Repository navigation
lanes: the GPU sampling rule once (gpu_rule.Rule): Metal's cfg and CUDA's Rule filled from it - #731
Merged
Merged
Conversation
…tal's cfg and seed halves and sample.cu's Rule filled from it, the host references read it, the CUDA test drops its copy; host tests pin both layouts
jschmied
pushed a commit
to jschmied/TensorFold
that referenced
this pull request
Oct 13, 2026
jschmied
pushed a commit
to jschmied/TensorFold
that referenced
this pull request
Oct 13, 2026
…when the CUDA server uses its own kernels --kernels native is the CUDA CLI's flag; the server runs its own kernels whenever it has no captured Triton set.
Owner
|
Thank you, @jschmied. One rule built in one place is the right shape for this, and it landed in 1.0.9 as you wrote it: your commit is You asked for the receipt you couldn't take, so here it is, with Nemotron 3.5 Lightning MLX 4-bit served before and after your change on the same machines.
Nothing changed on our side. #524's GLM sampler is the next place this rule should feed, once it moves onto the shared sampler. |
Closed
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
The contributor's commit landed above, rebased onto the commits after 1.0.8; this keeps the PR's head in the history with no change to the tree.
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
…when the CUDA server uses its own kernels --kernels native is the CUDA CLI's flag; the server runs its own kernels whenever it has no captured Triton set.
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
The follow-up to #654 you agreed to: the GPU sampling rule (1 / T, top_p, the near window of 20, ln(min_p), top_k and the seed) is built once, in
core/lanes/gpu_rule.zig, next to the host reference it already matches.gpu_rule.Ruleandrule(Sampling)hold the values.cfg()andseedHalves()give Metal's four floats and two seed halves, andsample.Rule.from()gives CUDA's struct.What now reads it:
Forward.sampleinfamilies/nemotron/forward.zig, andtests/nemotron_sample_check.zig.families/nemotron/cuda_sampler.zig.cuda/sample.zigloses itsrule().gpu_rule.sampleandgpu_full.plan, the host references.tests/cuda/sample_tests.zig, which loses its copy of the struct.The kernels and their arguments are unchanged; the values are the same expressions, so the bits are too. Host tests pin both layouts: Metal's cfg row and seed halves in
gpu_rule, andsample.Rule's size and field offsets incuda/sample.zig.#524's
glm/draw_rule.zigbuilds the same values again for GLM on Metal; it could fill fromgpu_rule.ruleonce both land.Receipt
0efbd447(1.0.8) plus this commit. CUDA: one DGX Spark (GB10, sm_121, driver 580.173.02, CUDA 13),TensorFold/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit, built-in kernels. Metal: an M3 Pro, Zig 0.17.0, Xcode 27.0.tf-cuda-test sample: 2,880 draws equal the host references.--parallel 1, base (0efbd447) against this branch: 2 prompts x (greedy, and 5 settings x 4 seeds: temperature 0.6 to 1.2, top_p 0.8 to 1.0, top_k 0, 5, 20, 50, min_p 0.05), drafted and"draft": false. All 84 replies equal; greedy logprob rows byte-equal (4 of 4); drafted == plain 42 of 42 in both builds. 39 of 40 seeded sampled replies differed from each other, so the draws were live.tf-nemotron-sample-checkon base and branch, "all draws match": 8 cases (flat, peaked, past 1,024 candidates, tied levels, top_k 3000, top_k with top_p, min_p, a draft vocabulary through an id map), 16 of 16 rows each.zig build test44/44 steps on Linux; on the M3 Pro 154/156 steps, as on base. The one failing step is the same on base:core.checkpoint_metal"a split checkpoint keeps later tensors in the file..." logscheckpoint tensor text.weight stays in its file: read it through a Stage. New tests: "the rule once: its values, and the Metal cfg row and seed halves it packs", "sample.cu's Rule layout", "a rule in the kernels' layout keeps every field". Swapping two ofcfg()'s values fails 4 checks.lean_check.py: 539 findings, as onmain.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.