[HIP][GW] Support large context: global flash scores + raise MAX_CONTEXT to 32768

The GUI (strata-ctl agent session) sends a ~2648-token prompt plus max_new=16384;
the old MAX_CONTEXT=8192 refused it ('prompt + max_new exceeds context window'),
so the chat returned 0 tokens. Two fixes:

- Flash attention stored per-head scores[n_win] in dynamic shared memory. SWA is
  window-capped (1024) but full-attn is global, so beyond ~16K positions it
  exceeded the 64 KB LDS limit. Scores now live in a global scratch buffer
  ([n_head, n_win], allocated by the Rust wrapper, pool-reused); only the [nt]
  reduction stays in shared. Math unchanged -> parity EXACT (16 tok) preserved.
- MAX_CONTEXT 8192 -> 32768, sized for the consumer's max_new budget plus a large
  agent prompt; per-request KV (prompt+max_new) fits the 48 GiB HIP VRAM.

Verified live: 3113-token prompt -> correct 'Parigi' (finish stop). NOTE: prefill
is still sequential (~140 ms/token), so a large agent prompt takes minutes to
first token — batched prefill / prefix cache / expert-GEMV speedup is the next
(perf) step. Small prompts are fast.

Suite: workspace -D warnings green; 18 ld + 18 hip + 5 gw GPU; 5 Lean 0 sorryAx.
This commit is contained in:
adm committed 2026-12-01 18:56:50 +01:00
1 parent 7790f48c27
commit 59c41cb613
4 files changed
+38 -20

No files matched your search

+2 -2
View File
@@ -62,7 +62,7 @@ int vetta_flash_swa_gqa_decode(const float* q, const float* k, const float* v,
float scale, int swa_window, int cur_pos,
const float* rel_bias, int max_rel,
const float* sink_logit, const float* gate,
vetta_stream_t stream);
float* scores_scratch, vetta_stream_t stream);
// k_flash_swa_gqa_decode_f16: FP16 KV cache variant (strata default FP16 KV).
int vetta_flash_swa_gqa_decode_f16(const float* q, const uint16_t* k, const uint16_t* v,
@@ -70,7 +70,7 @@ int vetta_flash_swa_gqa_decode_f16(const float* q, const uint16_t* k, const uint
float scale, int swa_window, int cur_pos,
const float* rel_bias, int max_rel,
const float* sink_logit, const float* gate,
vetta_stream_t stream);
float* scores_scratch, vetta_stream_t stream);
// k_moe_router_topk: Inkling exact sigmoid router (top-K, route_scale norm).
int vetta_moe_router_topk(const float* logits, const float* bias,