[CUDA][Muse-Glimmer] Retained prefixes slow fresh-prompt prefill in the off-graph cell KV cache
メンテナーはふだん 1 日以内に返信
@Gasoonjia がすでに取り組んでいます。
2026年11月24日 から。
評価
この issue はまだ評価されていません。
説明
Describe the bug
On the CUDA off-graph cell KV cache path, retaining unrelated prefixes slows fresh-prompt prefill as the occupied shared pool grows. With the same four-session configuration, disabling prefix retention improves 6K prefill from 1,544 to 2,304 tokens/s (~49%). Prefix reuse should remain useful without making a fresh prompt scan unrelated retained sequences.
This was reproduced while bringing up a Linux CUDA 13.2 Muse-Glimmer text-only solo package. The main report concerns cache-related prefill overhead. Two related export/performance observations are listed below, with their limits.
Versions and model
- ExecuTorch:
799098d28233ec11cba62c57a3484d48185f741f - PyTorch:
2.15.0+cu132; Python 3.12; CUDA toolkit 13.2 (nvcc V13.2.86); driver 610.43.02 - GPU: NVIDIA PG509-210, sm80, 108 SMs, 80 GB; maximum SM clock 1,410 MHz; configured power limit 330 W
- Model: meta-models/Muse-Glimmer-30B-GGUF, revision
b44f1072cf75e918a1b82a3a17b45c4389b076e7, fileMuse-Glimmer-30B-KQuant-17GB-Q4_K_M.gguf - GGUF SHA256:
4cc57c0f51040a226e5a72cc47b7613f7772950e460a665f7083de89f183f60e - BF16 activations/KV; all layers on GPU; no DFlash or vision
Export
python -m executorch.examples.models.muse_glimmer.export.export_solo \
--gguf "$GGUF" --backend cuda --activation-dtype bfloat16 \
--use-offgraph-kv-cache --max-seq-len 131072 \
--max-step-tokens 512 --max-cells 131072 --max-kv-seqs 4 \
--forward-sizes 1,4 --output-dir "$OUT"
The export succeeded in 1,813 seconds and produced a 30,911,232-byte PTE plus a 17,857,004,800-byte aoti_cuda_blob.ptd.
Reproduction
Use the Muse-Glimmer batching worker with the exported PTE, companion PTD and model tokenizer. Keep these flags fixed:
muse_glimmer_batching_worker \
--backend=cuda --pte="$PTE" --data_path="$PTD" --tokenizer="$TOKENIZER" \
--max_sessions=4 --max_inflight_requests=4 --max_decode_sequences=4 \
--max_session_tokens=8191 --prefix_cache_entries=8 \
--prefix_checkpoint_prompt_end=every
Run a second fresh worker with the same flags except --prefix_cache_entries=0, omitting --prefix_checkpoint_prompt_end=every.
Feed JSONL requests through stdin. For each supplied prompt length 512, 2048, then 6144, perform four sequential requests using distinct session IDs and deterministic random token IDs from [3, 199000). Generate one output token with temperature=0.0 and ignore_eos=true. Wait for the terminal done response, then send close and wait for its acknowledgment before the next request. Exclude the first request at each length as warmup and take the median of the remaining three native prefill_tok_s values. The worker adds BOS, giving measured prompt lengths 513/2049/6145. For example:
{"op":"generate","request_id":1,"session_id":"fresh-1","prompt_segments":[{"ids":[123,456,789]}],"max_new_tokens":1,"temperature":0.0,"ignore_eos":true}
{"op":"close","request_id":2,"session_id":"fresh-1"}
Replace the short illustrative ID list with the full prompt. Seeds used were supplied_length + 1 + trial, where trial is 0–3. Closed sessions release their live state; the cached configuration retains prefix snapshots. Only one benchmark actively used the GPU at a time; a separate package server remained resident and idle.
Measurements
Medians after warmup, tokens/s:
| Prompt tokens | ExecuTorch, no prefix retention | ExecuTorch, eight prefix entries | llama.cpp, FP16 KV | llama.cpp, BF16 KV |
|---|---|---|---|---|
| 2049 | 2176 | 1884 | 1427 | 1427 |
| 6145 | 2304 | 1544 | 1434 | 1433 |
Short 513-token timings varied across configurations/warmups; this diagnosis relies on the 2K/6K results and matched 6K traces.
In a separate matched Nsight Systems capture of three fresh 6K prompts, one output token each:
| Configuration | Total attention kernel time | Share of GPU kernel time | Request prefill times |
|---|---|---|---|
| Prefix retention disabled | 1069.6 ms | 14.0% | 2782, 2684, 2683 ms |
| Eight retained prefix entries | 1690.9 ms | 20.6% | 2775, 3067, 3443 ms |
Attention time increases 58.1%. The first request is similar; later distinct retained prefixes increase latency. Profiled timings include profiler overhead and are separate from the unprofiled throughput table.
Suspected mechanism
Revision-pinned source:
- CellCache::step_for / build_mask:
step.read_len = used_end_; the mask is allocated and constructed over query tokens × occupied pool extent. - CUDA off-graph KV lowering: passes the shared pool, explicit mask and read length to SDPA.
- Triton SDPA: traverses KV tiles up to that read length and checks/reduces the mask. Invisible tiles can skip K/V dot products, but checking unrelated tiles still costs work.
A separate CPU perf capture found mask construction at 3.44% self samples; driver/copy paths dominated. This does not establish CPU mask construction alone as the bottleneck.
Could the cell path use compact per-sequence KV indices/masks, or another mechanism that avoids traversing unrelated retained prefixes while preserving shared-prefix reuse? A sequence-layout export is a candidate to compare; no fix has been validated yet.
Related observations
- Quantized prefill dispatch: the quantized GEMM family specializes through M=64; 512-token prefill materializes BF16 weights and runs BF16 GEMM. In an uncached 2K trace, matrix multiplies/fusions account for 59.1% of GPU kernel time, dequantization 27.8%, and attention 7.9%. A fused low-bit prefill path is an optimization opportunity, but these results do not establish a regression against llama.cpp: ExecuTorch was faster in the measured comparison.
- 128K context versus total cell capacity: this export used both
--max-seq-len 131072and--max-cells 131072. The latter is shared total capacity, not per-session capacity. With four sessions, eight prefix slots and four capture slots, the observed supported per-session context was 8191, including the padding-cell constraint. This was an export configuration mistake rather than evidence that CUDA cannot support 128K. Clearer export/serving guidance for sizing the total cell budget would help; a larger export and its memory budget have not been validated.
Roofline and llama.cpp comparison limits
The largest generated BF16 GEMM (M=512, N=39936, K=6656) has 272.194 GFLOP of arithmetic and a median duration of 1.105337 ms: approximately 246 TFLOP/s, or 79% of nominal dense BF16 peak. Separate under-load clock samples were 1365–1395 MHz, suggesting roughly 80–82% of the clock-adjusted compute ceiling. This is a timing-derived estimate, not hardware-counter roofline verification: Nsight Compute failed because a driver profiling resource was unavailable. High GPU utilization can include avoidable cache traversal.
llama.cpp revision 8345f3339 was built for CUDA 13.2 / sm80 without source changes. Its benchmark used the same GGUF, all layers offloaded, Flash Attention, batch/microbatch 512 and three measured repetitions. Increasing microbatch to 1024/2048 gave only a few percent prefill improvement. Native decode around 6K was approximately 63 tok/s for ExecuTorch versus 50 tok/s for llama.cpp; these native timings exclude HTTP overhead and use different sampling boundaries.
- 主要言語
- Python
- スター
- 5.2k
- フォーク
- 1.3k
- 平均マージ
- 1日 7時間
- マージ済み PR(30日)
- 644
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pytorch/executorch のほかの issue
-
to_edge_transform_and_lower ignores some ops_to_not_decompose requests: multi-output ops, and non-core ops without a decomposition対応中かも @Eureka-Zhang が 7 日前に担当しました。 オープンmodule: exir
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
pytorch/executorch#25620 ·
メンテナーはふだん 1 日以内に返信
-
Qualcomm AI Engine Direct - fp16a8w quantization crashes on layer_norm対応中かも @psiddh が 21 日前に担当しました。 オープンbug module: qnn partner: qualcomm
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
pytorch/executorch#24434 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
enhancement triaged
難易度 2/5 半日 初心者へのやさしさ 68/100
pytorch/executorch#21640 ·
メンテナーはふだん 1 日以内に返信
-
quantize_per_channel and dequantize_per_tensor.tensor abort the process on a float32 scale対応中かも @AxelNoun が今日担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
pytorch/executorch#25873 ·
メンテナーはふだん 1 日以内に返信
-
XNNPACK INT4 linear returns incorrect per-channel outputs and fails groupwise FP16 on Apple M4 Max対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug module: quantization module: xnnpack
難易度 4/5 3〜5日 初心者へのやさしさ 43/100
pytorch/executorch#25854 ·
メンテナーはふだん 1 日以内に返信
pytorch/executorch の issue をすべて見る
似ている issue
-
Container fails to start when GitHub Releases is unavailable: uv run re-downloads the tvl wheelオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
trezor/trezor-user-env#421 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 1/5 1〜3時間 初心者へのやさしさ 91/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
tangentcode/tangentswarm#167 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信