From 43d97cb9e6c70f32d08141c9dfbcc4ad4d320977 Mon Sep 17 00:00:00 2001 From: baKon Date: Mon, 5 Oct 2026 19:42:53 -0500 Subject: [PATCH] load: a zero share is delivered from a container, and an undelivered slot refuses From a container the relayout workers are fed by the sweep over the file, and a zero share (rad_weight_shard_zero: an attention-zero rank's q|gate, k, v and o) has no bytes in the file, so nothing ever arrived for it, its worker never ran, and its slot held whatever the card had there. On a card whose freed VRAM the driver wipes that is zeros and the rank serves correctly by luck; on a card fresh from a reset ("VRAM is lost") it is garbage and every token is garbage. The checkpoint branch hands every staged weight to the workers itself, which is why the hole was never seen there. Zero shares are now handed to the workers before the sweep, and the pool's finish() refuses when any staged weight was never delivered, so a slot nothing wrote cannot serve again. Reproducer on any card: RADIANCE_POISON_ALLOC=255 with an odd world over a container (--tp 3 on a two-KV-head model). --- core/engine_bringup.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/core/engine_bringup.cpp b/core/engine_bringup.cpp index 50f74b36..bf2c9b6d 100644 --- a/core/engine_bringup.cpp +++ b/core/engine_bringup.cpp @@ -1388,6 +1388,27 @@ public: rad_stream_destroy(uplinks_[(size_t)d].st); uplinks_[(size_t)d].st = nullptr; } + /* EVERY STAGED WEIGHT MUST HAVE BEEN DELIVERED. One nothing arrived for was never laid out + * and its slot holds whatever the card had there: zeros on a card whose freed memory the + * driver wipes, which is how such a slot serves for months unnoticed, and garbage on one + * that has just been through a reset. Refusing here is what makes the hole visible. */ + if (status_ == RAD_OK && !audited_) { + audited_ = true; + int64_t undelivered = 0; + for (const StagedWeight& s : items_) + if (s.remaining > 0) { + if (undelivered < 4) + RAD_ERR("load: '%s' was staged and nothing delivered its %s: its slot was " + "never written", s.prog->weights[s.wi].name.c_str(), + humanb(s.remaining).c_str()); + ++undelivered; + } + if (undelivered) { + RAD_ERR("load: %lld staged weight(s) were never delivered; the model cannot run", + (long long)undelivered); + status_ = RAD_E_STATE; + } + } return status_; } @@ -1664,6 +1685,7 @@ private: std::vector out_; /* copies outstanding out of each sweep window */ int64_t budget_ = 0, held_ = 0, pending_ = 0, peak_ = 0; bool done_ = false; + bool audited_ = false; /* finish() runs its delivery audit once; the destructor calls it again */ std::atomic failed_{false}; int status_ = RAD_OK; }; @@ -2425,6 +2447,16 @@ int Engine::load_weights() { const auto rt0 = std::chrono::steady_clock::now(); int sw_st = RAD_OK; if (file_) { + /* A WEIGHT WITH NO BYTES IN THE FILE -- a zero share -- is one the sweep never reaches: no + * run of the container is its source, so nothing would ever arrive for it and its worker + * would never run. It is handed to the workers here, whole, and its own fill writes it + * (the checkpoint branch below does the same for every weight, which is why the hole was + * never seen there). */ + for (size_t k = 0; k < staged.size() && !pool.failed(); ++k) + if (staged[k].fill) { + pool.reserve((int)k); + pool.arrived((int)k, staged[k].remaining); + } sw_st = sweep_container(file_.get(), runs, devices, &pool, &read_bytes); } else { /* every weight to the workers, in declaration order, as fast as the budget lets them in */