core: the second lane's scratch region sized by the ops it may issue

A program naming a buffer to rad_buf_concurrent got two scratch regions of the program's largest kernel
scratch each, though by Ctx::lane1_ rule 3 an op on the second lane touches only rad_buf_concurrent
buffers. Program::scratch_bytes_lane1 is the largest device scratch of such an op (or one naming no
transient buffer); the Arena takes per-region sizes, arena_plan_bytes counts them for the VRAM budget,
and Ctx::issue refuses a larger lane-1 request by name instead of overrunning the region. Qwen3.8 with
its drafter: region 1 0 B instead of 50 MiB (17 MiB without speculation).

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 5838c25343
commit 0c813784a0
8 files changed
+125 -15

No files matched your search

+11 -4
View File
@@ -153,13 +153,20 @@ int Ctx::bind_arena() {
int64_t dev_bytes = 0, total = 0;
arena_plan_bytes(P, &dev_bytes, &total);
RAD_TRY(arena_.init(dev_bytes, P.scratch_bytes, RAD_MEM_DEVICE, std::max(P.scratch_regions, 1)));
RAD_TRY(arena_.init(dev_bytes, P.scratch_bytes, RAD_MEM_DEVICE, std::max(P.scratch_regions, 1),
P.scratch_bytes_lane1));
/* The arena is in no pool and scales with max_tok, so core/mem/vram_budget.cpp charges it by
* name rather than leaving it to --gpu-headroom-mib. This log line must agree with that
* charge. */
RAD_INFO("arena: %s device + %d x %s scratch = %s, charged to the VRAM budget before it was "
"split", humanb(dev_bytes).c_str(), arena_.scratch_regions(),
humanb(P.scratch_bytes).c_str(), humanb(total).c_str());
if (arena_.scratch_regions() > 1)
RAD_INFO("arena: %s device + %s scratch + %s for the second lane = %s, charged to the VRAM "
"budget before it was split", humanb(dev_bytes).c_str(),
humanb(P.scratch_bytes).c_str(), humanb(arena_.scratch_bytes(1)).c_str(),
humanb(total).c_str());
else
RAD_INFO("arena: %s device + %s scratch = %s, charged to the VRAM budget before it was "
"split", humanb(dev_bytes).c_str(), humanb(P.scratch_bytes).c_str(),
humanb(total).c_str());
if (host_hw > 0) {
/* RAD_MEM_HOST_MAPPED, not RAD_MEM_HOST: nothing copies between the two arenas, so device