Commit bd347db
feat(prefill): produce logits inside tq_forward_batch (no final tq_forward)
Big architectural improvement to the batched prefill path: the output
rmsnorm + lm_head matmul for the last batch position is now computed
inside tq_forward_batch itself, and tq_generate no longer calls
tq_forward after a successful batched prefill.
Benefits:
- One fewer full forward pass → small extra speedup for long prompts
- For DeltaNet models, avoids double-advancing the recurrent SSM state
(the root cause of the empty-output bug in the DeltaNet hybrid path)
Verified on Llama-3.2-1B/3B: outputs bit-identical to the previous
per-token-then-final-forward flow. 11/11 STRICT tests pass.
DeltaNet hybrid path (P1.6) still bails to per-token for Qwen3.5 due
to a separate FFN-handling issue in the per-token-inside-batch
DeltaNet loop that produces empty text. Gated behind
TQ_DELTANET_BATCH=1. Investigation logged in commit c6c9fda.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent c6c9fda commit bd347db
2 files changed
Lines changed: 32 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | | - | |
320 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
321 | 322 | | |
322 | 323 | | |
323 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3070 | 3070 | | |
3071 | 3071 | | |
3072 | 3072 | | |
3073 | | - | |
3074 | | - | |
3075 | | - | |
3076 | | - | |
3077 | | - | |
| 3073 | + | |
| 3074 | + | |
| 3075 | + | |
3078 | 3076 | | |
3079 | 3077 | | |
3080 | 3078 | | |
| |||
3153 | 3151 | | |
3154 | 3152 | | |
3155 | 3153 | | |
3156 | | - | |
3157 | | - | |
3158 | | - | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
3159 | 3157 | | |
3160 | | - | |
| 3158 | + | |
3161 | 3159 | | |
3162 | 3160 | | |
3163 | 3161 | | |
| |||
3566 | 3564 | | |
3567 | 3565 | | |
3568 | 3566 | | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
| 3571 | + | |
| 3572 | + | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
3569 | 3589 | | |
3570 | 3590 | | |
3571 | 3591 | | |
| |||
0 commit comments