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.
Files changed (303) hide show
  1. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/.github/workflows/release.yml +2 -1
  2. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/ATTRIBUTION.md +19 -2
  3. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/CHANGELOG.md +124 -1
  4. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/PKG-INFO +19 -27
  5. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/README.md +12 -25
  6. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/__init__.py +1 -1
  7. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/_torch.py +68 -8
  8. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/geometry.py +2 -0
  9. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/kernels/cone_beam.py +253 -253
  10. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/kernels/fan_beam.py +82 -57
  11. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/kernels/parallel_beam.py +48 -28
  12. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/projectors.py +18 -14
  13. diffct_mlx-3.0.0rc1/diffct_mlx/conventions.py +84 -0
  14. diffct_mlx-3.0.0rc1/diffct_mlx/engine/LICENSE +201 -0
  15. diffct_mlx-3.0.0rc1/diffct_mlx/engine/NOTICE +20 -0
  16. {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/__init__.py +48 -5
  17. diffct_mlx-3.0.0rc1/diffct_mlx/engine/_solver_state.py +348 -0
  18. diffct_mlx-3.0.0rc1/diffct_mlx/engine/_solver_tv.py +111 -0
  19. diffct_mlx-3.0.0rc1/diffct_mlx/engine/analytical.py +758 -0
  20. diffct_mlx-3.0.0rc1/diffct_mlx/engine/analytical_execution.py +468 -0
  21. diffct_mlx-3.0.0rc1/diffct_mlx/engine/backends.py +1366 -0
  22. diffct_mlx-3.0.0rc1/diffct_mlx/engine/chunking.py +241 -0
  23. {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/constants.py +30 -7
  24. diffct_mlx-3.0.0rc1/diffct_mlx/engine/distribution.py +224 -0
  25. {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/footprint.py +56 -34
  26. {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/geometry.py +191 -56
  27. diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/__init__.py +66 -0
  28. diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/analytical_transpose.py +319 -0
  29. diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/cone_beam.py +701 -0
  30. {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/kernels/cone_footprint.py +17 -13
  31. {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/kernels/fan_beam.py +158 -91
  32. {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/kernels/fan_footprint.py +10 -6
  33. diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/geometry_vjp.py +709 -0
  34. diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/parallel3d_beam.py +357 -0
  35. {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/kernels/parallel_beam.py +141 -77
  36. {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/kernels/parallel_footprint.py +9 -5
  37. diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/spacing.py +79 -0
  38. diffct_mlx-3.0.0rc1/diffct_mlx/engine/kernels/surface_geometry.py +149 -0
  39. diffct_mlx-3.0.0rc1/diffct_mlx/engine/operators.py +2971 -0
  40. diffct_mlx-3.0.0rc1/diffct_mlx/engine/pipeline.py +258 -0
  41. diffct_mlx-3.0.0rc1/diffct_mlx/engine/projectors.py +1014 -0
  42. diffct_mlx-3.0.0rc1/diffct_mlx/engine/reconstruction.py +498 -0
  43. diffct_mlx-3.0.0rc1/diffct_mlx/engine/solvers.py +350 -0
  44. diffct_mlx-3.0.0rc1/diffct_mlx/engine/storage.py +125 -0
  45. diffct_mlx-3.0.0rc1/diffct_mlx/engine/streaming.py +178 -0
  46. diffct_mlx-3.0.0rc1/diffct_mlx/engine/surface_gradients.py +117 -0
  47. diffct_mlx-3.0.0rc1/diffct_mlx/engine/surfaces.py +158 -0
  48. {diffct_mlx-2.3.0/diffct → diffct_mlx-3.0.0rc1/diffct_mlx/engine}/utils.py +238 -21
  49. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/operators.py +30 -30
  50. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/orchestration/out_of_core.py +25 -17
  51. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/physics/simulate.py +9 -12
  52. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/rebinning.py +49 -22
  53. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/_analytic.py +29 -8
  54. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/cases.py +31 -25
  55. diffct_mlx-3.0.0rc1/docs/V3_PLAN.md +83 -0
  56. diffct_mlx-3.0.0rc1/docs/engine/DISTRIBUTED.md +292 -0
  57. diffct_mlx-3.0.0rc1/docs/engine/EXECUTION.md +342 -0
  58. diffct_mlx-3.0.0rc1/docs/engine/MIGRATION.md +133 -0
  59. diffct_mlx-3.0.0rc1/docs/engine/REFERENCE.md +453 -0
  60. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/conf.py +1 -1
  61. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/circular_trajectory/fbp_fan.py +1 -1
  62. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/circular_trajectory/fbp_parallel.py +1 -1
  63. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/circular_trajectory/fdk_cone.py +1 -1
  64. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/circular_trajectory/iterative_reco_cone.py +1 -1
  65. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/circular_trajectory/iterative_reco_fan.py +1 -1
  66. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/circular_trajectory/iterative_reco_parallel.py +1 -1
  67. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/non_circular_trajectory/iterative_reco_cone.py +2 -2
  68. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/non_circular_trajectory/iterative_reco_fan.py +2 -2
  69. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/non_circular_trajectory/iterative_reco_parallel.py +2 -2
  70. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/examples/plot_trajectory.py +1 -1
  71. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/pyproject.toml +9 -7
  72. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/benchmarks/test_bench_cone.py +1 -1
  73. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/benchmarks/test_bench_fan.py +1 -1
  74. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/benchmarks/test_bench_parallel.py +1 -1
  75. diffct_mlx-3.0.0rc1/tests/engine/__init__.py +0 -0
  76. diffct_mlx-3.0.0rc1/tests/engine/_multiprocessing.py +26 -0
  77. diffct_mlx-3.0.0rc1/tests/engine/_native_per_axis_spacing.py +261 -0
  78. diffct_mlx-3.0.0rc1/tests/engine/_numba_cuda.py +18 -0
  79. diffct_mlx-3.0.0rc1/tests/engine/_phantoms.py +81 -0
  80. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/_block_cgls.py +265 -0
  81. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/_common.py +296 -0
  82. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/analytical_reconstruction.py +90 -0
  83. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/benchmark_execution.py +91 -0
  84. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/benchmark_gpu_overheads.py +102 -0
  85. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/benchmark_projector.py +237 -0
  86. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/benchmark_scaling.py +277 -0
  87. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/benchmark_surface_geometry.py +187 -0
  88. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/benchmark_trajectory_admission.py +114 -0
  89. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/chunked_reconstruction.py +71 -0
  90. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/curved_detector.py +55 -0
  91. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/data/NOTICE +65 -0
  92. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/data/preprocess_walnut.py +329 -0
  93. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/disk_reconstruction.py +168 -0
  94. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/geometry_calibration.py +101 -0
  95. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/helical_fdk.py +71 -0
  96. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/iterative_reconstruction.py +116 -0
  97. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/learnable_reconstruction.py +121 -0
  98. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/plot_trajectory.py +326 -0
  99. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/quickstart.py +64 -0
  100. diffct_mlx-3.0.0rc1/tests/engine/_upstream/examples/walnut_reconstruction.py +143 -0
  101. diffct_mlx-3.0.0rc1/tests/engine/conftest.py +12 -0
  102. diffct_mlx-3.0.0rc1/tests/engine/distributed_projector_check.py +709 -0
  103. diffct_mlx-3.0.0rc1/tests/engine/fixtures/native_scalar_spacing_main.npz +0 -0
  104. {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_adjoint_inner_product.py +1 -1
  105. diffct_mlx-3.0.0rc1/tests/engine/test_allocator_capacity.py +349 -0
  106. diffct_mlx-3.0.0rc1/tests/engine/test_analytical_autograd.py +313 -0
  107. diffct_mlx-3.0.0rc1/tests/engine/test_analytical_distribution.py +159 -0
  108. diffct_mlx-3.0.0rc1/tests/engine/test_analytical_input_alias.py +201 -0
  109. diffct_mlx-3.0.0rc1/tests/engine/test_analytical_input_alias_bfloat16.py +119 -0
  110. diffct_mlx-3.0.0rc1/tests/engine/test_analytical_regressions.py +191 -0
  111. diffct_mlx-3.0.0rc1/tests/engine/test_analytical_weight_distribution.py +83 -0
  112. diffct_mlx-3.0.0rc1/tests/engine/test_angular_low_precision.py +70 -0
  113. diffct_mlx-3.0.0rc1/tests/engine/test_axis_aligned_chords.py +118 -0
  114. diffct_mlx-3.0.0rc1/tests/engine/test_batch_execution_edges.py +205 -0
  115. diffct_mlx-3.0.0rc1/tests/engine/test_batched_surfaces.py +758 -0
  116. diffct_mlx-3.0.0rc1/tests/engine/test_block_cgls.py +996 -0
  117. diffct_mlx-3.0.0rc1/tests/engine/test_block_storage.py +607 -0
  118. diffct_mlx-3.0.0rc1/tests/engine/test_call_trajectory.py +252 -0
  119. diffct_mlx-3.0.0rc1/tests/engine/test_cgls_readonly_callback.py +519 -0
  120. diffct_mlx-3.0.0rc1/tests/engine/test_cgls_state_admission.py +173 -0
  121. diffct_mlx-3.0.0rc1/tests/engine/test_checkpoint_metadata_validation.py +154 -0
  122. diffct_mlx-3.0.0rc1/tests/engine/test_chunked_projector.py +1317 -0
  123. diffct_mlx-3.0.0rc1/tests/engine/test_completed_transfer_reuse.py +92 -0
  124. diffct_mlx-3.0.0rc1/tests/engine/test_cone_backprojection_transpose.py +189 -0
  125. {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_cone_projector_autograd.py +1 -1
  126. diffct_mlx-3.0.0rc1/tests/engine/test_cuda_exit_deallocations.py +87 -0
  127. diffct_mlx-3.0.0rc1/tests/engine/test_cuda_sink_lifetimes.py +125 -0
  128. {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_cuda_smoke.py +1 -1
  129. diffct_mlx-3.0.0rc1/tests/engine/test_detector_surface_dtypes.py +80 -0
  130. diffct_mlx-3.0.0rc1/tests/engine/test_detector_surface_mapping.py +79 -0
  131. diffct_mlx-3.0.0rc1/tests/engine/test_detector_surface_units.py +62 -0
  132. diffct_mlx-3.0.0rc1/tests/engine/test_detector_surfaces.py +705 -0
  133. diffct_mlx-3.0.0rc1/tests/engine/test_distributed_numeric_failure.py +370 -0
  134. diffct_mlx-3.0.0rc1/tests/engine/test_distributed_numeric_failure_native.py +449 -0
  135. diffct_mlx-3.0.0rc1/tests/engine/test_distributed_training_transforms.py +228 -0
  136. diffct_mlx-3.0.0rc1/tests/engine/test_execution_buffers.py +676 -0
  137. diffct_mlx-3.0.0rc1/tests/engine/test_execution_features.py +618 -0
  138. diffct_mlx-3.0.0rc1/tests/engine/test_execution_schedules.py +584 -0
  139. {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_fbp_fan_accuracy.py +1 -1
  140. {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_fbp_fan_offsets.py +1 -1
  141. {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_fbp_parallel_accuracy.py +1 -1
  142. {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_fdk_cone_accuracy.py +1 -1
  143. {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_fdk_cone_offsets.py +1 -1
  144. diffct_mlx-3.0.0rc1/tests/engine/test_geometry_autograd.py +51 -0
  145. diffct_mlx-3.0.0rc1/tests/engine/test_geometry_conversions.py +176 -0
  146. diffct_mlx-3.0.0rc1/tests/engine/test_geometry_gradients.py +402 -0
  147. diffct_mlx-3.0.0rc1/tests/engine/test_geometry_input_validation.py +393 -0
  148. diffct_mlx-3.0.0rc1/tests/engine/test_gpu_performance_contracts.py +229 -0
  149. {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_gradcheck.py +41 -4
  150. diffct_mlx-3.0.0rc1/tests/engine/test_lazy_native_observers.py +171 -0
  151. diffct_mlx-3.0.0rc1/tests/engine/test_live_trajectory_validation.py +234 -0
  152. diffct_mlx-3.0.0rc1/tests/engine/test_mps_backend.py +431 -0
  153. diffct_mlx-3.0.0rc1/tests/engine/test_multi_gpu_exit.py +87 -0
  154. diffct_mlx-3.0.0rc1/tests/engine/test_multiprocessing.py +78 -0
  155. diffct_mlx-3.0.0rc1/tests/engine/test_native_endpoint_precision.py +182 -0
  156. diffct_mlx-3.0.0rc1/tests/engine/test_native_per_axis_admission.py +99 -0
  157. diffct_mlx-3.0.0rc1/tests/engine/test_native_per_axis_extremes.py +139 -0
  158. diffct_mlx-3.0.0rc1/tests/engine/test_native_per_axis_helical.py +93 -0
  159. diffct_mlx-3.0.0rc1/tests/engine/test_native_per_axis_spacing.py +505 -0
  160. diffct_mlx-3.0.0rc1/tests/engine/test_native_per_axis_spacing_gpu.py +237 -0
  161. diffct_mlx-3.0.0rc1/tests/engine/test_native_stream_cache_threads.py +157 -0
  162. diffct_mlx-3.0.0rc1/tests/engine/test_native_surface_transforms.py +110 -0
  163. diffct_mlx-3.0.0rc1/tests/engine/test_native_volume_layout.py +326 -0
  164. diffct_mlx-3.0.0rc1/tests/engine/test_native_volume_layout_distributed.py +79 -0
  165. diffct_mlx-3.0.0rc1/tests/engine/test_output_pipeline_overlap.py +130 -0
  166. diffct_mlx-3.0.0rc1/tests/engine/test_parallel3d.py +376 -0
  167. diffct_mlx-3.0.0rc1/tests/engine/test_parallel3d_native.py +741 -0
  168. diffct_mlx-3.0.0rc1/tests/engine/test_parallel3d_native_distributed.py +453 -0
  169. diffct_mlx-3.0.0rc1/tests/engine/test_parallel3d_surface_oracle.py +149 -0
  170. diffct_mlx-3.0.0rc1/tests/engine/test_partition_lifecycle.py +197 -0
  171. diffct_mlx-3.0.0rc1/tests/engine/test_plan_memory_bounds.py +252 -0
  172. diffct_mlx-3.0.0rc1/tests/engine/test_portable_accuracy.py +141 -0
  173. diffct_mlx-3.0.0rc1/tests/engine/test_portable_bounded_autograd.py +945 -0
  174. diffct_mlx-3.0.0rc1/tests/engine/test_portable_cuda_budget.py +996 -0
  175. diffct_mlx-3.0.0rc1/tests/engine/test_portable_distributed_geometry.py +206 -0
  176. diffct_mlx-3.0.0rc1/tests/engine/test_portable_endpoint_precision.py +68 -0
  177. diffct_mlx-3.0.0rc1/tests/engine/test_portable_execution_bounds.py +203 -0
  178. diffct_mlx-3.0.0rc1/tests/engine/test_portable_into_default_dtype.py +42 -0
  179. diffct_mlx-3.0.0rc1/tests/engine/test_portable_into_snapshots.py +58 -0
  180. diffct_mlx-3.0.0rc1/tests/engine/test_portable_into_state_edges.py +122 -0
  181. diffct_mlx-3.0.0rc1/tests/engine/test_portable_into_work_plan.py +241 -0
  182. diffct_mlx-3.0.0rc1/tests/engine/test_portable_numeric_regressions.py +185 -0
  183. diffct_mlx-3.0.0rc1/tests/engine/test_portable_sampler_snapshot.py +160 -0
  184. diffct_mlx-3.0.0rc1/tests/engine/test_portable_surface_admission.py +85 -0
  185. diffct_mlx-3.0.0rc1/tests/engine/test_pr42_review_regressions.py +301 -0
  186. diffct_mlx-3.0.0rc1/tests/engine/test_projector_api.py +803 -0
  187. diffct_mlx-3.0.0rc1/tests/engine/test_projector_degenerate_geometry.py +257 -0
  188. diffct_mlx-3.0.0rc1/tests/engine/test_projector_geometry_devices.py +69 -0
  189. diffct_mlx-3.0.0rc1/tests/engine/test_projector_thread_safety.py +263 -0
  190. {diffct_mlx-2.3.0/tests → diffct_mlx-3.0.0rc1/tests/engine}/test_ramp_filter_windows.py +46 -8
  191. diffct_mlx-3.0.0rc1/tests/engine/test_reconstruction_api.py +1048 -0
  192. diffct_mlx-3.0.0rc1/tests/engine/test_reconstruction_work_reuse.py +231 -0
  193. diffct_mlx-3.0.0rc1/tests/engine/test_reference_backend.py +481 -0
  194. diffct_mlx-3.0.0rc1/tests/engine/test_release_2_0_1.py +324 -0
  195. diffct_mlx-3.0.0rc1/tests/engine/test_review_230.py +99 -0
  196. diffct_mlx-3.0.0rc1/tests/engine/test_review_regressions.py +345 -0
  197. diffct_mlx-3.0.0rc1/tests/engine/test_runtime_store_failures.py +258 -0
  198. diffct_mlx-3.0.0rc1/tests/engine/test_solver_admission_regressions.py +273 -0
  199. diffct_mlx-3.0.0rc1/tests/engine/test_solver_api.py +778 -0
  200. diffct_mlx-3.0.0rc1/tests/engine/test_solver_checkpoint_edges.py +364 -0
  201. diffct_mlx-3.0.0rc1/tests/engine/test_solver_collective_failures.py +227 -0
  202. diffct_mlx-3.0.0rc1/tests/engine/test_solver_device_scalars.py +257 -0
  203. diffct_mlx-3.0.0rc1/tests/engine/test_spatial_partition.py +433 -0
  204. diffct_mlx-3.0.0rc1/tests/engine/test_store_runtime_contract.py +197 -0
  205. diffct_mlx-3.0.0rc1/tests/engine/test_surface_collective_failures.py +523 -0
  206. diffct_mlx-3.0.0rc1/tests/engine/test_surface_composition_kernel.py +358 -0
  207. diffct_mlx-3.0.0rc1/tests/engine/test_surface_compute_shards.py +564 -0
  208. diffct_mlx-3.0.0rc1/tests/engine/test_surface_geometry_cudasim.py +607 -0
  209. diffct_mlx-3.0.0rc1/tests/engine/test_surface_gpu_execution.py +221 -0
  210. diffct_mlx-3.0.0rc1/tests/engine/test_surface_gradient_replay.py +226 -0
  211. diffct_mlx-3.0.0rc1/tests/engine/test_surface_host_sampling_budget.py +257 -0
  212. diffct_mlx-3.0.0rc1/tests/engine/test_surface_native_regressions.py +281 -0
  213. diffct_mlx-3.0.0rc1/tests/engine/test_surface_parameter_updates.py +271 -0
  214. diffct_mlx-3.0.0rc1/tests/engine/test_surface_pipeline_contracts.py +413 -0
  215. diffct_mlx-3.0.0rc1/tests/engine/test_surface_saved_snapshot_budget.py +274 -0
  216. diffct_mlx-3.0.0rc1/tests/engine/test_surface_snapshot_admission.py +209 -0
  217. diffct_mlx-3.0.0rc1/tests/engine/test_surface_trajectory_transform.py +142 -0
  218. diffct_mlx-3.0.0rc1/tests/engine/test_training_transforms.py +95 -0
  219. diffct_mlx-3.0.0rc1/tests/engine/test_trajectory_admission_cost.py +257 -0
  220. diffct_mlx-3.0.0rc1/tests/engine/test_trajectory_surface_integration.py +619 -0
  221. diffct_mlx-3.0.0rc1/tests/engine/test_transfer_pipeline.py +646 -0
  222. diffct_mlx-3.0.0rc1/tests/engine/test_transfer_retirement_lifetimes.py +166 -0
  223. diffct_mlx-3.0.0rc1/tests/engine/test_tv_zero_dependency.py +75 -0
  224. diffct_mlx-3.0.0rc1/tests/engine/test_two_far_endpoints.py +84 -0
  225. diffct_mlx-3.0.0rc1/tests/engine/test_weights.py +184 -0
  226. diffct_mlx-3.0.0rc1/tests/test_backend_parity.py +139 -0
  227. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_conventions.py +11 -8
  228. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_footprint_amplitude.py +6 -3
  229. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_known_operator_gradflow.py +1 -1
  230. diffct_mlx-3.0.0rc1/tests/test_metal_kernel_static.py +44 -0
  231. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_regressions.py +1 -1
  232. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_siddon_centering.py +4 -4
  233. diffct_mlx-3.0.0rc1/tests/test_upstream_kernel_fixes.py +394 -0
  234. diffct_mlx-2.3.0/diffct/analytical.py +0 -521
  235. diffct_mlx-2.3.0/diffct/differentiable.py +0 -74
  236. diffct_mlx-2.3.0/diffct/kernels/__init__.py +0 -37
  237. diffct_mlx-2.3.0/diffct/kernels/cone_beam.py +0 -819
  238. diffct_mlx-2.3.0/diffct/projectors.py +0 -1124
  239. diffct_mlx-2.3.0/diffct_mlx/conventions.py +0 -83
  240. diffct_mlx-2.3.0/tests/test_metal_kernel_static.py +0 -34
  241. diffct_mlx-2.3.0/tests/test_weights.py +0 -126
  242. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/.github/workflows/docs.yml +0 -0
  243. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/.github/workflows/publish.yml +0 -0
  244. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/.gitignore +0 -0
  245. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/LICENSE +0 -0
  246. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/analytical.py +0 -0
  247. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/__init__.py +0 -0
  248. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/_mlx.py +0 -0
  249. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/__init__.py +0 -0
  250. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/constants.py +0 -0
  251. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/kernels/__init__.py +0 -0
  252. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/backend/metal/utils.py +0 -0
  253. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/calibration.py +0 -0
  254. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/filters.py +0 -0
  255. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/functionals.py +0 -0
  256. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/geometry.py +0 -0
  257. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/orchestration/__init__.py +0 -0
  258. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/phantoms/__init__.py +0 -0
  259. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/phantoms/engine.py +0 -0
  260. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/phantoms/shepp_logan.py +0 -0
  261. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/physics/__init__.py +0 -0
  262. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/physics/corrections.py +0 -0
  263. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/physics/data/spectra.npz +0 -0
  264. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/physics/pipeline.py +0 -0
  265. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/physics/spectra.py +0 -0
  266. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/projectors.py +0 -0
  267. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/real_measured_data_helper.py +0 -0
  268. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/__init__.py +0 -0
  269. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/_core.py +0 -0
  270. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/_solver.py +0 -0
  271. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/asd_pocs.py +0 -0
  272. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/awtv_pocs.py +0 -0
  273. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/dart.py +0 -0
  274. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/fbp.py +0 -0
  275. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/fdk.py +0 -0
  276. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/sart.py +0 -0
  277. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/sirt.py +0 -0
  278. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/solvers.py +0 -0
  279. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/reconstruction_algorithms/tv_pocs.py +0 -0
  280. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/regularizers.py +0 -0
  281. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/diffct_mlx/tv_gradients.py +0 -0
  282. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/Makefile +0 -0
  283. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/_static/.gitkeep +0 -0
  284. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/api.rst +0 -0
  285. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/examples.rst +0 -0
  286. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/fbp_fan_example.rst +0 -0
  287. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/fbp_parallel_example.rst +0 -0
  288. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/fdk_cone_example.rst +0 -0
  289. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/getting_started.rst +0 -0
  290. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/index.rst +0 -0
  291. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/iterative_reco_cone_example.rst +0 -0
  292. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/iterative_reco_fan_example.rst +0 -0
  293. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/docs/source/iterative_reco_parallel_example.rst +0 -0
  294. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/pytest.ini +0 -0
  295. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/requirements.txt +0 -0
  296. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/__init__.py +0 -0
  297. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/_phantoms.py +0 -0
  298. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/benchmarks/README.md +0 -0
  299. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/benchmarks/__init__.py +0 -0
  300. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/benchmarks/_common.py +0 -0
  301. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_diffct_mlx_extensions.py +0 -0
  302. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tests/test_quantitative_fdk.py +0 -0
  303. {diffct_mlx-2.3.0 → diffct_mlx-3.0.0rc1}/tools/generate_spectra.py +0 -0
@@ -17,4 +17,5 @@ jobs:
17
17
  - name: Create Release
18
18
  uses: softprops/action-gh-release@v2
19
19
  with:
20
- generate_release_notes: true
20
+ generate_release_notes: true
21
+ prerelease: ${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'a') || contains(github.ref_name, 'b') }}
@@ -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 `dev` branch (arbitrary-trajectory line), v1.3.3.dev0, commit `cb516cf` |
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/v2.3.0...HEAD
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: 2.3.0
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.9
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 handled per source (measured −log data are physical; raw Siddon
144
- projector output is voxel-unit and rescaled by `voxel_spacing`). The ramp
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
- > **Unit convention.** The projectors integrate in **voxel units**: physical
149
- > line integrals are `(A @ x) * voxel_spacing`. This holds for both projector
150
- > modes: since 2.2.0 the footprint kernels are mass-conserving and agree with
151
- > the Siddon kernels in amplitude (earlier versions scaled footprint output
152
- > with the detector-cell-to-voxel size ratio). Operators built via
153
- > `make_*_operator` carry `A.voxel_spacing` as metadata, and the boundaries
154
- > where physical units matter handle the conversion automatically —
155
- > `simulate_scan` rescales before the `exp(-p)` / beam-hardening physics (and
156
- > returns physical, scanner-like sinograms), and the quantitative FDK path
157
- > encodes it per data source. One consequence to know: **iterative**
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 handled per source (measured −log data are physical; raw Siddon
118
- projector output is voxel-unit and rescaled by `voxel_spacing`). The ramp
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
- > **Unit convention.** The projectors integrate in **voxel units**: physical
123
- > line integrals are `(A @ x) * voxel_spacing`. This holds for both projector
124
- > modes: since 2.2.0 the footprint kernels are mass-conserving and agree with
125
- > the Siddon kernels in amplitude (earlier versions scaled footprint output
126
- > with the detector-cell-to-voxel size ratio). Operators built via
127
- > `make_*_operator` carry `A.voxel_spacing` as metadata, and the boundaries
128
- > where physical units matter handle the conversion automatically —
129
- > `simulate_scan` rescales before the `exp(-p)` / beam-hardening physics (and
130
- > returns physical, scanner-like sinograms), and the quantitative FDK path
131
- > encodes it per data source. One consequence to know: **iterative**
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
 
@@ -202,7 +202,7 @@ from .tv_gradients import (
202
202
  awtv_gradient,
203
203
  )
204
204
 
205
- __version__ = "2.3.0"
205
+ __version__ = "3.0.0rc1"
206
206
 
207
207
  __all__ = [
208
208
  "backend",
@@ -1,18 +1,25 @@
1
1
  """Torch / CUDA backend.
2
2
 
3
- Thin adapter over the upstream ``diffct`` (dev-line) package: it re-exports the
4
- numba-CUDA autograd projectors as plain functional operators with the unified
5
- signatures, exposes the ``geometry`` and ``analytical`` submodules, and provides
6
- :data:`xp` — an MLX-``core``-shaped array namespace implemented on top of torch
7
- so the higher-level reconstruction layer is written once for both backends.
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 diffct import (
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 diffct import geometry, analytical # noqa: F401 (re-exported)
24
- from diffct.footprint import (
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))