Archived
qwen4exp: verify/decode pass launch order, prefetch width, chain polling, turnover slots
Lossless (no kernel arithmetic or operand change): the router weight is read beside the mixer all-reduce; k/v projections before q|gate; the indexer's keys behind the attention launches within the exact bound; verify-height prefetch at 32 workgroups (`prefetch` takes an optional `blocks` param) and the shared down arm before the routed down from 2 rows (kVerifyRows); chain waits poll by grid size (R4D_CHAIN_TINY/SMALL/MID); the mover's kept-free turnover slots follow the swaps the engine asked for (MoverConfig::turnover_adaptive) instead of a fixed 640. arch_test: new a_flash_next_decode_step_orders_its_small_launches; the pinned graph fingerprints and step hashes of qwen4exp_fp8 move (re-pinned). place_test: the adaptive turnover. r4d_selftest: the `blocks` param of prefetch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
946a6f9e2b
commit
ca7a7212ec
20 files changed
+598
-44
No files matched your search
+37
-5
@@ -8,6 +8,7 @@
|
||||
#include "../device/device.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <chrono>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
@@ -174,6 +175,12 @@ int Mover::init(const Program& prog, const Plan& plan, const MoverConfig& cfg, P
|
||||
cp.n_work = shadow + sc.n_stage;
|
||||
cp.n_turn = std::min<int64_t>(std::max(cfg.turnover_slots, 0),
|
||||
shadow * RAD_PLACE_TURNOVER_SLOTS / RAD_PLACE_SHADOW_SLOTS);
|
||||
/* Under MoverConfig::turnover_adaptive the kept-free count starts at its floor: a fresh
|
||||
* placement fills what it can at once, and the first burst of swaps lands in the shadow
|
||||
* slots and these while balance() frees the rest. */
|
||||
cp.turn_now = cfg.turnover_adaptive
|
||||
? std::min<int64_t>(cp.n_turn, std::max(cfg.turnover_floor, 0))
|
||||
: cp.n_turn;
|
||||
total_turn += cp.n_turn;
|
||||
cp.slab.init(slab_slots, sc.stride);
|
||||
total_slab += slab_slots;
|
||||
@@ -379,9 +386,10 @@ int Mover::init(const Program& prog, const Plan& plan, const MoverConfig& cfg, P
|
||||
republish(u);
|
||||
}
|
||||
|
||||
RAD_INFO("mover: %lld slab slots (%lld shadow, %lld more kept free out of a loan), %lld pinned "
|
||||
"pool slots, %s static vram%s",
|
||||
(long long)total_slab, (long long)total_shadow, (long long)total_turn,
|
||||
RAD_INFO("mover: %lld slab slots (%lld shadow, %s%lld more kept free out of a loan%s), %lld "
|
||||
"pinned pool slots, %s static vram%s",
|
||||
(long long)total_slab, (long long)total_shadow, cfg.turnover_adaptive ? "up to " : "",
|
||||
(long long)total_turn, cfg.turnover_adaptive ? " as swaps ask for them" : "",
|
||||
(long long)total_pool,
|
||||
humanb(static_bytes_).c_str(), file_.ok() ? ", file tier open" : "");
|
||||
/* The pageable region is charged to no budget, so this is the only place it is reported. */
|
||||
@@ -1126,7 +1134,13 @@ int Mover::issue(const Swap& s, HeatEngine* heat) {
|
||||
|
||||
if (promote) {
|
||||
const int64_t slot = cp.slab.take();
|
||||
if (slot < 0) { ++stats_.starved_slab; return false; }
|
||||
if (slot < 0) {
|
||||
++stats_.starved_slab;
|
||||
/* The slots kept free were too few for this step's swaps: all of them, for a
|
||||
* while (balance). */
|
||||
if (cfg_.turnover_adaptive) turn_boost_ = kTurnBoost;
|
||||
return false;
|
||||
}
|
||||
if (promote_to(unit, slot) < 0) { cp.slab.add_free(slot); return false; }
|
||||
return true;
|
||||
}
|
||||
@@ -1625,7 +1639,19 @@ int Mover::balance(HeatEngine* heat, bool turnover) {
|
||||
if (unit_[(size_t)m.unit].klass != (int32_t)c || !cp.slab.covered(m.slab_slot)) continue;
|
||||
if (m.frees_slab()) ++pending;
|
||||
}
|
||||
const int64_t turn = turnover ? cp.n_turn : 0;
|
||||
if (cfg_.turnover_adaptive) {
|
||||
/* Three steps of the mean swaps a step (a swap holds its slot about three steps,
|
||||
* RAD_PLACE_TURNOVER_SLOTS), between the floor and the configured count; all of
|
||||
* them while a starved promotion is recent. The mean is over every class, so a
|
||||
* class keeps a little more than its own share asks for. */
|
||||
const int64_t floor_ = std::min<int64_t>(cp.n_turn, std::max(cfg_.turnover_floor, 0));
|
||||
const int64_t want = turn_boost_ > 0 ? cp.n_turn : std::min<int64_t>(
|
||||
cp.n_turn, std::max<int64_t>(floor_, (int64_t)std::lround(3.0f * demand_mean_)));
|
||||
cp.turn_now = want >= cp.turn_now ? want : std::max(want, cp.turn_now - kTurnShrink);
|
||||
} else {
|
||||
cp.turn_now = cp.n_turn;
|
||||
}
|
||||
const int64_t turn = turnover ? cp.turn_now : 0;
|
||||
int64_t short_by = cp.n_work + turn - (cp.slab.n_free() + pending);
|
||||
if (short_by > 0) {
|
||||
drop_cand_.clear();
|
||||
@@ -1683,6 +1709,12 @@ int Mover::balance(HeatEngine* heat, bool turnover) {
|
||||
return flush_moves();
|
||||
}
|
||||
|
||||
void Mover::swap_demand(int64_t proposed) {
|
||||
if (!cfg_.turnover_adaptive) return;
|
||||
demand_mean_ += ((float)std::max<int64_t>(proposed, 0) - demand_mean_) / kTurnMean;
|
||||
if (turn_boost_ > 0) --turn_boost_;
|
||||
}
|
||||
|
||||
int Mover::idle_tick(HeatEngine* heat) {
|
||||
if (!plan_ || !plan_->dynamic) return RAD_OK;
|
||||
RAD_TRY(retire(heat));
|
||||
|
||||
Reference in new issue
Block a user