[FIX] Add NUMBA backend; correctly handle symmetric/nonsymmetric spheres#41
[FIX] Add NUMBA backend; correctly handle symmetric/nonsymmetric spheres#41
Conversation
|
@copilot can you translate these changes to webgpu and metal? |
There was a problem hiding this comment.
Pull request overview
This PR fixes GPU-accelerated tractography behavior for asymmetric ODFs by making “antipodal symmetry” (using abs(dot)) conditional, so full-basis spherical harmonics can preserve directionality.
Changes:
- Added a
full_basisoption toGPUTrackerand propagated it into NVRTC compile-time macros. - Introduced
APPLY_ABS_IF_SYM()in CUDA headers to toggle absolute-value behavior based onFULL_BASIS. - Updated CUDA direction similarity checks to use the new conditional macro.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
cuslines/cuda_python/cu_tractography.py |
Adds full_basis parameter to GPUTracker and stores it for compilation. |
cuslines/cuda_python/cu_direction_getters.py |
Passes FULL_BASIS macro into runtime CUDA compilation. |
cuslines/cuda_c/globals.h |
Defines APPLY_ABS_IF_SYM() based on FULL_BASIS. |
cuslines/cuda_c/tracking_helpers.cu |
Uses conditional abs in peak de-duplication similarity check. |
cuslines/cuda_c/generate_streamlines_cuda.cu |
Uses conditional abs in direction filtering against MAX_ANGLE. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agent-Logs-Url: https://github.com/dipy/GPUStreamlines/sessions/1dd77c24-0cb1-4313-8b51-5ce9068fb347 Co-authored-by: 36000 <[email protected]>
Done in commit f245353. Here's what was translated to each backend: Metal (
WebGPU (
|
|
@neurolabusc this update may be of interest ot you. it fixes a bug with probabilistic tractography using asymmetric ODFs. I had copilot also implement the changes in the webgpu and metal versions |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 9 comments.
Comments suppressed due to low confidence (1)
pyproject.toml:48
- Adding
numbaas a required dependency conflicts withrequires-python = ">=3.7"(Numba has not supported Python 3.7 for several releases) and with the runtime messaging that suggests acuslines[numba]extra. Either (1) bumprequires-pythonto a Numba-supported version, or (2) movenumbainto[project.optional-dependencies]as anumbaextra and keep the core install Python-3.7-compatible.
requires-python = ">=3.7"
dependencies = [
"numpy",
"numba",
"nibabel",
"tqdm",
"dipy",
"trx-python",
"scipy",
]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 24 out of 24 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (2)
run_gpu_streamlines.py:439
- The PR introduces a
full_basispath, butrun_gpu_streamlines.pydoesn’t expose any way to enable it and also doesn’t passfull_basisintoTracker(...). As a result, the new asymmetric-ODF behavior is effectively unreachable from this script. Consider adding a--full-basisCLI flag (and wiring it into both the DIPY SH/ODF construction and theTracker(full_basis=...)argument) so users can actually run the intended mode end-to-end.
with Tracker(
dg,
data,
FA,
args.fa_threshold,
sphere.vertices,
sphere.edges,
max_angle=args.max_angle * np.pi / 180,
step_size=args.step_size,
relative_peak_thresh=args.relative_peak_threshold,
min_separation_angle=args.min_separation_angle * np.pi / 180,
ngpus=args.ngpus,
rng_seed=0,
chunk_size=args.chunk_size,
) as gpu_tracker:
cuslines/init.py:88
- Top-level
cuslinesnow exportsTrackerbut no longer exports the historicalGPUTrackername. This is a breaking public API change for any downstream code doingfrom cuslines import GPUTracker. Consider keeping a backwards-compatible alias (e.g.,GPUTracker = Tracker) and including it in__all__while still preferringTrackergoing forward.
__all__ = [
"Tracker",
"ProbDirectionGetter",
"PttDirectionGetter",
"BootDirectionGetter",
"BACKEND",
]
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This fixes a bug and actually allows GPU accelerated tractography to take advantage of asymmetric ODFs.