dsa_score: row_part -- score one run of a step's query rows, and rebase cu for the selection after it

With `row_part` p, `score` holds R rows and row i is query row p * R + i; `q`, `q_scale` and
`gate` stay the whole step's, so a run is the unsplit op's rows bit for bit. A row past the last
sequence scores -inf, so every rank's run can be the same length whatever the step's. The optional
output `cu_part` receives cu - p * R, under which qsa_select runs over the run's own rows (pos
offset by p * R) and finds each row's sequence unchanged; qsa_select itself is untouched.

This is what an indexer split over tensor-parallel ranks by query rows needs from the op: the
scoring is the only per-row work in GLM-5.3's indexer that grows with the context.

libr4d offsets the query operands and compares row0 + r against cu; libref and libavx index the
same way. Without `row_part` nothing changes. Tests: the selftest scores each case's rows in equal
runs and holds every run to the unsplit rows' bytes and cu_part to the rebased bounds; ref_test
checks a run, a run past the step and a short query plane; r4d_emu_dsa (r4d_dsa.hip now runs on
the emulator) splits decode rows beside a prefill chunk at 2, 4 and 8 ranks, selects with the
rebased bounds and joins the runs as the all_gather does, byte for byte against the unsplit
scorer and selection, ties and signed gates included.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
NunzeandClaude Fable 5.1 authored and StillDeadcode committed 2026-10-21 15:24:05 +02:00
1 parent 5e8bae8ae6
commit afe5318259
13 files changed
+451 -47

No files matched your search

+2 -1
View File
@@ -674,7 +674,8 @@ extern "C" int r4d_shape_dsa_score(const RadParam* p, int n_p, int operand, RadO
opd_idx(S, B, pages),
opd_idx(S + 1, 0, M, -1, RAD_OPD_F_IDX_CU),
opd_idx(S, 0, 0, B),
opd((uint32_t)RAD_F32, M, B) };
opd((uint32_t)RAD_F32, M, B),
opd_none() };
R4D_PICK(l);
}
extern "C" int r4d_shape_mla_attn(const RadParam* p, int n_p, int operand, RadOpdDesc* out) {