the second lane's window (rad_lane1_window_begin / _end): concurrent buffers live across it, not the whole program

rad_buf_concurrent held a buffer for the whole program because the planner cannot tell when lane 1
runs. An architecture whose lane-1 work lies in one stretch of its declared ops now declares it, and
its concurrent buffers live across that window and their own uses, so the drafter's and the heads'
buffers share their bytes again. Ctx holds it: an op on lane 1 outside the window fails the step by
name, and the first lane-0 op past it joins lane 1 first when work is pending there. qwen35_fp8 and
gemma3 declare it from the embedding's all-reduce to the final norm. Qwen3.8 + DFlash2 at 64
sequences with speculation: activation arena 633.99 -> 526.32 MiB a card, upstream's exactly (with
the second lane's own scratch region, KV 86208 -> 93856 tokens against upstream's 95520).
arch_test's fake builder applies the window too, so the pinned steps check every plugin touches its
concurrent buffers only inside 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-24 11:10:08 +02:00
1 parent 0c813784a0
commit 0d2b502d51
13 files changed
+201 -6

No files matched your search

+3
View File
@@ -331,6 +331,8 @@ int Ctx::bind_ops() {
p.billed = (oi.op == "all_reduce");
p.collective = p.billed;
p.lora_site = oi.lora_site;
p.order = oi.anchor > 0 && (size_t)oi.anchor < P.ops.size() ? P.ops[(size_t)oi.anchor].index
: oi.index;
for (const Band& b : oi.bands) band_table_.push_back(b.hi);
@@ -906,6 +908,7 @@ int Ctx::lane_join(int from, int to) {
RAD_TRY(rad_event_record(lane_ev_[from], fs));
RAD_TRY(rad_event_wait(ts, lane_ev_[from]));
scratch_open_[from] = false; /* `to` is now behind every scratch user `from` issued */
if (from == 1 && to == 0) lane1_pending_ = false;
return RAD_OK;
}
+7 -1
View File
@@ -88,6 +88,9 @@ struct OpPlan {
bool billed = false;
/* Runtime LoRA: this gemm's row in Program::lora_sites, -1 for every op that is not one. */
int32_t lora_site = -1;
/* Its position in the declared order, or its anchor's for a core-appended op: what the second
* lane's window (Program::lane1_w0..lane1_w1) is checked against. */
int32_t order = 0;
};
/* ------------------------------------------------------------------ routing handoff */
@@ -619,7 +622,8 @@ private:
* 3. The buffer planner packs from one linear order, so two lanes can alias arena bytes
* through buffers with disjoint declared lifetimes. The architecture passes every buffer
* its second lane touches to `rad_buf_concurrent`, which makes it live for the whole
* program.
* program, or, where the architecture declares the second lane's window
* (rad_lane1_window_begin / _end), across the window and its own declared uses.
*
* 4. A slice must land in the same bucket-table band as the whole, or it picks a kernel with
* a different summation order and silently changes output. `--debug-graph` prints a model's
@@ -641,6 +645,8 @@ private:
bool own_lane1_ = false;
int lane_ = 0;
RadEvent lane_ev_[2] = { nullptr, nullptr };
/* An op was issued on lane 1 since lane 1 was last joined into lane 0 (the window's join). */
bool lane1_pending_ = false;
/* The last device op on each lane that touched host-domain memory. A host op runs at issue on
* this thread and must be ordered behind every earlier device op that touched the host arena;
* on each lane those complete no later than the last one. So a device op with a host-domain
+17
View File
@@ -592,6 +592,23 @@ int Ctx::issue_body(rad_op h, const RadOperand* opd, int n_opd, int64_t n) {
? "has no host kernel for this band, and the placement planner put "
"it on the host anyway"
: "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 1 is joined before lane 0 runs past it. */
if (program_ && program_->lane1_w1 >= 0) {
if (lane_ == 1 && (p.order < program_->lane1_w0 || p.order > program_->lane1_w1))
return abort_step_msg(h, RAD_E_STATE,
fmt("issued on the second lane outside its declared window (ops "
"%d..%d, this one %d): the buffers it may touch there are "
"live only across the window",
(int)program_->lane1_w0, (int)program_->lane1_w1, (int)p.order));
if (lane_ == 0 && lane1_pending_ && p.order > program_->lane1_w1) {
const int js = lane_join(1, 0);
if (js < 0)
return abort_step_msg(h, js, "joining the second lane at its window's end failed");
}
}
if (lane_ == 1) 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)
return abort_step_msg(h, RAD_E_SHAPE,