diffct-mlx 2.3.0__tar.gz → 3.0.0rc1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/.github/workflows/release.yml +2 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/ATTRIBUTION.md +19 -2
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/CHANGELOG.md +124 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/PKG-INFO +19 -27
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/README.md +12 -25
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/__init__.py +1 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/_torch.py +68 -8
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/geometry.py +2 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/kernels/cone_beam.py +253 -253
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/kernels/fan_beam.py +82 -57
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/kernels/parallel_beam.py +48 -28
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/projectors.py +18 -14
- diffct_mlx-3.0.0rc1/diffct_mlx/conventions.py +84 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/LICENSE +201 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/NOTICE +20 -0
- {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/__init__.py +48 -5
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/_solver_state.py +348 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/_solver_tv.py +111 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/analytical.py +758 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/analytical_execution.py +468 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/backends.py +1366 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/chunking.py +241 -0
- {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/constants.py +30 -7
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/distribution.py +224 -0
- {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/footprint.py +56 -34
- {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/geometry.py +191 -56
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/__init__.py +66 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/analytical_transpose.py +319 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/cone_beam.py +701 -0
- {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/kernels/cone_footprint.py +17 -13
- {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/kernels/fan_beam.py +158 -91
- {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/kernels/fan_footprint.py +10 -6
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/geometry_vjp.py +709 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/parallel3d_beam.py +357 -0
- {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/kernels/parallel_beam.py +141 -77
- {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/kernels/parallel_footprint.py +9 -5
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/spacing.py +79 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/surface_geometry.py +149 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/operators.py +2971 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/pipeline.py +258 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/projectors.py +1014 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/reconstruction.py +498 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/solvers.py +350 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/storage.py +125 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/streaming.py +178 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/surface_gradients.py +117 -0
- diffct_mlx-3.0.0rc1/diffct_mlx/engine/surfaces.py +158 -0
- {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/utils.py +238 -21
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/operators.py +30 -30
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/orchestration/out_of_core.py +25 -17
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/physics/simulate.py +9 -12
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/rebinning.py +49 -22
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/_analytic.py +29 -8
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/cases.py +31 -25
- diffct_mlx-3.0.0rc1/docs/V3_PLAN.md +83 -0
- diffct_mlx-3.0.0rc1/docs/engine/DISTRIBUTED.md +292 -0
- diffct_mlx-3.0.0rc1/docs/engine/EXECUTION.md +342 -0
- diffct_mlx-3.0.0rc1/docs/engine/MIGRATION.md +133 -0
- diffct_mlx-3.0.0rc1/docs/engine/REFERENCE.md +453 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/conf.py +1 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/circular_trajectory/fbp_fan.py +1 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/circular_trajectory/fbp_parallel.py +1 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/circular_trajectory/fdk_cone.py +1 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/circular_trajectory/iterative_reco_cone.py +1 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/circular_trajectory/iterative_reco_fan.py +1 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/circular_trajectory/iterative_reco_parallel.py +1 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/non_circular_trajectory/iterative_reco_cone.py +2 -2
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/non_circular_trajectory/iterative_reco_fan.py +2 -2
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/non_circular_trajectory/iterative_reco_parallel.py +2 -2
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/plot_trajectory.py +1 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/pyproject.toml +9 -7
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/benchmarks/test_bench_cone.py +1 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/benchmarks/test_bench_fan.py +1 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/benchmarks/test_bench_parallel.py +1 -1
- diffct_mlx-3.0.0rc1/tests/engine/__init__.py +0 -0
- diffct_mlx-3.0.0rc1/tests/engine/_multiprocessing.py +26 -0
- diffct_mlx-3.0.0rc1/tests/engine/_native_per_axis_spacing.py +261 -0
- diffct_mlx-3.0.0rc1/tests/engine/_numba_cuda.py +18 -0
- diffct_mlx-3.0.0rc1/tests/engine/_phantoms.py +81 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/_block_cgls.py +265 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/_common.py +296 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/analytical_reconstruction.py +90 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/benchmark_execution.py +91 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/benchmark_gpu_overheads.py +102 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/benchmark_projector.py +237 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/benchmark_scaling.py +277 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/benchmark_surface_geometry.py +187 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/benchmark_trajectory_admission.py +114 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/chunked_reconstruction.py +71 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/curved_detector.py +55 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/data/NOTICE +65 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/data/preprocess_walnut.py +329 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/disk_reconstruction.py +168 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/geometry_calibration.py +101 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/helical_fdk.py +71 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/iterative_reconstruction.py +116 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/learnable_reconstruction.py +121 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/plot_trajectory.py +326 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/quickstart.py +64 -0
- diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/walnut_reconstruction.py +143 -0
- diffct_mlx-3.0.0rc1/tests/engine/conftest.py +12 -0
- diffct_mlx-3.0.0rc1/tests/engine/distributed_projector_check.py +709 -0
- diffct_mlx-3.0.0rc1/tests/engine/fixtures/native_scalar_spacing_main.npz +0 -0
- {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_adjoint_inner_product.py +1 -1
- diffct_mlx-3.0.0rc1/tests/engine/test_allocator_capacity.py +349 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_analytical_autograd.py +313 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_analytical_distribution.py +159 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_analytical_input_alias.py +201 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_analytical_input_alias_bfloat16.py +119 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_analytical_regressions.py +191 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_analytical_weight_distribution.py +83 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_angular_low_precision.py +70 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_axis_aligned_chords.py +118 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_batch_execution_edges.py +205 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_batched_surfaces.py +758 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_block_cgls.py +996 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_block_storage.py +607 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_call_trajectory.py +252 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_cgls_readonly_callback.py +519 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_cgls_state_admission.py +173 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_checkpoint_metadata_validation.py +154 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_chunked_projector.py +1317 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_completed_transfer_reuse.py +92 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_cone_backprojection_transpose.py +189 -0
- {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_cone_projector_autograd.py +1 -1
- diffct_mlx-3.0.0rc1/tests/engine/test_cuda_exit_deallocations.py +87 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_cuda_sink_lifetimes.py +125 -0
- {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_cuda_smoke.py +1 -1
- diffct_mlx-3.0.0rc1/tests/engine/test_detector_surface_dtypes.py +80 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_detector_surface_mapping.py +79 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_detector_surface_units.py +62 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_detector_surfaces.py +705 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_distributed_numeric_failure.py +370 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_distributed_numeric_failure_native.py +449 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_distributed_training_transforms.py +228 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_execution_buffers.py +676 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_execution_features.py +618 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_execution_schedules.py +584 -0
- {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_fbp_fan_accuracy.py +1 -1
- {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_fbp_fan_offsets.py +1 -1
- {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_fbp_parallel_accuracy.py +1 -1
- {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_fdk_cone_accuracy.py +1 -1
- {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_fdk_cone_offsets.py +1 -1
- diffct_mlx-3.0.0rc1/tests/engine/test_geometry_autograd.py +51 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_geometry_conversions.py +176 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_geometry_gradients.py +402 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_geometry_input_validation.py +393 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_gpu_performance_contracts.py +229 -0
- {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_gradcheck.py +41 -4
- diffct_mlx-3.0.0rc1/tests/engine/test_lazy_native_observers.py +171 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_live_trajectory_validation.py +234 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_mps_backend.py +431 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_multi_gpu_exit.py +87 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_multiprocessing.py +78 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_native_endpoint_precision.py +182 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_native_per_axis_admission.py +99 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_native_per_axis_extremes.py +139 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_native_per_axis_helical.py +93 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_native_per_axis_spacing.py +505 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_native_per_axis_spacing_gpu.py +237 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_native_stream_cache_threads.py +157 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_native_surface_transforms.py +110 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_native_volume_layout.py +326 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_native_volume_layout_distributed.py +79 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_output_pipeline_overlap.py +130 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_parallel3d.py +376 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_parallel3d_native.py +741 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_parallel3d_native_distributed.py +453 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_parallel3d_surface_oracle.py +149 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_partition_lifecycle.py +197 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_plan_memory_bounds.py +252 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_accuracy.py +141 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_bounded_autograd.py +945 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_cuda_budget.py +996 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_distributed_geometry.py +206 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_endpoint_precision.py +68 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_execution_bounds.py +203 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_into_default_dtype.py +42 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_into_snapshots.py +58 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_into_state_edges.py +122 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_into_work_plan.py +241 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_numeric_regressions.py +185 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_sampler_snapshot.py +160 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_portable_surface_admission.py +85 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_pr42_review_regressions.py +301 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_projector_api.py +803 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_projector_degenerate_geometry.py +257 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_projector_geometry_devices.py +69 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_projector_thread_safety.py +263 -0
- {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_ramp_filter_windows.py +46 -8
- diffct_mlx-3.0.0rc1/tests/engine/test_reconstruction_api.py +1048 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_reconstruction_work_reuse.py +231 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_reference_backend.py +481 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_release_2_0_1.py +324 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_review_230.py +99 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_review_regressions.py +345 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_runtime_store_failures.py +258 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_solver_admission_regressions.py +273 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_solver_api.py +778 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_solver_checkpoint_edges.py +364 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_solver_collective_failures.py +227 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_solver_device_scalars.py +257 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_spatial_partition.py +433 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_store_runtime_contract.py +197 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_collective_failures.py +523 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_composition_kernel.py +358 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_compute_shards.py +564 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_geometry_cudasim.py +607 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_gpu_execution.py +221 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_gradient_replay.py +226 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_host_sampling_budget.py +257 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_native_regressions.py +281 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_parameter_updates.py +271 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_pipeline_contracts.py +413 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_saved_snapshot_budget.py +274 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_snapshot_admission.py +209 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_surface_trajectory_transform.py +142 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_training_transforms.py +95 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_trajectory_admission_cost.py +257 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_trajectory_surface_integration.py +619 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_transfer_pipeline.py +646 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_transfer_retirement_lifetimes.py +166 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_tv_zero_dependency.py +75 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_two_far_endpoints.py +84 -0
- diffct_mlx-3.0.0rc1/tests/engine/test_weights.py +184 -0
- diffct_mlx-3.0.0rc1/tests/test_backend_parity.py +139 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_conventions.py +11 -8
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_footprint_amplitude.py +6 -3
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_known_operator_gradflow.py +1 -1
- diffct_mlx-3.0.0rc1/tests/test_metal_kernel_static.py +44 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_regressions.py +1 -1
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_siddon_centering.py +4 -4
- diffct_mlx-3.0.0rc1/tests/test_upstream_kernel_fixes.py +394 -0
- diffct_mlx-2.3.0/diffct/analytical.py +0 -521
- diffct_mlx-2.3.0/diffct/differentiable.py +0 -74
- diffct_mlx-2.3.0/diffct/kernels/__init__.py +0 -37
- diffct_mlx-2.3.0/diffct/kernels/cone_beam.py +0 -819
- diffct_mlx-2.3.0/diffct/projectors.py +0 -1124
- diffct_mlx-2.3.0/diffct_mlx/conventions.py +0 -83
- diffct_mlx-2.3.0/tests/test_metal_kernel_static.py +0 -34
- diffct_mlx-2.3.0/tests/test_weights.py +0 -126
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/.github/workflows/docs.yml +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/.github/workflows/publish.yml +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/.gitignore +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/LICENSE +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/analytical.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/__init__.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/_mlx.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/__init__.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/constants.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/kernels/__init__.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/utils.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/calibration.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/filters.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/functionals.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/geometry.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/orchestration/__init__.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/phantoms/__init__.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/phantoms/engine.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/phantoms/shepp_logan.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/physics/__init__.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/physics/corrections.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/physics/data/spectra.npz +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/physics/pipeline.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/physics/spectra.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/projectors.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/real_measured_data_helper.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/__init__.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/_core.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/_solver.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/asd_pocs.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/awtv_pocs.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/dart.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/fbp.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/fdk.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/sart.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/sirt.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/solvers.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/tv_pocs.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/regularizers.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/tv_gradients.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/Makefile +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/_static/.gitkeep +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/api.rst +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/examples.rst +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/fbp_fan_example.rst +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/fbp_parallel_example.rst +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/fdk_cone_example.rst +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/getting_started.rst +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/index.rst +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/iterative_reco_cone_example.rst +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/iterative_reco_fan_example.rst +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/iterative_reco_parallel_example.rst +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/pytest.ini +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/requirements.txt +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/__init__.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/_phantoms.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/benchmarks/README.md +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/benchmarks/__init__.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/benchmarks/_common.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_diffct_mlx_extensions.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_quantitative_fdk.py +0 -0
- {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tools/generate_spectra.py +0 -0
|
@@ -10,8 +10,8 @@ This `cuda` branch of **DiffCT-MLX** is **adapted from the original
|
|
|
10
10
|
| **Upstream project** | [diffct](https://github.com/sypsyp97/diffct) |
|
|
11
11
|
| **Original author** | Yipeng Sun (<yipeng.sun@fau.de>) |
|
|
12
12
|
| **License** | Apache License 2.0 — see [LICENSE](LICENSE) |
|
|
13
|
-
| **Imported from** | upstream `
|
|
14
|
-
| **Import date** | 2026-07-06 |
|
|
13
|
+
| **Imported from** | upstream `main`, v2.5.2, commit `982610e` (DiffCT-MLX 3.0, as `diffct_mlx.engine`) |
|
|
14
|
+
| **Import date** | 2026-11-25 (first import: `dev` v1.3.3.dev0, commit `cb516cf`, 2026-07-06, as top-level `diffct`; retired in 3.0) |
|
|
15
15
|
| **Maintained here by** | Linda-Sophie Schneider (<linda-sophie.schneider@fau.de>) |
|
|
16
16
|
|
|
17
17
|
The `dev` branch was chosen as the basis (rather than `main`) because its
|
|
@@ -30,6 +30,23 @@ match the DiffCT-MLX port, enabling a shared public API across backends.
|
|
|
30
30
|
This mirrors the historical relationship in which diffct's former `apple`
|
|
31
31
|
branch became the standalone DiffCT-MLX repository.
|
|
32
32
|
|
|
33
|
+
## Engine in DiffCT-MLX 3.0
|
|
34
|
+
|
|
35
|
+
From 3.0 the Torch / numba-CUDA engine is upstream diffct 2.5.2, vendored as
|
|
36
|
+
`diffct_mlx/engine/` with upstream's `LICENSE` and `NOTICE` next to it. It is
|
|
37
|
+
maintained here, independently of upstream releases; upstream fixes are merged
|
|
38
|
+
by hand. The internal name ends a clash with the PyPI package `diffct`: up to
|
|
39
|
+
2.x the DiffCT-MLX wheel installed its own top-level `diffct`.
|
|
40
|
+
|
|
41
|
+
Changes against upstream 2.5.2:
|
|
42
|
+
|
|
43
|
+
- `differentiable.py` (a deprecated import shim) is removed.
|
|
44
|
+
- DiffCT-MLX extensions, as new files: separable-footprint projectors
|
|
45
|
+
(`footprint.py`, `kernels/*_footprint.py`), registered in `kernels/__init__.py`.
|
|
46
|
+
- Upstream tests run from `tests/engine/` against `diffct_mlx.engine`; upstream
|
|
47
|
+
example helpers they need are in `tests/engine/_upstream/`, and upstream's
|
|
48
|
+
user documentation is in `docs/engine/`.
|
|
49
|
+
|
|
33
50
|
## Notice of changes (Apache-2.0 §4)
|
|
34
51
|
|
|
35
52
|
This branch is a modified redistribution of diffct. The initial commit is a
|
|
@@ -9,6 +9,128 @@ and the project follows [Semantic Versioning](https://semver.org/).
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [3.0.0rc1] - 2026-11-25
|
|
13
|
+
|
|
14
|
+
Release candidate for 3.0.0 (install with `pip install --pre`). Not yet run
|
|
15
|
+
on CUDA hardware; plan and status in `docs/V3_PLAN.md`. Breaking: both
|
|
16
|
+
backends now use centred detector pixels and physical line integrals (see
|
|
17
|
+
"Changed (3.0 conventions)"); `detector_convention="legacy"` and
|
|
18
|
+
`line_integrals="voxel"` reproduce 2.x.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- The Torch backend runs on upstream diffct 2.5.2, vendored as
|
|
23
|
+
`diffct_mlx.engine`. It brings exact geometry gradients, the portable
|
|
24
|
+
PyTorch backend (CPU, Apple MPS, ROCm; `precision="float64"`), the chunked
|
|
25
|
+
`Projector`, per-axis voxel spacing, `parallel3d`, detector surfaces,
|
|
26
|
+
solvers and all upstream kernel fixes since 2.0. Siddon calls on CPU or
|
|
27
|
+
MPS tensors now run on the portable backend instead of failing.
|
|
28
|
+
- The footprint CUDA kernels follow the upstream conventions: detector cell
|
|
29
|
+
`k` at `(k − (N−1)/2)·pitch` and physical line integrals. The MLX/Metal
|
|
30
|
+
backend has not switched yet.
|
|
31
|
+
- Out-of-core FDK (`gather`) uses per-view `sdd/(2π·sid)` constants and the
|
|
32
|
+
fitted isocenter, as the engine's `cone_weighted_backproject` does.
|
|
33
|
+
- The wheel no longer installs a top-level `diffct` package.
|
|
34
|
+
`requires-python` is now `>=3.10`. New extra `[torch]` installs the
|
|
35
|
+
portable engine without numba-cuda.
|
|
36
|
+
|
|
37
|
+
### Removed
|
|
38
|
+
|
|
39
|
+
- The vendored diffct `dev` engine (top-level `diffct/`) and its tests. The
|
|
40
|
+
upstream tests in `tests/engine/` replace them.
|
|
41
|
+
|
|
42
|
+
### Changed (3.0 conventions)
|
|
43
|
+
|
|
44
|
+
- **Both backends use the upstream diffct conventions.** The Metal Siddon,
|
|
45
|
+
footprint and cone geometry-gradient kernels place detector pixel `i` at
|
|
46
|
+
`(i − (N−1)/2)·du` and return physical line integrals (µ·length); their
|
|
47
|
+
adjoints and geometry gradients scale alike. The MLX analytical helpers
|
|
48
|
+
(rebinning, Parker fan angles, quantitative FDK cosine weights,
|
|
49
|
+
out-of-core shadow ranges) use the same grid. MLX and the Torch engine
|
|
50
|
+
agree to < 2e-4 relative L2 in forward and backprojection
|
|
51
|
+
(`tests/test_backend_parity.py`).
|
|
52
|
+
- `detector_convention` defaults to `"centered"` and `line_integrals` to
|
|
53
|
+
`"physical"`. `"legacy"` (2.3 alias `"kernel"`) and `"voxel"` reproduce
|
|
54
|
+
2.x results. `kernel_detector_center(..., convention="legacy")` shifts by
|
|
55
|
+
`−du/2·u − dv/2·v`.
|
|
56
|
+
- Iterative reconstruction of physical data returns µ in 1/mm. The
|
|
57
|
+
synthetic and npy cone cases feed the quantitative FDK with
|
|
58
|
+
`sinogram_scale=1.0`. `NpyProjectionsConfig.projection_units="voxel"`
|
|
59
|
+
converts stacks written by 2.x. `simulate_scan` treats operators without
|
|
60
|
+
unit metadata as physical.
|
|
61
|
+
|
|
62
|
+
### Fixed (3.0)
|
|
63
|
+
|
|
64
|
+
- **Cone geometry gradient on Metal.** The analytic kernel differentiated a
|
|
65
|
+
trilinear-interpolated volume, while the forward kernel has been
|
|
66
|
+
cell-constant Siddon since 2.0, so `src_pos`, `det_center`, `det_u_vec`
|
|
67
|
+
and `det_v_vec` gradients were off by about 100 % (already in 2.3.0). The
|
|
68
|
+
kernel now ports the engine's exact face-crossing VJP with the forward's
|
|
69
|
+
traversal. It matches the engine's float64 gradient to < 1e-3 relative
|
|
70
|
+
(standard, detector-inside-volume and distant-source geometries) and
|
|
71
|
+
finite differences at eps = 1e-5. Rays that lie exactly in a voxel face
|
|
72
|
+
plane are not differentiable there; both backends then return one
|
|
73
|
+
one-sided derivative.
|
|
74
|
+
|
|
75
|
+
### Fixed
|
|
76
|
+
|
|
77
|
+
Kernel and analytical fixes of upstream diffct 2.0 to 2.5, ported into the
|
|
78
|
+
Metal kernels (`diffct_mlx/backend/metal/kernels/`) and the MLX analytical
|
|
79
|
+
code. The Torch backend gets them with the engine. Metal keeps the
|
|
80
|
+
`(k − N/2)·du` detector convention and voxel units until the 3.0 convention
|
|
81
|
+
switch. Regression tests in `tests/test_upstream_kernel_fixes.py` use the
|
|
82
|
+
public API and do not depend on either convention.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
- **Fan and cone rays integrate only from the source to the detector pixel.**
|
|
86
|
+
The Metal Siddon forward, backward and cone geometry-gradient kernels clamp
|
|
87
|
+
the ray parameter to the source-detector segment. Before, a source or
|
|
88
|
+
detector inside the volume gave the full-line integral through the volume.
|
|
89
|
+
- **Distant sources no longer drift.** Fan and cone ray setup measures the ray
|
|
90
|
+
parameter from the endpoint nearer the volume centre, and the traversal
|
|
91
|
+
restarts at the volume entry point. Before, a source 1e4 voxels away gave
|
|
92
|
+
relative errors of 3e-3 and a source 1e6 voxels away errors of 0.1.
|
|
93
|
+
- **Ray pieces of any positive length count.** The Siddon kernels skipped
|
|
94
|
+
pieces of length up to 1e-6 voxels, so a projection jumped when a ray
|
|
95
|
+
started or stopped clipping a voxel corner. They now skip only pieces of
|
|
96
|
+
length 0, and a projection is a continuous function of the geometry.
|
|
97
|
+
- **Axis-parallel threshold.** A direction component counts as
|
|
98
|
+
axis-parallel only below 1e-20 instead of 1e-6. With the old limit a ray
|
|
99
|
+
that grazed a grid line stayed in the neighbouring row, and a ray with a
|
|
100
|
+
small lateral component outside the volume bounds was dropped. The
|
|
101
|
+
traversal parameter never moves backwards, so a nearly axis-parallel ray
|
|
102
|
+
whose entry cell rounds to the wrong side of a grid line is not counted
|
|
103
|
+
twice. The kernels keep the finite 1e30 sentinel in place of infinity,
|
|
104
|
+
which fast math may assume never occurs.
|
|
105
|
+
- **2D parallel kernels normalize `ray_dir`.** A non-unit ray direction
|
|
106
|
+
scaled every line integral of the forward and adjoint parallel projectors
|
|
107
|
+
(upstream #79).
|
|
108
|
+
- **Cone geometry gradient with the detector inside the volume.** With the
|
|
109
|
+
clamped segment, moving the detector pixel along the ray changes the
|
|
110
|
+
integrated length. The gradient kernel adds this `mu(p)` boundary term and
|
|
111
|
+
weights each sample by its distance from the source.
|
|
112
|
+
- **Parker weights.** `diffct_mlx.rebinning.parker_weights` uses the
|
|
113
|
+
generalized Parker taper with half-width `max(gamma_max, (range - pi)/2)`,
|
|
114
|
+
so scans longer than a minimal short scan keep their overscan views and
|
|
115
|
+
every detector still integrates to `pi`. Before, views past
|
|
116
|
+
`pi + 2*gamma_max` got zero weight. A full turn returns ones, decided from
|
|
117
|
+
the acquired angles alone and not from the fan width.
|
|
118
|
+
- **Discrete Ram-Lak filter.** The MLX analytical ramp filter
|
|
119
|
+
(`ramp_filter`, `ramp_filter_2d`, `ramp_filter_3d`) uses the transform of
|
|
120
|
+
the finite Ram-Lak kernel, `h[0] = 1/2` and `h[k] = -2/(pi*k)^2` for odd
|
|
121
|
+
`k`, in place of the sampled `2*|f|`. The scale at Nyquist is unchanged.
|
|
122
|
+
The sampled ramp removed the small positive DC response of the finite
|
|
123
|
+
kernel and biased the low frequencies of finite projections.
|
|
124
|
+
- **`custom_trajectory_3d` rejects non-finite sources** on MLX with a
|
|
125
|
+
`ValueError`. It already rejected a source at the isocenter.
|
|
126
|
+
|
|
127
|
+
### Not ported
|
|
128
|
+
|
|
129
|
+
Upstream's per-view SID/SDD in the FBP/FDK constant, wrapped short-scan
|
|
130
|
+
angular weights (#77) and FP64 angular weights have no MLX counterpart. The
|
|
131
|
+
MLX analytical pipeline uses a scalar angular normalization, and Metal has no
|
|
132
|
+
FP64. The Torch backend has them through the engine.
|
|
133
|
+
|
|
12
134
|
## [2.3.0] - 2026-11-25
|
|
13
135
|
|
|
14
136
|
### Added
|
|
@@ -509,7 +631,8 @@ necessary for the arbitrary-trajectory kernel API:
|
|
|
509
631
|
when the detector is not plane-aligned to the voxel axes) and will
|
|
510
632
|
be tackled in a dedicated follow-up.
|
|
511
633
|
|
|
512
|
-
[Unreleased]: https://github.com/Linda-SophieSchneider/DiffCT-MLX/compare/
|
|
634
|
+
[Unreleased]: https://github.com/Linda-SophieSchneider/DiffCT-MLX/compare/v3.0.0rc1...HEAD
|
|
635
|
+
[3.0.0rc1]: https://github.com/Linda-SophieSchneider/DiffCT-MLX/compare/v2.3.0...v3.0.0rc1
|
|
513
636
|
[2.3.0]: https://github.com/Linda-SophieSchneider/DiffCT-MLX/compare/v2.2.0...v2.3.0
|
|
514
637
|
[2.2.0]: https://github.com/Linda-SophieSchneider/DiffCT-MLX/compare/v2.1.0...v2.2.0
|
|
515
638
|
[2.1.0]: https://github.com/Linda-SophieSchneider/DiffCT-MLX/compare/v2.0.1...v2.1.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: diffct-mlx
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0rc1
|
|
4
4
|
Summary: Differentiable computed tomography with an auto-selecting backend (Torch/CUDA or Apple MLX)
|
|
5
5
|
Project-URL: Homepage, https://github.com/Linda-SophieSchneider/DiffCT-MLX
|
|
6
6
|
Project-URL: Upstream, https://github.com/sypsyp97/diffct
|
|
@@ -12,14 +12,19 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
13
13
|
Classifier: Programming Language :: Python :: 3
|
|
14
14
|
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
15
|
-
Requires-Python: >=3.
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
16
|
Requires-Dist: numpy
|
|
17
17
|
Provides-Extra: cuda
|
|
18
|
+
Requires-Dist: numba; extra == 'cuda'
|
|
18
19
|
Requires-Dist: numba-cuda; extra == 'cuda'
|
|
19
20
|
Requires-Dist: numpy<2.5; extra == 'cuda'
|
|
20
21
|
Requires-Dist: torch; extra == 'cuda'
|
|
21
22
|
Provides-Extra: mlx
|
|
22
23
|
Requires-Dist: mlx; extra == 'mlx'
|
|
24
|
+
Provides-Extra: torch
|
|
25
|
+
Requires-Dist: numba; extra == 'torch'
|
|
26
|
+
Requires-Dist: numpy<2.5; extra == 'torch'
|
|
27
|
+
Requires-Dist: torch; extra == 'torch'
|
|
23
28
|
Provides-Extra: zarr
|
|
24
29
|
Requires-Dist: zarr>=3; extra == 'zarr'
|
|
25
30
|
Description-Content-Type: text/markdown
|
|
@@ -140,34 +145,21 @@ vol_mu = dct.reconstruct_case_fdk(case) # true attenuation units (1/mm)
|
|
|
140
145
|
|
|
141
146
|
All cone cases (synthetic, measured TIFF, npy) carry the quantitative
|
|
142
147
|
operators (`case.fdk_weight` / `fdk_filter` / `fdk_back_project`); sinogram
|
|
143
|
-
units are
|
|
144
|
-
|
|
148
|
+
units are physical for every source (measured −log data and projector
|
|
149
|
+
output alike). The ramp
|
|
145
150
|
filter itself now accepts `pad_factor` and `sample_spacing`, and
|
|
146
151
|
`FBPParameters`/`FDKParameters` default to `pad_factor=2`.
|
|
147
152
|
|
|
148
|
-
> **
|
|
149
|
-
>
|
|
150
|
-
>
|
|
151
|
-
>
|
|
152
|
-
>
|
|
153
|
-
> `
|
|
154
|
-
>
|
|
155
|
-
> `
|
|
156
|
-
>
|
|
157
|
-
>
|
|
158
|
-
> reconstruction of measured (physical) data converges to attenuation *per
|
|
159
|
-
> voxel*; divide by `case.voxel_spacing` for µ in 1/mm.
|
|
160
|
-
>
|
|
161
|
-
> **Detector convention.** The kernels place detector pixel `i` at
|
|
162
|
-
> `det_center + (i − N/2)·du` (the diffct `dev` line they come from), half a
|
|
163
|
-
> pixel off the geometric panel centre. Upstream diffct ≥ 2.0, DiffCT-MLX 1.x
|
|
164
|
-
> and scanner geometry files use `(i − (N−1)/2)·du` and physical line
|
|
165
|
-
> integrals. To work in that convention, build operators with
|
|
166
|
-
> `detector_convention="centered", line_integrals="physical"`
|
|
167
|
-
> (`make_*_operator` and `make_*_operators`); `A.T` scales alike and stays
|
|
168
|
-
> the exact adjoint, and reconstructions then come out in 1/mm. For direct
|
|
169
|
-
> projector or FBP/FDK calls, `dct.kernel_detector_center(...)` converts a
|
|
170
|
-
> panel-centre `det_center` (shift by `+du/2·u + dv/2·v`).
|
|
153
|
+
> **Conventions (3.0).** Both backends follow upstream diffct ≥ 2.0. Detector
|
|
154
|
+
> pixel `i` sits at `det_center + (i − (N−1)/2)·du`, so `det_center` is the
|
|
155
|
+
> geometric panel centre, and projections are physical line integrals
|
|
156
|
+
> (µ·length in the unit of the geometry). Iterative reconstruction of
|
|
157
|
+
> physical data therefore returns µ in 1/mm, like the quantitative FDK path.
|
|
158
|
+
> DiffCT-MLX 2.x placed pixel `i` at `(i − N/2)·du` and integrated in voxel
|
|
159
|
+
> units. To reproduce 2.x results, build operators with
|
|
160
|
+
> `detector_convention="legacy", line_integrals="voxel"`; for direct projector
|
|
161
|
+
> or FBP/FDK calls, `dct.kernel_detector_center(..., convention="legacy")`
|
|
162
|
+
> converts `det_center`.
|
|
171
163
|
|
|
172
164
|
### Operators, solvers, regularizers, physics & simulation
|
|
173
165
|
|
|
@@ -114,34 +114,21 @@ vol_mu = dct.reconstruct_case_fdk(case) # true attenuation units (1/mm)
|
|
|
114
114
|
|
|
115
115
|
All cone cases (synthetic, measured TIFF, npy) carry the quantitative
|
|
116
116
|
operators (`case.fdk_weight` / `fdk_filter` / `fdk_back_project`); sinogram
|
|
117
|
-
units are
|
|
118
|
-
|
|
117
|
+
units are physical for every source (measured −log data and projector
|
|
118
|
+
output alike). The ramp
|
|
119
119
|
filter itself now accepts `pad_factor` and `sample_spacing`, and
|
|
120
120
|
`FBPParameters`/`FDKParameters` default to `pad_factor=2`.
|
|
121
121
|
|
|
122
|
-
> **
|
|
123
|
-
>
|
|
124
|
-
>
|
|
125
|
-
>
|
|
126
|
-
>
|
|
127
|
-
> `
|
|
128
|
-
>
|
|
129
|
-
> `
|
|
130
|
-
>
|
|
131
|
-
>
|
|
132
|
-
> reconstruction of measured (physical) data converges to attenuation *per
|
|
133
|
-
> voxel*; divide by `case.voxel_spacing` for µ in 1/mm.
|
|
134
|
-
>
|
|
135
|
-
> **Detector convention.** The kernels place detector pixel `i` at
|
|
136
|
-
> `det_center + (i − N/2)·du` (the diffct `dev` line they come from), half a
|
|
137
|
-
> pixel off the geometric panel centre. Upstream diffct ≥ 2.0, DiffCT-MLX 1.x
|
|
138
|
-
> and scanner geometry files use `(i − (N−1)/2)·du` and physical line
|
|
139
|
-
> integrals. To work in that convention, build operators with
|
|
140
|
-
> `detector_convention="centered", line_integrals="physical"`
|
|
141
|
-
> (`make_*_operator` and `make_*_operators`); `A.T` scales alike and stays
|
|
142
|
-
> the exact adjoint, and reconstructions then come out in 1/mm. For direct
|
|
143
|
-
> projector or FBP/FDK calls, `dct.kernel_detector_center(...)` converts a
|
|
144
|
-
> panel-centre `det_center` (shift by `+du/2·u + dv/2·v`).
|
|
122
|
+
> **Conventions (3.0).** Both backends follow upstream diffct ≥ 2.0. Detector
|
|
123
|
+
> pixel `i` sits at `det_center + (i − (N−1)/2)·du`, so `det_center` is the
|
|
124
|
+
> geometric panel centre, and projections are physical line integrals
|
|
125
|
+
> (µ·length in the unit of the geometry). Iterative reconstruction of
|
|
126
|
+
> physical data therefore returns µ in 1/mm, like the quantitative FDK path.
|
|
127
|
+
> DiffCT-MLX 2.x placed pixel `i` at `(i − N/2)·du` and integrated in voxel
|
|
128
|
+
> units. To reproduce 2.x results, build operators with
|
|
129
|
+
> `detector_convention="legacy", line_integrals="voxel"`; for direct projector
|
|
130
|
+
> or FBP/FDK calls, `dct.kernel_detector_center(..., convention="legacy")`
|
|
131
|
+
> converts `det_center`.
|
|
145
132
|
|
|
146
133
|
### Operators, solvers, regularizers, physics & simulation
|
|
147
134
|
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
"""Torch / CUDA backend.
|
|
2
2
|
|
|
3
|
-
Thin adapter over the upstream
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
Thin adapter over :mod:`diffct_mlx.engine` (the vendored upstream diffct 2.5
|
|
4
|
+
engine plus the DiffCT-MLX footprint kernels). It re-exports the projectors as
|
|
5
|
+
plain functional operators with the unified signatures, exposes the
|
|
6
|
+
``geometry`` and ``analytical`` submodules, and provides :data:`xp`, an
|
|
7
|
+
MLX-``core``-shaped array namespace on top of torch, so the higher-level
|
|
8
|
+
reconstruction layer is written once for both backends.
|
|
9
|
+
|
|
10
|
+
Siddon projections run on the native numba-CUDA kernels for CUDA tensors and on
|
|
11
|
+
the engine's portable PyTorch backend for CPU and Apple MPS tensors. The
|
|
12
|
+
footprint projectors are CUDA-only.
|
|
8
13
|
"""
|
|
9
14
|
|
|
15
|
+
import functools
|
|
10
16
|
from types import SimpleNamespace
|
|
11
17
|
|
|
12
18
|
import numpy as _np
|
|
13
19
|
import torch
|
|
14
20
|
|
|
15
|
-
from
|
|
21
|
+
from .. import engine as _engine
|
|
22
|
+
from ..engine import (
|
|
16
23
|
ParallelProjectorFunction,
|
|
17
24
|
ParallelBackprojectorFunction,
|
|
18
25
|
FanProjectorFunction,
|
|
@@ -20,8 +27,9 @@ from diffct import (
|
|
|
20
27
|
ConeProjectorFunction,
|
|
21
28
|
ConeBackprojectorFunction,
|
|
22
29
|
)
|
|
23
|
-
from
|
|
24
|
-
from
|
|
30
|
+
from ..engine import geometry as _engine_geometry
|
|
31
|
+
from ..engine import analytical # noqa: F401 (re-exported)
|
|
32
|
+
from ..engine.footprint import (
|
|
25
33
|
ParallelFootprintProjectorFunction,
|
|
26
34
|
ParallelFootprintBackprojectorFunction,
|
|
27
35
|
FanFootprintProjectorFunction,
|
|
@@ -51,6 +59,25 @@ def get_default_device():
|
|
|
51
59
|
return _DEFAULT_DEVICE
|
|
52
60
|
|
|
53
61
|
|
|
62
|
+
# --- Geometry: engine generators, defaulting to the backend's device --------
|
|
63
|
+
|
|
64
|
+
def _with_default_device(fn):
|
|
65
|
+
@functools.wraps(fn)
|
|
66
|
+
def wrapper(*args, **kwargs):
|
|
67
|
+
if "device" not in kwargs:
|
|
68
|
+
kwargs["device"] = _DEFAULT_DEVICE
|
|
69
|
+
return fn(*args, **kwargs)
|
|
70
|
+
return wrapper
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
geometry = SimpleNamespace(**{
|
|
74
|
+
name: (_with_default_device(getattr(_engine_geometry, name))
|
|
75
|
+
if name.endswith(("_2d", "_3d", "_fan", "_parallel")) else getattr(_engine_geometry, name))
|
|
76
|
+
for name in dir(_engine_geometry)
|
|
77
|
+
if not name.startswith("_") and callable(getattr(_engine_geometry, name))
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
|
|
54
81
|
# --- Conversions ------------------------------------------------------------
|
|
55
82
|
|
|
56
83
|
def as_array(data, dtype=None, device=None):
|
|
@@ -287,9 +314,27 @@ xp = SimpleNamespace(
|
|
|
287
314
|
|
|
288
315
|
|
|
289
316
|
# --- Functional line-based projectors (unified signatures) ------------------
|
|
317
|
+
# CUDA tensors: native autograd Functions (exact geometry gradients).
|
|
318
|
+
# CPU / MPS tensors: the engine's portable PyTorch Projector.
|
|
319
|
+
|
|
320
|
+
def _is_native(x):
|
|
321
|
+
return isinstance(x, torch.Tensor) and x.is_cuda
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def _portable(beam, x, trajectory, volume_shape, detector_shape, detector_spacing,
|
|
325
|
+
voxel_spacing, adjoint):
|
|
326
|
+
projector = _engine.Projector(
|
|
327
|
+
tuple(trajectory), tuple(volume_shape), tuple(detector_shape), beam=beam,
|
|
328
|
+
detector_spacing=detector_spacing, voxel_spacing=voxel_spacing, backend="torch",
|
|
329
|
+
)
|
|
330
|
+
return projector.backproject(x) if adjoint else projector(x)
|
|
331
|
+
|
|
290
332
|
|
|
291
333
|
def parallel_forward(image, ray_dir, det_origin, det_u_vec,
|
|
292
334
|
num_detectors=128, detector_spacing=1.0, voxel_spacing=1.0):
|
|
335
|
+
if not _is_native(image):
|
|
336
|
+
return _portable("parallel", image, (ray_dir, det_origin, det_u_vec), image.shape,
|
|
337
|
+
(num_detectors,), detector_spacing, voxel_spacing, adjoint=False)
|
|
293
338
|
return ParallelProjectorFunction.apply(
|
|
294
339
|
image, ray_dir, det_origin, det_u_vec,
|
|
295
340
|
num_detectors, detector_spacing, voxel_spacing)
|
|
@@ -297,6 +342,9 @@ def parallel_forward(image, ray_dir, det_origin, det_u_vec,
|
|
|
297
342
|
|
|
298
343
|
def parallel_backward(sinogram, ray_dir, det_origin, det_u_vec,
|
|
299
344
|
detector_spacing=1.0, H=128, W=128, voxel_spacing=1.0):
|
|
345
|
+
if not _is_native(sinogram):
|
|
346
|
+
return _portable("parallel", sinogram, (ray_dir, det_origin, det_u_vec), (H, W),
|
|
347
|
+
(sinogram.shape[-1],), detector_spacing, voxel_spacing, adjoint=True)
|
|
300
348
|
return ParallelBackprojectorFunction.apply(
|
|
301
349
|
sinogram, ray_dir, det_origin, det_u_vec,
|
|
302
350
|
detector_spacing, H, W, voxel_spacing)
|
|
@@ -304,6 +352,9 @@ def parallel_backward(sinogram, ray_dir, det_origin, det_u_vec,
|
|
|
304
352
|
|
|
305
353
|
def fan_forward(image, src_pos, det_center, det_u_vec,
|
|
306
354
|
num_detectors=128, detector_spacing=1.0, voxel_spacing=1.0):
|
|
355
|
+
if not _is_native(image):
|
|
356
|
+
return _portable("fan", image, (src_pos, det_center, det_u_vec), image.shape,
|
|
357
|
+
(num_detectors,), detector_spacing, voxel_spacing, adjoint=False)
|
|
307
358
|
return FanProjectorFunction.apply(
|
|
308
359
|
image, src_pos, det_center, det_u_vec,
|
|
309
360
|
num_detectors, detector_spacing, voxel_spacing)
|
|
@@ -311,6 +362,9 @@ def fan_forward(image, src_pos, det_center, det_u_vec,
|
|
|
311
362
|
|
|
312
363
|
def fan_backward(sinogram, src_pos, det_center, det_u_vec,
|
|
313
364
|
detector_spacing=1.0, H=128, W=128, voxel_spacing=1.0):
|
|
365
|
+
if not _is_native(sinogram):
|
|
366
|
+
return _portable("fan", sinogram, (src_pos, det_center, det_u_vec), (H, W),
|
|
367
|
+
(sinogram.shape[-1],), detector_spacing, voxel_spacing, adjoint=True)
|
|
314
368
|
return FanBackprojectorFunction.apply(
|
|
315
369
|
sinogram, src_pos, det_center, det_u_vec,
|
|
316
370
|
detector_spacing, H, W, voxel_spacing)
|
|
@@ -318,6 +372,9 @@ def fan_backward(sinogram, src_pos, det_center, det_u_vec,
|
|
|
318
372
|
|
|
319
373
|
def cone_forward(volume, src_pos, det_center, det_u_vec, det_v_vec,
|
|
320
374
|
det_u=128, det_v=128, du=1.0, dv=1.0, voxel_spacing=1.0):
|
|
375
|
+
if not _is_native(volume):
|
|
376
|
+
return _portable("cone", volume, (src_pos, det_center, det_u_vec, det_v_vec), volume.shape,
|
|
377
|
+
(det_u, det_v), (du, dv), voxel_spacing, adjoint=False)
|
|
321
378
|
return ConeProjectorFunction.apply(
|
|
322
379
|
volume, src_pos, det_center, det_u_vec, det_v_vec,
|
|
323
380
|
det_u, det_v, du, dv, voxel_spacing)
|
|
@@ -325,6 +382,9 @@ def cone_forward(volume, src_pos, det_center, det_u_vec, det_v_vec,
|
|
|
325
382
|
|
|
326
383
|
def cone_backward(sinogram, src_pos, det_center, det_u_vec, det_v_vec,
|
|
327
384
|
D=128, H=128, W=128, du=1.0, dv=1.0, voxel_spacing=1.0):
|
|
385
|
+
if not _is_native(sinogram):
|
|
386
|
+
return _portable("cone", sinogram, (src_pos, det_center, det_u_vec, det_v_vec), (D, H, W),
|
|
387
|
+
tuple(sinogram.shape[-2:]), (du, dv), voxel_spacing, adjoint=True)
|
|
328
388
|
return ConeBackprojectorFunction.apply(
|
|
329
389
|
sinogram, src_pos, det_center, det_u_vec, det_v_vec,
|
|
330
390
|
D, H, W, du, dv, voxel_spacing)
|
|
@@ -321,6 +321,8 @@ def custom_trajectory_3d(n_views, sid, sdd,
|
|
|
321
321
|
if src_pos.shape != (n_views, 3):
|
|
322
322
|
raise ValueError(f"source_path_fn must return shape ({n_views}, 3), got {src_pos.shape}")
|
|
323
323
|
|
|
324
|
+
if not bool(mx.all(mx.isfinite(src_pos))):
|
|
325
|
+
raise ValueError("source_path_fn returned non-finite source positions")
|
|
324
326
|
src_norm = mx.linalg.norm(src_pos, axis=1)
|
|
325
327
|
mx.eval(src_norm)
|
|
326
328
|
min_src_norm = float(mx.min(src_norm))
|