Bound DFlash SWA K/V cache to the sliding window#2064
Conversation
|
What was the cross context in these tests? I was running this query (which I tested because that was the query used to claim 4X performance improvement in the beellama repo): This produces in the range of 10k tokens. Acceptance rate is significantly higher when using a cross context of 8192 (compared to 4096 or less). In that case drafting takes up to 30% of the total time, and FA of the DFlash model is quite expensive because one cannot take advantage of the SWA to speed it up. Hence I was thinking that one will get a non-negligible performance gain by having a contiguous range for the attention mask in the DFlash SWA layers. |
|
Results:
The final output was identical in both cases, although here I only ran a simple test for each, considering the inherent noise it is similar to the results from my first prompt. |
|
What is n_max? I used 4 and from memory acceptance was around 75% for 8192 and around 60% with 2048. |
|
Only a n_max = 1, I can test it later with a larger size but initially it was |
|
I ran a new benchmark using
Also everything matched except cross_ctx |
|
So, then, if you don't see a noticeable performance gain still merge? I did a few quick tests and don't see real performance gains either. On the main branch I had profiled it, so that's how I saw the nearly 30% being taken by DFlash. This was the combination of the actual DFlash compute graph evaluation plus the time it takes to construct the cross context. I didn't do that here, but my guess is that all the gain in the DFlash evaluation is being traded against a slower cross context construction. |
|
I've made some minor architectural changes to align with what's in vLLM, but essentially I don't see why we should merge it considering there may still be undiscovered bugs. That said, if you see value in the code because it aligns with the FA and you can envision future improvements it might be worth it. |
Following #2052, this PR gives DFlash SWA layers a K/V layout bounded by
min(cross_ctx, n_swa). Full-attention layers retain the completecross_ctxhistory.This avoids exposing the wrapped full-context ring to SWA attention and makes the FA layout valid without changing model behavior.
I Validated with Gemma 4 26B IQ4_NL and Q8 DFlash draft. Each result uses 2 warmups followed by 5 measured 512-token runs:
512: main111.94 ± 1.44 t/s, PR112.58 ± 0.612048: main115.20 ± 0.52 t/s, PR115.82 ± 0.424096: main114.23 ± 0.71 t/s, PR115.12 ± 0.338176: main112.92 ± 1.12 t/s, PR113.98 ± 1.14Everything else like output, tokens count, acceptance rate match it.
@ikawrakow I didn’t notice any uplift per se, so I’m not sure if I needed more context or if it’s because the Draft model has a lower cost.