diff --git a/core/runtime/issue.cpp b/core/runtime/issue.cpp index 5baf187c..154f12b3 100644 --- a/core/runtime/issue.cpp +++ b/core/runtime/issue.cpp @@ -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) diff --git a/tests/runtime_test.cpp b/tests/runtime_test.cpp index f87129c9..c01dddf9 100644 --- a/tests/runtime_test.cpp +++ b/tests/runtime_test.cpp @@ -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) {