Skip to content

glm cuda: the sampled rule from cuda.sample.rule, in place of its hand-built copy (#2460 item 3, step 3b) - #3705

Merged
ashhart merged 2 commits into
ashhart:mainfrom
jschmied:sampler3b-glm
Nov 19, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
jschmied:sampler3b-glm

Conversation

@jschmied

Copy link
Copy Markdown
Contributor

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 was
open; #1571 merged on 11-14. GLM's CUDA sampler redeclared sample.cu's Rule and filled it by hand, with a
near = 20.0 literal. That is the form MiniMax M3 had before #2680. It now does what MiniMax does:

  • glm/cuda_sampler.zig: Rule = cuda.sample.Rule, and rule(s) = cuda.sample.rule(s). Both reach the core rule
    (lanes.gpu_rule.rule) through Sampling.gpuRule. The names and signatures are unchanged, so the callers stay as
    they are: cuda_engine.zig:549 (drawn rows) and cuda_structured.zig:18 (masked rows). check is kept. It is
    ruleFor's T > 0 gate, and the test checks that.

Every GLM CUDA rule site on main 9489c38 is in that file. cuda_follow.zig carries the request's settings to the
other ranks, which then call begin -> check. It builds no rule. Metal's glm/draw_rule.zig and
draw_dispatch.zig keep their own 36-byte ABI, are already on lanes.gpu_rule, and #3402 has them open.

Core vs family-only: nothing new in core or in the shared CUDA code. cuda.sample.rule/ruleFor come from #2680.
The family keeps only the call, the upload and check.

Checks on this head

  • Head commit: 6e8cf3e (1 file, +28 -4).
  • Tokens equal to main by construction: the rule bytes are identical. New host test GLM sampler rule: the hand-built rule it replaced, byte for byte; check is ruleFor's gate (in glm/cuda_sampler.zig, run by test-cuda-host). It
    checks 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:
  • Planted control, red first: 9 faults planted in a scratch copy. The test ran under a scratch filtered step, never
    committed. Each plant went red at runtime, not as a compile error:
    • GLM rule: near 20.5, seed ^ 1, pad 1;
    • GLM check: >= 0;
    • ruleFor: >= 0;
    • Rule.from: top_p and min_log swapped;
    • core gpu_rule: T floor 1e-5, near 21, top_k + 1.
      9 of 9 were red; the clean copy was green (8/8 tests).
  • Refusals: this change adds none and changes none. GLM CUDA serves every field of the rule (T, top_p, top_k, min_p)
    through sample.cu, as before. It declares no .penalties, so nonzero presence/frequency penalties are still refused
    by name before anything is queued ("presence_penalty and frequency_penalty are not supported by backend ...",
    penalty request: unsupported nonzero fields refuse before engine submission).
  • Kernels untouched: zig build native -Dsm=121 was run for this head and main at the same path. The 115 embedded
    fatbins are identical, every md5 equal. The tensorfold-native md5 differs (head 5261543b, main faf9691a): the host
    code changed shape. No .cu file changed.
  • Tests (aarch64 GB10, -Dnvcc): zig build test-cuda-host 414/414 steps, 7007 passed, 33 skipped. Plain
    zig build is green. python3 tools/pr_check.py --base main reports 0 errors. Lean checker: 221 on the base and
    221 on this head, 0 new. zig fmt --check build.zig zig and git diff --check are clean. Every file stays under
    600 lines, and every added comment is one line of 120 columns or less.
  • x86_64 (8 cores, no GPU): 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 one
    failure is cli_config_test (serve --config: expand reads the file...), and it fails the same way on main on that
    box (umask 002). This PR touches no server code. zig build check-native-cuda-host compile-cuda-tests: 16/16.
    pr_check, zig fmt --check and git diff --check are clean there too.
  • CI: not yet run (no PR open).
  • Not run, and why: GLM served on CUDA. There is no GLM checkpoint on this box, and GLM CUDA TP=2 is not available
    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):

@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
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.

  • Synthena

jschmied and others added 2 commits November 19, 2026 22:49
…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
ashhart merged commit e3d86f0 into ashhart:main Nov 19, 2026
2 of 11 checks passed
@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants