Skip to content

Take the IMPACT backend from ITKIMPACT - #1463

Open
vboussot wants to merge 1 commit into
SuperElastix:mainfrom
vboussot:refactor-itkimpact-backend
Open

Take the IMPACT backend from ITKIMPACT#1463
vboussot wants to merge 1 commit into
SuperElastix:mainfrom
vboussot:refactor-itkimpact-backend

Conversation

@vboussot

@vboussot vboussot commented Aug 11, 2026

Copy link
Copy Markdown

The IMPACT losses, ModelConfiguration, online (Jacobian) inference, the vector-image interpolator and the Static feature-map generation come from the ITKIMPACT remote module, a one-way dependency Elastix to ITKIMPACT. The local copies (ImpactLoss.h, ImpactTensorUtils.*,
itkBSplineInterpolateVectorImageFunction.*, itkImpactModelConfiguration.h) are removed, and the backend's ModelConfiguration source is compiled into the Impact component so its torch-free public header stays Python-wrappable.

Building. With USE_ImpactMetric ON, ITKIMPACT_INCLUDE_DIR must point at the ITKIMPACT include/ directory. Both the ImpactMetric component and CommonGTest receive it, so elxImpactMetricGTest.cxx resolves the backend headers. ImpactWriteFeatureMaps becomes ImpactFeatureMapOutputDirectory.

Patch geometry follows the backend's. PatchPoint() sends each offset through the fixed image's direction matrix, one column per image axis, and the sampling callbacks receive the patch tensor shape from itk::Impact::PatchTensorShape(). This is the index-to-physical map ITKIMPACT applies in its v4 threader and in ImageToTensorFilter, so both modes describe the same neighbourhood.

CI provisions LibTorch with pip install torch on all three OSes, the same mechanism the backend uses. torch 2.11 is pinned rather than 2.12 because it is the last series still shipping CUDA cu128, the widest GPU coverage for the release: Blackwell plus older cards, driver floor R570, where 2.12 offers only cu126/cu129/cu130. The download_libtorch / build_libtorch actions are no longer referenced, and python-version moves to 3.11 for the
pip step.

@thewtex
thewtex requested a review from N-Dekker August 11, 2026 15:10
@vboussot
vboussot force-pushed the refactor-itkimpact-backend branch 6 times, most recently from 3cd2fee to b58ebf7 Compare August 11, 2026 18:15
The IMPACT losses, ModelConfiguration, online (Jacobian) inference, the
vector-image interpolator and the Static feature-map generation come from the
ITKIMPACT remote module, a one-way dependency Elastix to ITKIMPACT. The local
copies (ImpactLoss.h, ImpactTensorUtils.*, itkBSplineInterpolateVectorImageFunction.*,
itkImpactModelConfiguration.h) are removed, and the backend's ModelConfiguration
source is compiled into the Impact component so its torch-free public header stays
Python-wrappable.

With USE_ImpactMetric ON, ITKIMPACT_INCLUDE_DIR must point at the ITKIMPACT
include/ directory; both the ImpactMetric component and CommonGTest receive it, so
elxImpactMetricGTest.cxx resolves the backend headers. ImpactWriteFeatureMaps
becomes ImpactFeatureMapOutputDirectory.

The patch geometry follows the backend's. PatchPoint() sends each offset through
the fixed image's direction matrix, one column per image axis, and the sampling
callbacks receive the patch tensor shape from itk::Impact::PatchTensorShape().
This is the index-to-physical map ITKIMPACT applies in its v4 threader and in
ImageToTensorFilter, so both modes describe the same neighbourhood.

CI provisions LibTorch with `pip install torch`, the same mechanism the backend
uses, on every runner that has a wheel: all three on GitHub Actions, and Windows
and Ubuntu on Azure. Azure's hosted macOS agents are Intel and PyTorch publishes
no macOS x86_64 wheel past 2.2.2, so that one job builds LibTorch from source, at
the v2.11.0 tag so all three platforms compile against the same headers. On Windows
the steps that run elastix set PATH from cmd, whose entry separator is the one the
loader expects, so the LibTorch DLLs are found next to the plugin. torch 2.11 is pinned rather than 2.12 because it is the last series still
shipping CUDA cu128, the widest GPU coverage for the release: Blackwell plus
older cards, driver floor R570, where 2.12 offers only cu126/cu129/cu130. The
download_libtorch / build_libtorch actions are no longer referenced.

The three Static baselines are regenerated against this configuration, and the
suite is 8/8 on this branch.
@vboussot
vboussot force-pushed the refactor-itkimpact-backend branch from b58ebf7 to de9f456 Compare August 12, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants