Repository navigation
Conversation
--device N (TF_CUDA_DEVICE) makes device N the current CUDA device before an engine loads, in every CUDA engine, and the unified-memory check reads the current device. Two ranks on one machine can then both see both GPUs and each run on its own, so their transfers can map the peer GPU. Without the flag nothing changes: device 0.
This was referenced Oct 4, 2026
Closed
8 tasks done
ashhart
added a commit
that referenced
this pull request
Oct 6, 2026
The CUDA CLI opened its context on device 0 no matter what, so two ranks on one machine could not each run on their own GPU while still seeing both, which a peer-mapped transfer between them needs. --device N in the option loop, or TF_CUDA_DEVICE in the environment, now selects the ordinal cuda.Context.init gets before an engine loads; nothing set still means device 0, and no kernel or engine arithmetic changes. The resolution lives in deviceOrdinal, covered by a new host test (the flag wins, then the environment, else 0), and the CLI's tests join zig build test through the CUDA host tests. PR #354's own receipt showed the same token_sha with and without the flag. Co-authored-by: gilby <[email protected]>
Owner
|
Thank you, @gilby. The Python engine is frozen (#286), so this won't land there, but Zig CUDA's command-line tools have the same gap. They open device 0 every time, though the context call already takes an ordinal. We'll carry |
Closed
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
The CUDA CLI opened its context on device 0 no matter what, so two ranks on one machine could not each run on their own GPU while still seeing both, which a peer-mapped transfer between them needs. --device N in the option loop, or TF_CUDA_DEVICE in the environment, now selects the ordinal cuda.Context.init gets before an engine loads; nothing set still means device 0, and no kernel or engine arithmetic changes. The resolution lives in deviceOrdinal, covered by a new host test (the flag wins, then the environment, else 0), and the CLI's tests join zig build test through the CUDA host tests. PR ashhart#354's own receipt showed the same token_sha with and without the flag. Co-authored-by: gilby <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
--device N(orTF_CUDA_DEVICE=N) makes GPU N the current CUDA device before an engine loads, in every CUDA engine(27B, Qwen3.6 MoE, Flash Next, GLM-5.3, Nemotron), and the unified-memory check reads the current device instead of
device 0. Two ranks on one machine can then both see both GPUs and each run on its own, which a peer-mapped transfer
between them needs (
CUDA_VISIBLE_DEVICEShides the peer). Without the flag nothing changes: device 0.Receipt
PyTorch 2.13.0a0 (NGC 26.07 container, CUDA 13.3),
Vontra/Qwen3.6-35B-A3B-MLX-4bit-MTP@ f84b054, its own MTP drafter;tensorfold serve <checkpoint> --backend cuda --parallel 1 --device 0, measured on this change at 0.6.4 (branch now on0.6.5 (609ca41) as 00f4fca; one conflict, in Nemotron's CUDA engine: 0.6.5's new MTP depth and confidence checks are
kept and its
torch.cuda.set_device(0)becomes this PR's device select)tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: not affected(no kernel or engine arithmetic changes). With
--device 0the server starts and one request sent twice, thesecond with
"draft": false, givestoken_shad594be69c0dd both times, the same sha as plain 0.6.4 on this checkpoint. Resumed == fresh, on v0.6.5 (one DGX Spark): the same 2,640-token prompt three times on one server at temperature 0: fresh, resumed (2,635 tokens from the prompt cache) and resumed with"draft": false, alltoken_sha968cfc11c98b.tools/bench_openai.py: not affected; not run.tools/prefill_cold.py: not affected; see the v0.6.5 check below.test_glm5_prompt_kernels::test_fused_index_scores_are_the_three_ops, fails on v0.6.5 too. CUDA on v0.6.5 (one DGX Spark, GB10):pytest tests/cuda tests/test_cuda_build.py -k "qwen27 or qwen36 or nvfp4 or b16 or qmm or moe or build or distributed or dflash or dspark or exl3 or graph": 679 passed, 0 failed, 81 skipped.test_glm5_prompt_kernels::test_fused_index_scores_are_the_three_ops, fails on 0.6.4 too). Newtests/test_cuda_device.py(3 tests, noGPU needed) fails to collect on 0.6.4 (
tensorfold.cuda.deviceabsent) and passes here.tools/prefill_cold.py(2k / 8k / 16k, 3 reps, median tok/s; runs v0.6.5, this, this, v0.6.5, each side the mean of its two) onRadixArk/Qwen3.8-27B-NVFP4-BF16-LMHead+z-lab/Qwen3.8-27B-DFlash2at--context 131072 --parallel 1, a checkpoint v0.6.5 serves: v0.6.5 → this 2,595 → 2,604 / 2,846 → 2,839 / 2,728 → 2,725.Vontra/Qwen3.6-35B-A3B-MLX-4bit-MTPwith--device 0 --parallel 4:tools/bench_concurrent.py --levels 2,4 --alone --serial(code and chat, temperature 1.0 and 0): 0 failed, alone 72/72 and serial 20/20 equal, 0 unequal in all 8 cells.--device 0/--device 1): our two-GPU machine was busywith other work during this pass; we ran it there earlier on 0.6.2 with perf(cuda): two-rank NVFP4 layers shard as they load; row-parallel sums over a peer mapping #356's P2P sum (two NVLinked A40s).
Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.