[PR #284] [MERGED] glm prefill: show where each prompt chunk's time goes #443

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

📋 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)

  • 8e9665b glm 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 nothing
  • 2633b04 glm 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 rebuild
  • e2c5e28 glm 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

Why this PR was recreated. The original (#237) was opened from the gopinath87607/ewaste-maya fork. Deleting that fork deleted its branches, and GitHub closes every pull request whose branch lived in a deleted fork - a closed PR whose source branch is gone cannot be reopened. This is the same work from a new fork (gopinath87607/project-maya), rebased onto current main (v1.1.16 renamed the settings to MAYA_*; that rename is resolved in docs/SETTINGS.md and the code still reads the STRATA_* spelling the alias sets). It replaces the closed #237, which was closed by the fork's deletion, not by a maintainer.


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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mw00/project-maya/pull/284 **Author:** [@gopinath87607](https://github.com/gopinath87607) **Created:** 10/20/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `pr/prefill-stages` --- ### 📝 Commits (3) - [`8e9665b`](https://github.com/mw00/project-maya/commit/8e9665bf94f382b790b231d6125f2bf7d1a93f79) glm 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 nothing - [`2633b04`](https://github.com/mw00/project-maya/commit/2633b044a92b1240f0ba30a84dd9095fb9f4502d) glm 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 rebuild - [`e2c5e28`](https://github.com/mw00/project-maya/commit/e2c5e2816ebda161d25f6e1499e43fe662014089) glm 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) <details> <summary>View changed files</summary> 📝 `docs/SETTINGS.md` (+1 -0) 📝 `src/core/glm_prefill.cu` (+192 -1) </details> ### 📄 Description > **Why this PR was recreated.** The original (#237) was opened from the `gopinath87607/ewaste-maya` fork. Deleting that fork deleted its branches, and GitHub closes every pull request whose branch lived in a deleted fork - a closed PR whose source branch is gone cannot be reopened. This is the same work from a new fork (`gopinath87607/project-maya`), rebased onto current `main` (v1.1.16 renamed the settings to `MAYA_*`; that rename is resolved in `docs/SETTINGS.md` and the code still reads the `STRATA_*` spelling the alias sets). It replaces the closed #237, which was closed by the fork's deletion, not by a maintainer. --- ## 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:25:30 +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#443
No description provided.