Repository navigation
glm cuda: the sampled rule from cuda.sample.rule, in place of its hand-built copy (#2460 item 3, step 3b) - #3705
Merged
Merged
Conversation
Owner
|
Thanks @jschmied. LAND. The shared rule preserves the 32-byte CUDA payload and the existing temperature gate. The old-rule byte comparison covers the field grid and both call sites keep the same draw path. No kernel or sampling behavior changes in this refactor.
|
This was referenced Nov 19, 2026
…d-built copy GLM's CUDA sampler redeclared sample.cu's Rule and filled it by hand (near 20.0 literal), as MiniMax M3 did before ashhart#2680. It now takes cuda.sample.Rule and cuda.sample.rule, which reach the core rule through lanes.Sampling.gpuRule. Byte-equal: a host test checks the old hand-built rule against rule and ruleFor over a 4,500-setting grid; the greedy gate (check) is ruleFor's.
ashhart
force-pushed
the
sampler3b-glm
branch
from
November 19, 2026 22:49
6e8cf3e to
7716fe8
Compare
Owner
|
Thank you @jschmied. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
ashhart
added a commit
to BadAd84/TensorFold
that referenced
this pull request
Nov 19, 2026
ashhart
added a commit
that referenced
this pull request
Nov 19, 2026
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
Step 3b of #2460 item 3 (one sampler in
core/lanes), the GLM part of #2680. #2680 left GLM alone while #1571 wasopen; #1571 merged on 11-14. GLM's CUDA sampler redeclared sample.cu's
Ruleand filled it by hand, with anear = 20.0literal. That is the form MiniMax M3 had before #2680. It now does what MiniMax does:glm/cuda_sampler.zig:Rule=cuda.sample.Rule, andrule(s)=cuda.sample.rule(s). Both reach the core rule(
lanes.gpu_rule.rule) throughSampling.gpuRule. The names and signatures are unchanged, so the callers stay asthey are:
cuda_engine.zig:549(drawn rows) andcuda_structured.zig:18(masked rows).checkis kept. It isruleFor'sT > 0gate, and the test checks that.Every GLM CUDA rule site on main 9489c38 is in that file.
cuda_follow.zigcarries the request's settings to theother ranks, which then call
begin->check. It builds no rule. Metal'sglm/draw_rule.ziganddraw_dispatch.zigkeep their own 36-byte ABI, are already onlanes.gpu_rule, and #3402 has them open.Core vs family-only: nothing new in core or in the shared CUDA code.
cuda.sample.rule/ruleForcome from #2680.The family keeps only the call, the upload and
check.their PRs.
glm/cuda_sampler.zig. cuda: TF_CUDA_HOST_WFE, opt-in WFET waits for the RoCE proxy and GLM token readbacks #2922 changes lines 38, 59 and 88 (the host waiter).GLM-5.3-Flash CUDA: shared rounds draft MTP for every stream at once #2856 changes lines 47 and 105 (
launchMany, which usessampler.Ruleandsampler.rule(s); both are kept withthe same size and signature). Neither touches lines 17-23. No other file changes.
Checks on this head
GLM sampler rule: the hand-built rule it replaced, byte for byte; check is ruleFor's gate(inglm/cuda_sampler.zig, run bytest-cuda-host). Itchecks 4,500 settings: 4 seeds x 9 temperatures (-1, 0, 1e-9, 1e-6, 0.5, 0.7, 1, 2, inf) x 5 top_k (0, 1, 20, 1024,
1025) x 5 top_p x 5 min_p. For each one:
rule(s)==ruleFor(s), byte for byte;check(s)is null exactly whenruleFor(s)is null;ruleFor(null)is null.That is 3,500 sampled and 1,000 greedy settings, so greedy and seeded top-k/top-p/min-p/temperature are all covered.
cuda: one sampled rule, cuda.sample.ruleFor, in place of the family copies (#2460 item 3, step 3) #2680's 25,480-setting grid in
nemotron/cuda_sampler.zigstill holds the GLM/MiniMax hand form as its oracle.committed. Each plant went red at runtime, not as a compile error:
rule: near 20.5, seed ^ 1, pad 1;check:>= 0;ruleFor:>= 0;Rule.from: top_p and min_log swapped;gpu_rule: T floor 1e-5, near 21, top_k + 1.9 of 9 were red; the clean copy was green (8/8 tests).
through sample.cu, as before. It declares no
.penalties, so nonzero presence/frequency penalties are still refusedby name before anything is queued ("presence_penalty and frequency_penalty are not supported by backend ...",
penalty request: unsupported nonzero fields refuse before engine submission).zig build native -Dsm=121was run for this head and main at the same path. The 115 embeddedfatbins are identical, every md5 equal. The
tensorfold-nativemd5 differs (head 5261543b, main faf9691a): the hostcode changed shape. No
.cufile changed.-Dnvcc):zig build test-cuda-host414/414 steps, 7007 passed, 33 skipped. Plainzig buildis green.python3 tools/pr_check.py --base mainreports 0 errors. Lean checker: 221 on the base and221 on this head, 0 new.
zig fmt --check build.zig zigandgit diff --checkare clean. Every file stays under600 lines, and every added comment is one line of 120 columns or less.
zig build -Dfixed-cpu test test-golden test-kernel-contract test-server-security test-pull-security fuzz-cortheon check-release-paths: 756/759 steps, 10178/10257 tests passed (78 skipped). The onefailure is
cli_config_test(serve --config: expand reads the file...), and it fails the same way on main on thatbox (umask 002). This PR touches no server code.
zig build check-native-cuda-host compile-cuda-tests: 16/16.pr_check,zig fmt --checkandgit diff --checkare clean there too.here (one GB10). So there is no served A/B against main: no greedy/seeded replies, no resume, no concurrency 1/4.
Tokens equal main by the byte-equal rule above, and no kernel changed. Nothing ran on macOS: no Metal file changed.
Proposed CHANGELOG line (for the maintainer to place; not committed):
cuda.sample.rule; its hand-built copy is gone, same tokens(RFC: families compose core blocks: a conformance kit first, then sampler, config, drafter and format loaders #2460 item 3).