gemma3: a prefill step of one sequence in two pieces, block boundaries on the second lane

qwen35_fp8's pipelined prefill on Gemma 3's MXFP4 trunk at two ranks: every block runs a piece
at a time on lane 0 (the attention over its own query bounds and positions, the GeGLU MLP), and the
work between two blocks a piece at a time on lane 1 -- the block's all-reduce at `overlap` 1, its
post-norm and the fp8 junction (the add and the next norm with its quantiser), after the last block
the add, the DFlash2 taps and the final norm. RADIANCE_GEMMA3_PIPE=0 turns it off.

- Every q|k|v and gate|up reads one shared E4M3 input pair under the pipeline (the junctions write
  it), so the second lane's buffers cost one pair, not one a linear (rad_buf_concurrent keeps them
  live for the whole program).
- A window KV group's seqused counts from its rebased first block, so the first piece's cannot be
  its position: it is the group's seqused less the second piece's rows, computed on the card by a
  new libr4d op, sub_i32 (y = x - s[0], int32; documented in OPS.md, a selftest case). The first
  try used the position and faulted on a 12k prompt past the 1024-token window.
- G3Linear and G3JunctionFP8 row-sliced forms; each block's overlap all-reduce.

Bit for bit the serial step: TranslateGemma's KL recordings at chunk 2048 and one sequence a step
(so a document's steps from 1024 rows pipeline) compare equal with the pipeline on and off. Prefill
on two R9700s, chunk 2048: 6k tokens 1.27 -> 1.21 s, 12k 2.48 -> 2.42 s; at chunk 1024 (pieces of
512) no gain, so a deployment wants 2048 (against 1024: -9 % / -7 %). arch_test: a 2048-row TP2
step runs in pieces with its collectives on lane 1 and the shared pair; RADIANCE_GEMMA3_PIPE=0 runs
it serially.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
mici81andClaude Opus 5.5 authored and StillDeadcode committed 2026-10-24 11:10:08 +02:00
1 parent 57d2cb4043
commit 73b1d039a0
7 files changed
+502 -9

No files matched your search

+3
View File
@@ -1282,6 +1282,7 @@ libref function says which (`libref/ref_audio.cpp`).
| `iota` | `M`(range) `start` `step` `period`/opt | → `y` |
| `cu_repeat` | `M`(range) `mult` | `len` → `y` |
| `int_affine` | `M`(range) `src` `mul` `add` | `x` → `y` |
| `sub_i32` | `M`(range) | `x`, `s` → `y` |
**Frames.** A lane is one piece; a frame is one step of its language model, whose branches (the
conditional first, then the unconditional) are consecutive rows, `rep` of them a lane.
@@ -1316,6 +1317,8 @@ conditional first, then the unconditional) are consecutive rows, `rep` of them a
`y[j] = (src[j] < 0 ? 0 : x[src[j]]) mul[j] + add[j]` over three lists of integers of one length
(`src` -1 a constant): the shapes and bounds a model derives from a pass's device geometry, such
as a decoder's volume at each of its scales.
- `sub_i32`: `y[i] = x[i] - s[0]`, int32: a device length less a device offset (a pipelined
prefill's first piece takes its KV group's `seqused` less the second piece's rows).
**Windows.** The denoiser runs over windows of frames, each entry of a window step a lane's latent
in a state buffer `stride` rows a lane (`lat_cu` bounds each entry's rows, `win_lane` names its