[PR #2774] [CLOSED] Short prompt chunks: router push + decode grouped kernel for resident experts #4258

Closed
opened 2026-11-07 15:34:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2774
Author: @apatassini
Created: 10/16/2026
Status: ❌ Closed

Base: main ← Head: short-prompt-reads


📝 Commits (1)

  • 25b1894 Short prompt chunks: router push and the decode grouped kernel for resident experts (opt-in push)

📊 Changes

1 file changed (+107 additions, -2 deletions)

View changed files

📝 src/prefill/prefill.cpp (+107 -2)

📄 Description

Agent workloads read many short prompt chunks (tool results, file excerpts): in a 5-hour coding-agent session on an RTX 5070 Ti
(Qwen3.8-Flash-Next GSQ-RCO Q2_0, 256K) 74% of the reads were under 1,000 tokens and took 57% of the read time, at 200-750 tok/s.

With STRATA_PREFILL_TIMING=1, a 170-token chunk spends ~40% in what the timer calls "dequant": on a canonical (non-native)
pack, below stream_all_min MMQ converts every expert blob into GGUF blocks with one gather_strata_q2 launch per expert
(~14,000 launches for 170 tokens); the copies from RAM are only ~3%.

The branch adds, for chunks below stream_all_min only:

  • STRATA_PF_ROUTE_PRIOR=lambda — the decode push (route_prior_top10) also in the prefill router (opt-in, changes outputs
    like STRATA_ROUTE_PRIOR);
  • resident experts used by at most STRATA_PF_DIRETTO_MAX rows (default 8) leave MMQ's list — their rows form a block after the
    local ones, as the CPU share does — and run on moe_grouped_s2 (or native_expert_grouped for native packs) straight from the
    compressed blob, in calls of up to 1,024 rows with a small own scratch (9 MiB). STRATA_PF_DIRETTO=0 turns it off.

Measured (28K cached context, appended chunk, RTX 5070 Ti): 177 tokens 473 → ~315 ms, ~500 668 → ~470 ms, ~900 826 → ~677 ms;

= 1,024 tokens and decode unchanged. Max rows 16 ≈ 8; 4 is worse; all rows is much worse (the decode kernel re-reads the blob
every 8 rows).

Two pitfalls found on the way: moe_grouped_s2 handles at most GMAX = 8 rows per group and silently drops the rest; MMQ closes
its last group at rows_local (bounds_host[n]), so rows_local must exclude the new block.

The read push is opt-in; so far only sanity-checked on outputs, no separate quality run yet (the decode push STRATA_ROUTE_PRIOR=1.0 was quality-checked on two real tasks, 3+3 runs, no measurable loss).

Full notes and measurements: https://github.com/apatassini/Strata/blob/qwen38-16gb/QWEN38.md

🤖 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/Niko1221/Strata/pull/2774 **Author:** [@apatassini](https://github.com/apatassini) **Created:** 10/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `short-prompt-reads` --- ### 📝 Commits (1) - [`25b1894`](https://github.com/Niko1221/Strata/commit/25b1894d5a1ac10564e9d3167b440fd97e8331c2) Short prompt chunks: router push and the decode grouped kernel for resident experts (opt-in push) ### 📊 Changes **1 file changed** (+107 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/prefill/prefill.cpp` (+107 -2) </details> ### 📄 Description Agent workloads read many short prompt chunks (tool results, file excerpts): in a 5-hour coding-agent session on an RTX 5070 Ti (Qwen3.8-Flash-Next GSQ-RCO Q2_0, 256K) 74% of the reads were under 1,000 tokens and took 57% of the read time, at 200-750 tok/s. With `STRATA_PREFILL_TIMING=1`, a 170-token chunk spends ~40% in what the timer calls "dequant": on a canonical (non-native) pack, below `stream_all_min` MMQ converts every expert blob into GGUF blocks with one `gather_strata_q2` launch per expert (~14,000 launches for 170 tokens); the copies from RAM are only ~3%. The branch adds, for chunks below `stream_all_min` only: - `STRATA_PF_ROUTE_PRIOR=lambda` — the decode push (`route_prior_top10`) also in the prefill router (opt-in, changes outputs like `STRATA_ROUTE_PRIOR`); - resident experts used by at most `STRATA_PF_DIRETTO_MAX` rows (default 8) leave MMQ's list — their rows form a block after the local ones, as the CPU share does — and run on `moe_grouped_s2` (or `native_expert_grouped` for native packs) straight from the compressed blob, in calls of up to 1,024 rows with a small own scratch (9 MiB). `STRATA_PF_DIRETTO=0` turns it off. Measured (28K cached context, appended chunk, RTX 5070 Ti): 177 tokens 473 → ~315 ms, ~500 668 → ~470 ms, ~900 826 → ~677 ms; >= 1,024 tokens and decode unchanged. Max rows 16 ≈ 8; 4 is worse; all rows is much worse (the decode kernel re-reads the blob every 8 rows). Two pitfalls found on the way: `moe_grouped_s2` handles at most `GMAX = 8` rows per group and silently drops the rest; MMQ closes its last group at `rows_local` (`bounds_host[n]`), so `rows_local` must exclude the new block. The read push is opt-in; so far only sanity-checked on outputs, no separate quality run yet (the decode push `STRATA_ROUTE_PRIOR=1.0` was quality-checked on two real tasks, 3+3 runs, no measurable loss). Full notes and measurements: https://github.com/apatassini/Strata/blob/qwen38-16gb/QWEN38.md 🤖 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-11-07 15:34:23 +07:00
Sign in to join this conversation.
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
Niko1221/Strata#4258
No description provided.