runtime: an op that names no buffer is not held to the second lane's window

The window keeps lane 1's concurrent buffers live only across it. A weight read into the cache
(prefetch_beside) names no buffer, so it touches nothing the window protects: it may run on lane 1
outside the window (a DFlash2 drafter's reads come after the trunk's window), and it leaves no window
work for lane 0 to join. runtime_test covers it.

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-25 10:11:47 +01:00
1 parent c9f79c32d8
commit de53cd18c1
2 files changed
+27 -3

No files matched your search

+7 -3
View File
@@ -595,8 +595,12 @@ int Ctx::issue_body(rad_op h, const RadOperand* opd, int n_opd, int64_t n) {
: "has no device kernel for this band");
/* The second lane's window (rad_lane1_window_begin): its concurrent buffers are live only across
* it, so lane 1 runs nothing outside it, and lane 0 joins lane 1 before it runs an op outside
* it, on either side: a transient of such an op may share bytes with a concurrent buffer. */
if (program_ && program_->lane1_w1 >= 0) {
* it, on either side: a transient of such an op may share bytes with a concurrent buffer. An op
* that names no buffer (a weight read into the cache, prefetch_beside) touches nothing the window
* keeps live and has no transient: it runs on lane 1 anywhere and leaves no window work to join. */
bool names_buf = false;
for (int i = 0; i < n_opd && !names_buf; ++i) names_buf = opd[i].kind == RAD_OPK_BUF;
if (program_ && program_->lane1_w1 >= 0 && names_buf) {
const bool outside = p.order < program_->lane1_w0 || p.order > program_->lane1_w1;
if (lane_ == 1 && outside)
return abort_step_msg(h, RAD_E_STATE,
@@ -610,7 +614,7 @@ int Ctx::issue_body(rad_op h, const RadOperand* opd, int n_opd, int64_t n) {
return abort_step_msg(h, js, "joining the second lane outside its window failed");
}
}
if (lane_ == 1) lane1_pending_ = true;
if (lane_ == 1 && names_buf) lane1_pending_ = true;
/* The row's DIV on the ranged parameter held at the band's upper bound, maybe not here. */
if (ip.ranged_div > 1 && n % ip.ranged_div != 0)
+20
View File
@@ -993,6 +993,26 @@ TEST(an_op_outside_the_window_on_lane_0_joins_the_second_lane_first) {
}));
}
/* An op that names no buffer -- a weight read into the cache (prefetch_beside) -- touches nothing the
* window keeps live, so on lane 1 it runs outside the window too (a drafter's reads beside its
* all-reduces come after the trunk's window). */
TEST(an_op_naming_no_buffer_runs_on_the_second_lane_outside_its_window) {
Fixture f;
f.P.scratch_regions = 2;
rad_weight w = f.add_weight("blk.0.w", RAD_BF16, 8, 4, g_weight_bytes);
rad_op a0 = f.add_op("gemm_nt", "M", { 8192 }, { k_scr_seen0 }, { "s0" }, nullptr, {});
rad_op a1 = f.add_op("gemm_nt", "M", { 8192 }, { k_scr_seen1 }, { "s1" }, nullptr, { w });
f.P.lane1_w0 = f.P.lane1_w1 = (int32_t)a0;
CHECK_OK(f.start());
CHECK_OK(f.step(4, 0, [&](Ctx& c) {
RadOperand opd[1] = { RAD_W(w) };
CHECK_OK(c.set_lane(1));
CHECK_OK(c.issue(a1, opd, 1, RAD_N_BATCH));
CHECK_OK(c.set_lane(0));
}));
}
/* Operands are positional (spec §2.3), so a miscount is silent numerical garbage at the kernel,
* not a diagnosable failure. The runtime checks the given arity against the schema. */
TEST(operand_arity_is_checked_against_the_schema) {