perf(moe): prefetch the next layer's experts from a router lookahead during offloaded decode
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 18/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- ai, performance
Direzione di ricerca
Start from the offloaded decode path behind --moe-strategy offload and the expert slot-map ensure logic, then read the linked fork commits and PR #74 to see the proposed router lookahead and prefetch install. Any change must keep every slot-map write on the compute stream, so review the race tests before anything else. Done means the FREETOKEN_MOE_PREFETCH=on path gives token-identical greedy output on cold prompts with the slot-map audit enabled.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In offloaded decode (--moe-strategy offload, decode on the GPU), each layer's expert misses are copied over PCIe only after that layer's router has run, so the copy sits on the critical path. On an RTX 5080 (16 GB, PCIe) serving Qwen3.8-Flash-Next-NVFP4, the expert H2D copies are about half of each decode step.
Proposal: predict layer L's experts one layer early and copy them while layer L-1 computes.
- Lookahead: run layer L's router on layer L-1's router input (the residual stream changes little between adjacent layers). Run it on a side stream forked at the start of L-1's MoE block.
- Install: right after L-1's own ensure, install up to N predicted, non-resident experts as low-priority slots: held, usage 0, first to be evicted. Copy them on a dedicated high-priority stream behind L-1's demand copy. L's demand copy then waits on that stream.
- Correctness constraint: every slot-map writer (demand ensure and prefetch install) must stay on the compute stream. Only reads and byte copies may cross streams. A first version that installed from the predictor stream behind an event join corrupted 1–6 of 60 cold greedy prompts. Two writers racing on the slot map was enough, even though an nsys trace showed no ordering violation.
Measured (Qwen3.8-Flash-Next-NVFP4, scored eviction with the shared-expert overlap as the baseline, N = 4):
| baseline | with prefetch | |
|---|---|---|
| decode, 32K context | 43.4 tok/s | 53.0 tok/s (+22%) |
| decode, 255K context | 43.0 tok/s | 50.8 tok/s |
| demand misses per token | 206 | 111 |
| VRAM | +148 MiB |
The output is lossless: greedy outputs were token-identical on 420 cold nonce prompts, with a slot-map audit enabled.
Implementation (on my fork, against an older main):
- 8c171b6: router lookahead (layer L's router on layer L-1's input).
- 47d4811: prefetch into low-priority slots behind
FREETOKEN_MOE_PREFETCH=on. - 3a0ff77: install prefetches on the compute stream, so the slot map has a single writer.
- The full series, including the race tests and the slot-audit/verify debug modes: https://github.com/gdevenyi/FreeToken/pull/74
- Lingua principale
- Python
- Stelle
- 14.2k
- Fork
- 1.4k
- Merge medio
- 21h 53m
- PR unite (30g)
- 100
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di FlashML-org/FreeToken
-
Desktop feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
FlashML-org/FreeToken#800 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
FlashML-org/FreeToken#767 ·
I maintainer di solito rispondono entro 1 giorno
-
test_gemv_path_matches_the_transcription fails on sm_120 (bf16 rounding tie exceeds the tolerance)Forse già presa @void-mckenzie l’ha presa 17 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
FlashML-org/FreeToken#649 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
FlashML-org/FreeToken#648 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
FlashML-org/FreeToken#646 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di FlashML-org/FreeToken
Issue simili
-
Add `openai_safety_identifier`, the replacement for the `user` field that `openai_user` sendsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
pydantic/pydantic-ai#12091 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Enhance blog readabilityApertaCSS enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
pychess/pychess-variants#2448 ·
I maintainer di solito rispondono entro 1 giorno
-
Bump locked PyTensor so Apple clang 21 does not pass -ld64Forse già presa @drbenvincent l’ha presa oggi. Apertabug dev ops
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni
-
ai_p2 bug comp-datalake
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
ClickHouse/ClickHouse#128306 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno