Skip to content

gpu-gates: preserve whole GLM pass wall in throughput - #723

Merged
juliankang4 merged 3 commits into
midagedev:mainfrom
juliankang4:fix-glm-pass-time-accounting
Oct 23, 2026
Merged

juliankang4 merged 3 commits into
midagedev:mainfrom
juliankang4:fix-glm-pass-time-accounting

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

GLM MTP 생성 시간 집계가 마지막 pass의 시간을 일부 버리던 결함을 고쳐, 처리량 숫자가 pass 전체 시간을 쓰도록 합니다.

Part of #565. Tracked in #699.

What and why

The drafted GLM generation CLI (generate_glm5next) could drop part of a pass's wall time from its timing lines. When the -n token limit cut the last window, the sink divided that window's wall by all the rows it kept, then stored only the rows that fit under the limit. The part of the wall that belonged to the cut rows disappeared. A pass that straddled the --warm boundary lost time in the same way, and time pass marked it warm if its last token was warm. The summary rate and the SMOKE footer therefore mixed two units: positions the passes advanced and tokens the CLI delivered. The sink came in with 98f784b.

The sink now stores each pass's token IDs and positions apart from its full wall. The aggregation and record assembly moved into shared/gen_time.rs, which the CLI and a host test both compile, so the test exercises the production code and no copy of it.

  • time step spreads a pass's whole wall over the tokens it delivered. A pass that crosses the warm boundary puts its full wall on the counted tokens and zero on its warm ones, so both the all-step sum and the counted-step sum keep the pass wall.
  • time pass is marked warm only when every token of the pass is warm.
  • mtp summary divides all advanced positions by all pass wall time.
  • The SMOKE footer divides the tokens delivered after --warm by the full wall of every pass that delivered one of them.

Token 0 still belongs to the prompt time, output tokens and the token limit are unchanged, and the plain and slots paths are untouched. Inference, draft selection, launches and token IDs are unchanged. What changes is the time attribution, the warm flag and the throughput in these records.

Release notes: Fixed: the GLM drafted generation timing records keep the whole wall time of the last and warm-boundary passes.

Code shape

  • No second copy. The aggregation and record assembly have one owner, shared/gen_time.rs. The CLI's earlier inline version is removed, and the test includes the same file instead of repeating it.
  • Model code holds only architecture facts. The new module is a CLI timing helper and holds no model facts.
  • Dead code is gone. The per-token time stored in the sink and the inline aggregation in generate_glm5next.rs are removed.
  • No silent failure. No error path was added or swallowed. The existing parsing and the existing error for a generation that ends early are kept.
  • Comments state what is true now. The CLI doc comment now describes how a pass wall is attributed.
  • No relaxed gate. No band, tolerance or lint moved.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up. rustfmt --check --edition 2024 on the three changed files and git diff --check are clean; clippy has not been run on this head.

Duplication found or removed (path:line), or "none": none found. The inline aggregation in crates/gpu-gates/src/bin/generate_glm5next.rs moved into crates/gpu-gates/src/bin/shared/gen_time.rs. The Qwen path already sums whole pass walls and counts --warm in passes, so it follows a different contract and is not changed here.

What I ran

The tested head is 12fba900f74c2998da4e620a1859ae06a6189555, based on 648dd751d9ed25f9a18d8a404e5f08e3fb52e512. The tests use synthetic pass data (one pass of 10 ms and one of 40 ms), so they need no model or GPU. They ran on an RTX 5090 machine on the CPU.

  • FAIL-first: with the accounting module restored to the version before this fix, bash tools/gate.sh -p bloomery-gpu-gates --test gen_time -- --nocapture failed on the real assertions: test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s, exit 101. The last delivered step was 20 ms where 40 ms was expected, the counted wall was 20 ms instead of 40 ms, and the summary rate was 66.67 instead of 60.0.
  • Warm-flag mutant: with the final source and .flag("warm", *at <= warm) changed to .flag("warm", *at - kept < warm), bash tools/gate.sh -p bloomery-gpu-gates --test gen_time -- drafted_pass_is_warm_only_when_all_its_tokens_are_warm --nocapture failed: test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 3 filtered out; finished in 0.00s, exit 101. The second pass was marked warm.
  • After restoring the final source, bash tools/gate.sh -p bloomery-gpu-gates --test gen_time -- --nocapture: test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s.
  • On the fixture, the final source prints mtp summary at tok/s(positions)=60.00 (three positions over 50 ms) and SMOKE at tok/s(positions)=40.00 for two delivered tokens. With one counted token the footer reads mean_ms=40.0000 and 25.00 tokens/s. They are fixture arithmetic and carry no model speed claim.

The four tests cover the last pass wall when the token limit cuts a pass and when it fits exactly, a pass that straddles the warm boundary, the warm flag of each pass, and the summary and footer records read back through the existing record parser.

The machine was an RTX 5090 host, and nvidia-smi reported this before the run:

NVIDIA GeForce RTX 5090, driver 595.99.02, CUDA 12.0

  • just gate-ds41-place not run here: it needs the CLI built with the GLM feature, and that CLI's own test module includes the new tests, so the gate runs them.

Not run: clippy, t0, and the CLI built with the GLM feature. No CUDA kernel, launch or device arithmetic changed, so I ran no GPU gate, no model generation and no timing comparison.

Reproduction

bash tools/gate.sh -p bloomery-gpu-gates --test gen_time -- --nocapture
bash tools/gate.sh -p bloomery-gpu-gates --test gen_time -- drafted_pass_is_warm_only_when_all_its_tokens_are_warm --nocapture

The second command runs the warm-flag test alone.

What I ran into

This does not block the PR. The Qwen drafted path counts --warm in passes and the GLM path counts it in generated tokens. I kept both, because each already matches its own record format.

AI help

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

@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app 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: The remaining finding concerns stale test evidence; no must-fix finding remains.

Non-blocking

⚠ Refresh the test evidence: crates/gpu-gates/src/bin/shared/gen_time.rs:126. This module has three tests compiled into generate_glm5next, and no --test gen_time target exists. The PR body reports four tests from different hashes. Run just gate-ds41-place at this head and update the transcript so the regression evidence is reproducible.

Checked

Duplicates: 10 new or moved items; the extraction replaces the inline GLM owner and reuses the existing quantile helper. No dryer pairs supplied.
Complexity: crapper flagged no function.
Silent failure: 2 truncation sites followed. Runtime token accounting and CLI guards prevent missing timed rows and empty counted samples.
Tests: static mutation analysis in gen_time.rs: dividing by kept at line 38 fails the last-pass assertion; omitting crossing-pass wall at line 35 fails the warm-boundary assertion; using delivered-token rate at line 65 or first-token warmth at line 76 fails the record assertions. Rust tests were not run.
Gates: none relaxed; no PIN moved. The existing gate-ds41-place recipe selects all three new tests.
Escape catalog: C1–C4 do not match.

Notes

dryer did not run; diagnostics reports no changed Rust file under crates/, although both changed paths are there.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/generate_glm5next.rs, crates/gpu-gates/src/bin/shared/gen_time.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 8f02929 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 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