Skip to content

runtime, gpu, app, glm5next: bound slot passes by rows and sequence bindings - #744

Merged
juliankang4 merged 8 commits into
midagedev:mainfrom
juliankang4:fix-glm-slot-pass-limits
Oct 23, 2026
Merged

juliankang4 merged 8 commits into
midagedev:mainfrom
juliankang4:fix-glm-slot-pass-limits

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

GLM 서버에서 plain 슬롯이 셋이나 넷 동시에 돌면 서버가 중단되던 결함을 고쳐, 한 pass가 묶을 수 있는 sequence 수까지 지켜 여러 pass로 나눠 실행하도록 합니다.

Part of #565. Tracked in #699.

What and why

With three or four plain GLM slots decoding at once, the server could stop. Slot passes were limited by row count only, and the GLM NextN body binds just two sequences per pass. A round of four rows from four slots passed the row check, then failed at the body with GLM's pass binds two sequences: 0..4.

The mismatch came in with e2d2e22a1c. f20a0dbacc made SlotRows own the row limit and 22a8050903 routed plain GLM server rounds through that shared pass path, both when the row limit was two. e2d2e22a1c raised LOAD_ROWS from two to four for a NextN load, and the sequence binding stayed at two. The same mismatch is on current main.

The fix gives the pass limits one owner and splits a round by both limits:

  • SlotRows::MAX_SLOTS declares how many sequences a pass can bind, apart from the row count. It defaults to MAX_ROWS. GLM reads it from its existing RowBind::SEQS.
  • runtime::round_passes owns both limits: it refuses a bound of no sequence or of more sequences than rows, never splits a window, and keeps slot 0's pass last. Plain rounds, drafted rounds and the width cost selector all cut through it.
  • GpuModel checks the sequence count at the shared boundary for capture, step and verify, before the body runs. The row sum is range-checked before it is added, so it cannot overflow. A call over the limit gets a named refusal there instead of a body error.
  • slots_a_pass gives the server's GLM admission check and the shared drafted-window boundary the same two limits. GLM gets no min(2) and no smaller slot cap.
  • The width cost selector prices a round by the pass packing the server runs, cut at the same row and sequence limits, so GLM's two-sequence passes get their own readings.

No kernel, launch formula, float arithmetic, gate band or pin changed, and the fix adds no unsafe. The fix makes a round that used to fail run as two passes, so it makes no speed claim. A round that already fits one pass pays one more host comparison (the sequence count) per pass cut, and its device work is unchanged.

Release notes: Fixed: three or four concurrent plain GLM slots now run as several passes instead of stopping the server.

Code shape

  • No second copy. Plain and drafted rounds both go through round_passes, and the server's admission check reads the same row and sequence data.
  • Model code holds only architecture facts. GLM adds no branch. Its sequence count comes from the existing RowBind::SEQS, and the shared owner carries the new limit.
  • Dead code is gone. Nothing was left unused. The new MAX_SLOTS and slots_a_pass have production callers in this diff.
  • No silent failure. A zero or invalid limit, a count over the limit and a row sum out of range are named refusals.
  • Comments state what is true now.
  • No relaxed gate. No band, tolerance or lint moved. The plain-slot server clause was widened and relabeled with a dated PIN.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up. cargo fmt --all and git diff --check are clean. Clippy was not run.

Duplication found or removed (path:line), or "none": none. A DUP scan flagged H_SLOTS in crates/gpu-gates/src/bin/gate_glm5next_e2e.rs against a constant in crates/gpu/src/card_slots.rs. They count different things (resident sequences in a test, expert contributions per token in a kernel), so they stay apart.

What I ran

Hardware for the GPU runs: a GB10 machine in the project's CUDA 13.3 container. The model is the existing GLM fixture, so nothing was downloaded. nvidia-smi before the serve gate:

| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |
  • FAIL-first: with the sequence condition taken out of runtime::round_passes, cargo test -p bloomery-runtime --lib -- round_packing batch_costs_keep_different_packings_separate exited 101: round_packing_keeps_windows_and_the_slot_zero_pass_last failed with 3 of 1 at (4, 2), left: 1, right: 2, and the width cost test failed with left: 0, right: 1.
  • With the width cost selector ignoring the sequence limit, batch_costs_keep_different_packings_separate fails on its own.
  • After the fix, cargo test -p bloomery-runtime --lib: 289 passed, 0 failed; cargo test -p bloomery-app --lib: 27 passed, 0 failed.
  • BLOOMERY_BOX_LOCAL=1 just gate-gpu-glm5next-stagger ended with gpu-gate.sh: gate_glm5next_e2e ran 28 s (exit 0) and clauses: 6 ran, 0 left to the real tier. The new clause (h5) prints (h5) Eager four windows passes=2 solo_ids=true PASS and the same line for Graph: four NextN windows run as two passes in both modes, and their ids match the independent runs.
  • BLOOMERY_BOX_LOCAL=1 bash tools/box.sh 'bash tools/gpu-gate.sh gate_glm5next_e2e --only hostless' exited 0, printing hostless: three sequences refused before capture, step and verify PASS among its PASS lines for NVFP4 eager=graph=batch, the forced row and the Q4_K trace.
  • cargo oxide build --arch sm_121 -- -p bloomery-gpu-gates --features glm5next,clef,vision,mimo2,solar2,minimaxm3,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve --bin gate_glm5next_serve, then BLOOMERY_BOX_LOCAL=1 bash tools/box.sh 'bash tools/gpu-gate.sh gate_glm5next_serve --arm plain-slots --dir target/glmrows-serve', exited 0 with gate-gpu-glm5next-serve: PASS. Four concurrent requests each generated 64 token ids (together [Some(64), Some(64), Some(64), Some(64)]), and each matched its independent run. Of the 63 round records, the first ones read rows=3 passes=2 slots=4 and rows=4 passes=2 slots=4. The capacity and four-request overlap checks print PASS.

