mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #284] [MERGED] glm prefill: show where each prompt chunk's time goes #443
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#443
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/mw00/project-maya/pull/284
Author: @gopinath87607
Created: 10/20/2026
Status: ✅ Merged
Merged: 10/21/2026
Merged by: @mw00
Base:
main← Head:pr/prefill-stages📝 Commits (3)
8e9665bglm prefill: STRATA_GLM_PREFILL_STAGES (on) prints where a prompt chunk's wall went - one line a part a chunk: the copy lane's span split into the copies, 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), with the lane's lead and tail beside it (lead + lane + tail = wall), the pcie GB/s over the copy time, the bytes and experts each lane moved, and the layer lane's max/min; and one line a prompt with each part's chunk walls and what the hand-overs between them cost. Until now a prefill change could only be judged by the prompt's ms/token, which mixes four parts, the chunk size and the CPU lane -glm prefill: 6500 tokens in 4802 ms (0.74 ms/token, 1353 tok/s), 1 chunk of 6500 | CUDA0 4523 ms, ...says which part and which stretch of the lane. 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 should find nothing2633b04glm prefill: the stage line's events are destroyed with the rest of the prompt path - the pool is grown on demand and a part's prompt path can be destroyed and built again (the vision lend takes it down), so the leaked events would accumulate with every rebuilde2c5e28glm prefill: the stage 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, so the chunk's own cudaGetLastError check failed every prompt that reached the line (CUDA0's chunk line printed, then the request died with "glm prefill: invalid resource handle"); the flag is set where prefill_run records the hop, and a query that fails now clears its own error, so the line reads -1 where it cannot measure rather than failing the prompt it is measuring. The per-prompt summary also printed the chunk's token size as a chunk count ("1 chunk of 448"): it says "448 tokens" now. Verified on a fresh 421-token prompt after a restart: four part lines (wall 1735/1187/1473/989 ms, lead+lane+tail = wall on every one, copies 6.4 GB/s on the two 5060s and 9.0 on the two 3060s, ring wait 0, mixer windows 146/200/269/187 ms), "glm prefill: 421 tokens in 5549.2 ms (13.18 ms/token, 76 tok/s), 1 chunk of 448 tokens", and the answer at 82.3 ms/tok decode (12.2 tok/s)📊 Changes
2 files changed (+193 additions, -1 deletions)
View changed files
📝
docs/SETTINGS.md(+1 -0)📝
src/core/glm_prefill.cu(+192 -1)📄 Description
What this changes
STRATA_GLM_PREFILL_STAGES(on by default;=0silences) 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=0beside a--benchis 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
cudaEventElapsedTimeon 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 says448 tokens, not1 chunk of 448.What it leaves alone
The compute path is unchanged and
=0restores silence. The row is indocs/SETTINGS.mdas 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=0A/B is the check.Checks
src/core/glm_prefill.cucompiles clean with the build's own flags (nvcc 13.2, compute_86 + compute_120).python3 tools/check_hip_compat.pypasses.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.