Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

perf(qsa): prefill indexer scoring pads 4 heads to 16 per row; 16-row tiles are ~5x faster and bitwise identical

Aperta
#783 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, pytorch

Direzione di ricerca

Start with python/freetoken/kernel/triton/qsa/score.py and _qsa_mqa_paged_kernel, then trace its prefill and decode callers in attention/qsa_sparse.py. The proposed change needs a prefill tile map built from qo_indptr, reused across QSA layers, while decode and CUDA graph capture keep the current kernel. Done means matching score bits and qsa_block_topk selections on the listed ragged, partial, sliced, and long-context cases, with the reported prefill speedup.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happened

In prefill, the QSA indexer score kernel (_qsa_mqa_paged_kernel) runs one query row per program and pads the 4 index heads to MAX_N = 16. So most of each tl.dot is padding. On Qwen3.8-Flash-Next it takes 196-200 ms of every 4096-token prefill chunk at a 249K context, 14.5-15% of the chunk on an RTX 5080.

Proposal

For prefill only, give each program 16 query rows of one request × 4 heads. That is N = 16 with no padding: one dot per head, summed over the heads in the same order as today.

  • Tiles are cut at request boundaries, using a tile map built from qo_indptr on the host and cached across the 12 QSA layers.
  • Decode and CUDA-graph capture keep the current kernel.

Each output is still a single K=128 dot followed by the same head-sum order, so the scores are bitwise identical. Checked as int32 bits on ragged multi-request batches, partial tiles, mid-forward row slices and a 249K slice. qsa_block_topk selects identical blocks. Changing the head-sum order makes the check fail, so it does detect order differences.

Measured on an RTX 5080 (sm_120) with production flags, 2 interleaved rounds:

current 16-row tiles
score kernel per 4K chunk at 249K 196-200 ms 38 ms
microbench, one 4096-row chunk at 249K context, per layer 18.47 ms 3.24 ms
cold TTFT 249K 85.5 s 83.5 s

The end-to-end gain here is small because this box streams MoE experts over PCIe and late chunks are copy-bound. On a setup where prefill is compute-bound, the score kernel is a larger share.

Cause (current main, cc56b6bd)

python/freetoken/kernel/triton/qsa/score.py: _qsa_mqa_paged_kernel launches one program per query row, with the head axis padded to MAX_N. It is called from attention/qsa_sparse.py for prefill and decode alike.

Environment

RTX 5080 16 GB (sm_120, driver 615.78.08), torch 2.14.1+cu130, Triton 3.8.0, nvidia/Qwen3.8-Flash-Next-NVFP4, main cc56b6bd.

Lingua principale
Python
Stelle
14.2k
Fork
1.4k
Merge medio
21h 17m
PR unite (30g)
97

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di FlashML-org/FreeToken

Tutte le issue di FlashML-org/FreeToken

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.