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

+4 -2
View File
@@ -1748,11 +1748,13 @@ static const RadOperandSpec oMlaAttn[] = { { "q", RAD_OPD_IN, 0 },
{ "length", RAD_OPD_IN, 0 },
{ "out", RAD_OPD_OUT, 0 } };
static const RadParamSpec pDsaScore[] = { P_INT("M"), P_INT("n"), P_INT("heads"),
P_INT("blocks"), P_INT("seqs"), P_STR("dtype") };
P_INT("blocks"), P_INT("seqs"), P_STR("dtype"),
P_INTO("row_part") };
static const RadOperandSpec oDsaScore[] = {
{ "q", RAD_OPD_IN, 0 }, { "q_scale", RAD_OPD_IN, 0 }, { "gate", RAD_OPD_IN, 0 },
{ "k", RAD_OPD_IN, 0 }, { "k_scale", RAD_OPD_IN, 1 }, { "bt", RAD_OPD_IN, 0 },
{ "cu", RAD_OPD_IN, 0 }, { "nc", RAD_OPD_IN, 0 }, { "score", RAD_OPD_OUT, 0 }
{ "cu", RAD_OPD_IN, 0 }, { "nc", RAD_OPD_IN, 0 }, { "score", RAD_OPD_OUT, 0 },
{ "cu_part", RAD_OPD_OUT, 1 }
};
static const RadOperandSpec oDsaPool[] = {
{ "kg", RAD_OPD_IN, 0 }, { "ape", RAD_OPD_WEIGHT, 0 }, { "q", RAD_OPD_OUT, 0 },