[PR #237] glm prefill: STRATA_GLM_PREFILL_STAGES (on; =0 silences) prints where a prompt chunk's wall went #415

Closed
opened 2026-10-29 21:25:09 +07:00 by bsakaguchi · 0 comments
Owner

Original Pull Request: https://github.com/mw00/project-maya/pull/237

State: closed
Merged: No


What this changes

STRATA_GLM_PREFILL_STAGES (on by default; =0 silences) prints where a prompt chunk's wall went. A chunk is one long copy lane (the staged experts) beside the compute stream, and nothing said where its wall goes: the profiling prints only at exit, and the trace is a debug knob.

One line a part a chunk says: the copy lane's span split into the copies (with the PCIe GB/s over the copy time), the ring waits (a group's staging slot still being read), the gaps inside a layer's groups, and the windows between two layers' groups (the mixer and the host's plan - where a lane that is going to idle, idles); the lane's lead and tail beside it (lead + lane + tail = wall); the bytes and experts each lane moved (RAM, disk, VRAM staged, resident, prestaged, CPU); the host's plan time, disk waits and the hop in; and the layer lane's max/min. One line a prompt then gives each part's chunk walls and what the hand-overs between them cost, ending N chunk(s) of T tokens.

The syncs it adds wait only on copies the compute stream has already waited on (the last MoE layer prestages no next one), so STRATA_GLM_PREFILL_STAGES=0 beside a --bench is the A/B that should find no cost.

The branch also fixes two faults in the first version of the line: its events are destroyed with the rest of the prompt path (the pool can be rebuilt, e.g. by the vision lend, so leaked events would accumulate), and the line reads only the events its chunk recorded - the head part has no hop in, and cudaEventElapsedTime on an event with nothing recorded returns "invalid resource handle" and leaves it set, which made every prompt that reached the line die. A query that fails now clears its own error and reads -1. The per-prompt summary also says 448 tokens, not 1 chunk of 448.

What it leaves alone

The compute path is unchanged and =0 restores silence. The row is in docs/SETTINGS.md as on by default, as the checkout commits it.

Measurements

Verified on a fresh 421-token prompt after a restart: four part lines, walls 1,735 / 1,187 / 1,473 / 989 ms, lead + lane + tail = wall on every one, copies 6.4 GB/s on the two 5060s and 9.0 GB/s on the two 3060s, ring wait 0, mixer windows 146 / 200 / 269 / 187 ms; the summary read glm prefill: 421 tokens in 5549.2 ms (13.18 ms/token, 76 tok/s), 1 chunk of 448 tokens; the answer decoded at 82.3 ms/token. No cost is claimed for the line itself; the =0 A/B is the check.

Checks

  • src/core/glm_prefill.cu compiles clean with the build's own flags (nvcc 13.2, compute_86 + compute_120).
  • python3 tools/check_hip_compat.py passes.
  • Not run in this branch's preparation; the numbers are the checkout's, on the hardware named.

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/mw00/project-maya/pull/237 **State:** closed **Merged:** No --- ## What this changes `STRATA_GLM_PREFILL_STAGES` (**on by default; `=0` silences**) prints where a prompt chunk's wall went. A chunk is one long copy lane (the staged experts) beside the compute stream, and nothing said where its wall goes: the profiling prints only at exit, and the trace is a debug knob. One line a part a chunk says: the copy lane's span split into the copies (with the PCIe GB/s over the copy time), the ring waits (a group's staging slot still being read), the gaps inside a layer's groups, and the windows between two layers' groups (the mixer and the host's plan - where a lane that is going to idle, idles); the lane's lead and tail beside it (lead + lane + tail = wall); the bytes and experts each lane moved (RAM, disk, VRAM staged, resident, prestaged, CPU); the host's plan time, disk waits and the hop in; and the layer lane's max/min. One line a prompt then gives each part's chunk walls and what the hand-overs between them cost, ending `N chunk(s) of T tokens`. The syncs it adds wait only on copies the compute stream has already waited on (the last MoE layer prestages no next one), so `STRATA_GLM_PREFILL_STAGES=0` beside a `--bench` is the A/B that should find no cost. The branch also fixes two faults in the first version of the line: its events are destroyed with the rest of the prompt path (the pool can be rebuilt, e.g. by the vision lend, so leaked events would accumulate), and the line reads only the events its chunk recorded - the head part has no hop in, and `cudaEventElapsedTime` on an event with nothing recorded returns "invalid resource handle" and leaves it set, which made every prompt that reached the line die. A query that fails now clears its own error and reads -1. The per-prompt summary also says `448 tokens`, not `1 chunk of 448`. ## What it leaves alone The compute path is unchanged and `=0` restores silence. The row is in `docs/SETTINGS.md` as on by default, as the checkout commits it. ## Measurements Verified on a fresh 421-token prompt after a restart: four part lines, walls 1,735 / 1,187 / 1,473 / 989 ms, lead + lane + tail = wall on every one, copies 6.4 GB/s on the two 5060s and 9.0 GB/s on the two 3060s, ring wait 0, mixer windows 146 / 200 / 269 / 187 ms; the summary read `glm prefill: 421 tokens in 5549.2 ms (13.18 ms/token, 76 tok/s), 1 chunk of 448 tokens`; the answer decoded at 82.3 ms/token. No cost is claimed for the line itself; the `=0` A/B is the check. ## Checks - `src/core/glm_prefill.cu` compiles clean with the build's own flags (nvcc 13.2, compute_86 + compute_120). - `python3 tools/check_hip_compat.py` passes. - Not run in this branch's preparation; the numbers are the checkout's, on the hardware named. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
bsakaguchi 2026-10-29 21:25:09 +07:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#415
No description provided.