The unit tests above ran on this head. The three gates above ran before the limits moved into runtime::round_passes. After the merge I ran all three again on main at f4121587f, on the same GB10 machine in the fixture tier:

stagger-draft (h5) Eager four windows passes=2 solo_ids=true PASS
stagger-draft (h5) Graph four windows passes=2 solo_ids=true PASS
gpu-gate.sh: gate_glm5next_e2e ran 29 s (exit 0)
hostless: three sequences refused before capture, step and verify PASS
gpu-gate.sh: gate_glm5next_e2e ran 1 s (exit 0)
gate-gpu-glm5next-serve: PASS
gpu-gate.sh: gate_glm5next_serve ran 17 s (exit 0)

Mutants that turn each new test red: dropping the sequence condition in runtime::round_passes fails round_packing_keeps_windows_and_the_slot_zero_pass_last and batch_costs_keep_different_packings_separate; removing GLM's MAX_SLOTS override fails pass_limits_match_the_walks_sequence_bindings; running slot 0's pass first fails the slot 0 draft-row check.

Not run: t0, clippy, the full workspace check, and a timing comparison. The change is host scheduling and a shared boundary check, with no kernel change, so it does not touch TP rank slicing or collectives. I ran no two-node check.

What I ran into

Nothing here blocks this PR. A round that splits into many passes recomputes the rows ahead of each cut in Session::step_slots_rounds. A prefix offset computed once would remove that work if many concurrent slots turn out to matter.

Reproduction

cargo test -p bloomery-runtime --lib
cargo test -p bloomery-app --lib
# On a GB10 the GLM gates run in the fixture tier; the real tier opens only the workstation cards.
export BLOOMERY_ARCH=sm_121 BLOOMERY_BOX_LOCAL=1 BLOOMERY_MODEL=glm5next BLOOMERY_TIER=fixture BLOOMERY_GATE_CARD=any
unset BLOOMERY_REF_MODEL BLOOMERY_REF_MODEL_PROFILE
source tools/ref/ref-paths.sh && export BLOOMERY_REF_MODEL="$MODEL"
just gate-gpu-glm5next-stagger
bash tools/box.sh 'bash tools/gpu-gate.sh gate_glm5next_e2e --only hostless'
cargo oxide build --arch sm_121 -- -p bloomery-gpu-gates --features glm5next,clef,vision,mimo2,solar2,minimaxm3,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve --bin gate_glm5next_serve
bash tools/box.sh 'bash tools/gpu-gate.sh gate_glm5next_serve --arm plain-slots --dir target/glmrows-serve'

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card labels Oct 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: CLEAN: No reachable behavior defect or proven quality defect was found.

Non-blocking

⚠ Validate the final planner: crates/runtime/src/lib.rs:130. The body says the GPU runs preceded the final planner move. Re-run stagger, hostless and plain-slots on this head. Attach the tested commit hashes, model path, commands and output so the evidence covers the implementation being merged.

⚠ Supply dispatch proof: crates/runtime/src/lib.rs:130. A packing call adds at most N−1 sequence comparisons for N entries, N ≥ 1 [derived]; the width selector calls the packer for candidate widths. Supply an identical PTX scan for the host move and the same-lease A/B required by AGENTS.md for previously valid rounds.

Optimization headroom

  • E. Less work: crates/app/src/lib.rs:721. Reuse row offsets across passes. With 32 plain GLM slots and two slots per pass, repeated prefixes read 240 lengths per round; one traversal reads 32 (1,920 → 256 logical bytes of 64-bit lengths [derived]).

Checked

Shared owner: plain rounds, drafted rounds and width selection call runtime::round_passes.
Complexity: hostless adds a refusal-check clause; serve run adds arm dispatch.
Silent failure: 1 zero-result site followed through both production callers. slots_a_pass documents zero capacity; callers select the fallback or return a named refusal. No new discarded errors.
Tests: static mutation checks reject a dropped sequence condition, missing GLM override, changed slot-0 order, wrong cost packing, missing boundary refusal, and incorrect pass/output routing. The body reports FAIL-first for packing and cost selection.
Gates: no band or tolerance moved. Removed app assertions move to the runtime test with a dated PIN; the widened serve clause has a dated PIN.
Adversarial checks: invalid bounds, maximum row counts, reordered passes and logits offsets are guarded; sibling SlotRows implementations have no proven sequence-limit mismatch.
Escape catalog: C1–C4 do not match.

Notes

No builds or gates were executed during this static review or validation.

Card check: needs-gpu. This pull request changes crates/app/src/lib.rs, crates/app/src/mtp.rs, crates/gpu-gates/src/bin/gate_glm5next_e2e.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit f412158 into midagedev:main Oct 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant