Skip to content

fix: widen the hub's public stream parameter to intptr_t + bump cpu/cuda pins - #50

Merged
balbasty merged 2 commits into
mainfrom
claude/4-cuda-stream-intptr_t
Aug 2, 2026
Merged

fix: widen the hub's public stream parameter to intptr_t + bump cpu/cuda pins#50
balbasty merged 2 commits into
mainfrom
claude/4-cuda-stream-intptr_t

Conversation

@balbasty

@balbastybalbasty commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

Part of #4. Repo 4 of 5; depends on fastfields/fastfields-cpu-lib#61 and fastfields/fastfields-cuda-lib#35.

What changed

Width.ff::dt_euclidean and friends are the device-dispatch boundary: they inspect the DLTensor's device.device_type and forward the samestream argument to either FF_CPU:: or FF_CUDA:::

if (is_cuda) returnFF_CUDA::dt_euclidean(inp_out, voxel_spacing, stream);
elsereturnFF_CPU::dt_euclidean(inp_out, voxel_spacing, stream);

Both branches must share one signature, so this hub was int everywhere the two lower layers were int. 114 parameter declarations across the 8 modules (distance, posdef, pushpull, reg_field, reg_flow, resize, restrict, splinc) are now intptr_t, matching the now-widened cpu/cuda dispatch layers. Signature-only — verified with the same non-signature-line grep used in the other PRs in this series (empty diff outside stream / #include <cstdint> lines).

Submodule pins.cpud969e2d (fastfields/fastfields-cpu-lib#61), cuda33aa9b3 (fastfields/fastfields-cuda-lib#35).

How this was verified

Really run:make all CXX=clang++ — a full, real build of this repo against the bumped pins: it recursively builds libfastfields-cpu.so (via make -C cpu install), compiles all 8 hub object files, and links libfastfields.so against it. Exit 0, artifact produced (build/libfastfields.so, 55 KB; build/lib/libfastfields-cpu.so, 163 MB).

This exercises the CPU path end to end. The CUDA path is not linked by the default all target (needs USE_CUDA=1 + nvcc); CUDA compile+link verification lives at the fastfields-cuda-lib layer (PR #35), which is where the CUDA object files are actually produced.

PR series

  1. fix: widen the CUDA stream parameter to intptr_t and forward it in the distance launchers fastfields-cuda-impl#25
  2. fix: widen the CUDA stream parameter to intptr_t and forward it for the distance ops fastfields-cuda-lib#35
  3. fix: widen the public stream parameter to intptr_t fastfields-cpu-lib#61
  4. fastfields-lib — this PR
  5. fix: widen the CUDA stream parameter to intptr_t at the nanobind boundary fastfields-dlpack#22

Workstream: claude-jitfields-to-fastfields

🤖 Generated with Claude Code

…uda pins
A `cudaStream_t` is a pointer and therefore 64-bit, but every public
`stream` parameter in the hub's device-dispatch functions was declared
`int`. `ff::dt_euclidean` and friends inspect the DLTensor's device and
forward the same argument to either `FF_CPU::` or `FF_CUDA::`:
if (is_cuda) return FF_CUDA::dt_euclidean(inp_out, voxel_spacing, stream);
else return FF_CPU::dt_euclidean(inp_out, voxel_spacing, stream);
so both backends must agree on the parameter's type. Widens 114 parameter
declarations across the 8 modules to `intptr_t`, matching the now-widened
cpu/cuda dispatch layers. This is a signature-only change (verified with the
same non-signature-line grep used in the cpu-lib/cuda-lib PRs: empty).
Bumps `cpu` -> d969e2d (fastfields-cpu-lib#61) and `cuda` -> 33aa9b3
(fastfields-cuda-lib#35).
Verified with `make all CXX=clang++`: the full hub (cpu library + hub object
files + link) builds successfully end to end against the bumped pins,
producing libfastfields.so linked against libfastfields-cpu.so. This is a
real, complete build of the CPU path; the CUDA path is not linked by this
target (CUDA needs `USE_CUDA=1` and nvcc, exercised at the cuda-lib layer
instead).
Refs #4
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016AjQcY78NgbagPSbPJRr6Z
@balbasty
balbasty merged commit 1331528 into mainAug 2, 2026
2 of 3 checks passed
@balbasty
balbasty deleted the claude/4-cuda-stream-intptr_t branch August 2, 2026 09:15
@balbastyClaude

Copy link
Copy Markdown
CollaboratorAuthor

Review summary (triage, jitfields-to-fastfields): merged as squash.

114 hub-level stream params widened intintptr_t (the device-dispatch boundary that must share one signature across the CPU/CUDA branches), plus cpu/cuda submodule pins bumped to the merged cpu-lib#61/cuda-lib#35. Refreshed against current main before merging (picks up lib#51's clang-format fix and, transitively, the cpu-lib#62 RLS fix via the already-merged pin). build job (real make all — recursively builds cpu-lib, links libfastfields.so) genuinely green, ~23 min. clang-format failure is expected/non-blocking.

Workstream: claude-jitfields-to-fastfields


Generated by Claude Code

balbasty added a commit to fastfields/fastfields-dlpack that referenced this pull request Aug 2, 2026
…dary (#22)
* fix: widen the CUDA stream parameter to intptr_t at the nanobind boundary
Closes#4.
A `cudaStream_t` is a pointer and therefore 64-bit, but every `stream`
parameter accepted at this boundary was declared plain `int` in the
nanobind lambda signatures. A real stream handle from a caller (e.g. a
torch/cupy stream pointer forwarded as an integer) whose upper 32 bits are
non-zero is silently truncated before it ever reaches the C++ library --
the last and most externally visible link in the truncation chain fixed
by this issue across all five repos. Widens all 45 `stream` parameters in
`src/ext.cpp` to `intptr_t`.
Bumps the `_fastfields_lib` submodule pin to fastfields-lib's
16f3eb7 (fastfields/fastfields-lib#50), which carries the matching widening
through the hub and both device-dispatch layers
(fastfields/fastfields-cpu-lib#61, fastfields/fastfields-cuda-lib#35) down
to the CUDA launchers themselves (fastfields/fastfields-cuda-impl#25).
Verified end to end on this machine (CPU path; no GPU available):
- `pip install --no-build-isolation .` succeeds: builds `_core.so` via
nanobind against the bumped `_fastfields_lib`, links `-lfastfields`,
and installs the wheel.
- `import fastfields.dlpack._core` succeeds and exposes the expected
entry points (dt_euclidean, dt_l1, dt_mesh, field_matvec, ...).
- Regression check for the actual bug: calling `dt_euclidean(x, 1.0,
1 << 40)` -- a stream value with bits set above the 32-bit range --
completes without truncation or OverflowError, which a plain `int`
parameter could not guarantee.
- `pytest tests/`: 36 passed, 0 failed.
Refs fastfields/fastfields-lib#4
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016AjQcY78NgbagPSbPJRr6Z
* fix: bump _fastfields_lib pin past the RLS broadcast-stride fix
fastfields-cpu-lib#62 (field_matvec_rls's RLS/shared-weight broadcast
path reading the wrong stride, corrupting output for wc=1, C>1) has
now been fixed and threaded all the way up through cpu-impl#48,
cuda-impl#27, cpu-lib#64, cuda-lib#38, and fastfields-lib#55. This
repo's _fastfields_lib pin (16f3eb7) predated fastfields-lib#55, so
the fix was not reachable through this PR's pin -- the extension
built here would still have linked against the broken
field_matvec_rls.
Bumps _fastfields_lib -> fd9e6c5 (fastfields-lib main HEAD, which now
carries cpu -> 4d46a02 and cuda -> e96440c, both past the fix).
Verified for real:
CXX=clang++ pip install --no-build-isolation .
cd /tmp && python -m pytest <repo>/tests -q
Install succeeds end to end (builds libfastfields.so/-cpu.so via the
bumped _fastfields_lib's Makefile, links the nanobind extension,
packages and installs the wheel). pytest: 36 passed, 0 failed. Also
re-ran the stream-widening regression check this PR introduced
(stream = 2**40 via dt_euclidean) against the freshly built
extension: still passes.
part of fastfields-cpu-lib#62
Co-authored-by: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@balbasty@claude