[PR #47] [CLOSED] prefill: the borrow estimate misses the NextN cache fill - chunks over ~9K tokens on a split crash #299

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

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/47
Author: @sociolog
Created: 10/9/2026
Status: ❌ Closed

Base: main ← Head: pr3-prefill-borrow


📝 Commits (1)

  • 79dd17e prefill: the borrow estimate takes the NextN cache fill's region; a chunk that does not fit the lent tail is refused

📊 Changes

1 file changed (+11 additions, -1 deletions)

View changed files

📝 src/core/glm_prefill.cu (+11 -1)

📄 Description

The bug

prefill_carve sizes the per-layer region as the max over the mixers, the MoE and - on the half that carries the
NextN block - the block's cache fill (T x (6 n_embd + kv_lora + 2 idx_key) floats). The setup's estimate
(bytes_for), which sizes the pool tail that is lent to the prompt path, leaves the NextN term out. Up to ~9K tokens
a chunk the MoE term is larger, so it never showed; above that, on the NextN half, the carve runs past the lent tail.

Repro on v1.0.15 / v1.0.16 (RTX 3090 + 3060, Maya-M): STRATA_GLM_PREFILL_CHUNK=10240 STRATA_GLM_PREFILL_MB=4096,
any prompt over ~10K tokens: the expert staging cudaMemcpyAsync returns "invalid argument" (its destination is
outside the pool), the next check reports prefill mmq: quantize: invalid argument, then the engine segfaults.
Instrumented: CUDA1 carve 2407 MB, lent tail 2307 MB.

The fix

  • The estimate takes the same NextN term as the carve.
  • prefill() refuses a carve larger than the lent tail with a message instead of writing past it.

Result

20,025-token prompt, 3090 + 3060 split, prompt speed by chunk size (all run now; > 8192 crashed before):

chunk 8192 (2-GPU default) 10240 12288 16384 20480 (one chunk)
tok/s 788 829 827 828 719

The 2-part default stays 8192 in this patch (two pipelined chunks of ~10K are ~5 % faster on a 20K prompt here; one
chunk loses the pipelining between the halves) - your call whether to raise it.

Checks run on this branch (run on v1.0.16; the branch is rebased onto v1.0.20 - upstream's engine changes since are one INFO line and one comment; the server tests re-run on v1.0.20: 124 OK): builds (sm_75, sm_86); glm_dsa_parity, glm_ffn_parity, glm_hc_parity, glm_kda_parity, glm_layer_parity --selftest: all PASS; python -m unittest serve.test_server serve.test_tools serve.test_mcp serve.test_detok: 102 tests OK (3 skipped); the --bench request sequence (3 answers, 2K and 8K prompts) on the real model: runs clean.


The code, the measurements and this description were produced with the help of Claude, an AI assistant by Anthropic.


🔄 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/47 **Author:** [@sociolog](https://github.com/sociolog) **Created:** 10/9/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr3-prefill-borrow` --- ### 📝 Commits (1) - [`79dd17e`](https://github.com/mw00/project-maya/commit/79dd17e5d150c56f1d720eff7cdc5a9793724d5e) prefill: the borrow estimate takes the NextN cache fill's region; a chunk that does not fit the lent tail is refused ### 📊 Changes **1 file changed** (+11 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/core/glm_prefill.cu` (+11 -1) </details> ### 📄 Description ## The bug `prefill_carve` sizes the per-layer region as the max over the mixers, the MoE and - on the half that carries the NextN block - the block's cache fill (`T x (6 n_embd + kv_lora + 2 idx_key)` floats). The setup's estimate (`bytes_for`), which sizes the pool tail that is lent to the prompt path, leaves the NextN term out. Up to ~9K tokens a chunk the MoE term is larger, so it never showed; above that, on the NextN half, the carve runs past the lent tail. Repro on v1.0.15 / v1.0.16 (RTX 3090 + 3060, Maya-M): `STRATA_GLM_PREFILL_CHUNK=10240 STRATA_GLM_PREFILL_MB=4096`, any prompt over ~10K tokens: the expert staging `cudaMemcpyAsync` returns "invalid argument" (its destination is outside the pool), the next check reports `prefill mmq: quantize: invalid argument`, then the engine segfaults. Instrumented: CUDA1 carve 2407 MB, lent tail 2307 MB. ## The fix - The estimate takes the same NextN term as the carve. - `prefill()` refuses a carve larger than the lent tail with a message instead of writing past it. ## Result 20,025-token prompt, 3090 + 3060 split, prompt speed by chunk size (all run now; > 8192 crashed before): | chunk | 8192 (2-GPU default) | 10240 | 12288 | 16384 | 20480 (one chunk) | |---|---:|---:|---:|---:|---:| | tok/s | 788 | 829 | 827 | 828 | 719 | The 2-part default stays 8192 in this patch (two pipelined chunks of ~10K are ~5 % faster on a 20K prompt here; one chunk loses the pipelining between the halves) - your call whether to raise it. **Checks run on this branch (run on v1.0.16; the branch is rebased onto v1.0.20 - upstream's engine changes since are one INFO line and one comment; the server tests re-run on v1.0.20: 124 OK):** builds (sm_75, sm_86); `glm_dsa_parity`, `glm_ffn_parity`, `glm_hc_parity`, `glm_kda_parity`, `glm_layer_parity` `--selftest`: all PASS; `python -m unittest serve.test_server serve.test_tools serve.test_mcp serve.test_detok`: 102 tests OK (3 skipped); the `--bench` request sequence (3 answers, 2K and 8K prompts) on the real model: runs clean. --- *The code, the measurements and this description were produced with the help of Claude, an AI assistant by Anthropic.* --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:23:57 +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#299
No description provided.