aql: no packet-header acquire on chained launches whose kernels acquire for themselves

A chained kernel that has lost its barrier bit is launched ahead of the kernels
it depends on and reads nothing until its prologue wait has passed, where it
acquires itself (and, since the previous change, empties the scalar cache). The
acquire in its packet header runs when the packet processor launches the kernel,
before the launches in front have written, so it guards nothing the kernel
reads and only holds the packet processor: on an R9700, 2.1 us per launch with
the agent-scope acquire against 1.2 us without.

rad_kernel_chain may now answer 2 (libr4d's rows do): the chained forms' acquire
covers everything they read. The loader records it (KernelRow::chain_fenced);
the engine asks rad_dev_chain_infer(2) when chaining pays and every row that can
chain, from every loaded library, says 2 (one row answering 1 keeps the acquire
on all chained packets). The backend then issues a chained dispatch without its
barrier bit with no header acquire, live and in played passes, unless the ring,
the host epoch or a copy asks for one; releases, barrier packets, plain kernels
and the prefetch stream are untouched, and a card with its arguments in VRAM
and no HDP flush register keeps the acquire. RADIANCE_AQL_CHAIN_FENCE=1 puts it
back on every chained launch.

Qwen3.8-Flash-Next IQR-V4, TP2, MTP chain 3 with coupling, ABBA over 2 pairs:
+0.75% tok/s [0.73, 0.78], all 156 texts identical. The three device tests
added before now also run with the packets unacquired, and a shipped-plugins
test requires libr4d's chained rows to answer 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Code000andClaude Opus 5.5 committed 2026-11-17 19:21:59 +01:00
1 parent 304597970f
commit 01f08152dc
11 files changed
+214 -50

No files matched your search

+7 -1
View File
@@ -43,12 +43,18 @@ extern "C" void rad_dev_host_wrote(void);
* lets a chained kernel (named r4dchain*) wait in its prologue instead of behind the barrier bit.
* Only on the AQL backend, whose queues keep the completion counter, and only where the model's
* plugin measured a gain (RadArchProbe::chain_pays): with its drafter decoding speculatively, or
* with and without one (rad_dev_chain_infer, from the engine before any row resolves). */
* with and without one (rad_dev_chain_infer, from the engine before any row resolves).
*
* rad_dev_chain_infer(2) says more: every chained form this engine can launch fences itself
* (RadKernelChainFn saying 2, abi/rad_abi.h). rad_dev_chain_unfenced then answers 1, and the
* backend issues a chained launch that has lost its barrier bit without the packet processor's
* acquire as well (aql.cpp, "the acquire of a chained launch"). */
extern "C" int rad_dev_chain_enabled(void);
/* VRAM the runtime keeps resident as queue scratch on `props`' card once a kernel with a private
* segment has run (0 on the host backend and on unified memory). Charged to the VRAM budget with
* the hardware queues. */
extern "C" int64_t rad_dev_resident_scratch_bytes(const RadDeviceProps* props);
extern "C" int rad_dev_chain_unfenced(void);
extern "C" void rad_dev_chain_infer(int pays);
/* One range of a ranged copy: `bytes` from source offset `src` to destination offset `dst`, all