Kazeia-engine/docs/04_gdn_chunkwise.md

17 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Chantier 4 — GDN chunkwise prefill (3.5, push 93→~150)
## Base mesurée (26/05, fork ql, t8/b512/fa)
prefill plat: 93 @512, 97 @2k, 91 @8k. dense 285→182 (quadratique). croisement RAG ~24-28k. decode O(1) stable. Cible: prefill linéaire mais lent = recurrence sérielle, pas BW.
## Le kernel actuel (gated-delta-net-ops.c:573 pp_thread)
Par tête (parallèle H*n_seqs), state S×S (S_v≤128). Pour chaque token t: gate-decay des S lignes, delta=(vS·k)·β, update rank-1 S+=k⊗δ, out=S·q. = 3·S² flops/token, sériel sur n_tokens. C'est l'ancre.
## Chunkwise (delta rule, CUDA/Vulkan le font)
Chunk C=64: intra-chunk = matmuls C×S triangulaire, inter-chunk = state. Les rank-1 sériels → GEMM C×S batchables → HMX 32×32. n_tokens/64 étapes au lieu de n_tokens.
## Paliers (mesure à chaque)
1. pp_thread chunked **f32** bit-exact (réutilise cache, pas HMX). Valide ggml ref + bench. Gain cache seul?
2. inner GEMM → HMX fp16, comparer dérive vs CPU (prefill tolère, KV only). Bench 93→?
3. VTCM pour state inter-chunk (déjà au tg). Cible 150.
Risque: HMX fp16 accum non bit-exact — OK prefill (decode CPU exact). Frontière, aide partielle structure/debug.