Archived
R4D_DIT_SEL: a per-block window shadow for the CPU-replay bisection
The first replay verdict (dev vs ref step-0 velocity) came back decorrelated (cos -0.45, affine relFro 0.89) -- the fork is somewhere in the 50-block trunk, and the modulation interface is EXONERATED against the checkpoint (dev_mod cross-check: every block's cell = ada_w_block @ the step temb + bias, cos 1.0000, std ratio 1.000; weight order [video,text,audio] for stream cells [text,audio,video]). To say WHO diverges and WHERE, declare_dit (env-gated) now also casts the stream's first 64 rows into [L, 64, D] f32 PERSIST after every block -- the same rows and ordering point the next block's norm reads -- and the driver reads it back as dit_blk.f32. 69 MB, one cast op, no fingerprint lost: the CPU harness gained the matching window stats (win64std) + ref_blkwin. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
ea7a4e2d26
commit
c783a7cb72
4 files changed
+46
-10
No files matched your search
@@ -1053,6 +1053,8 @@ typedef struct RadVideoGenDecl {
|
||||
int64_t dbg_dit_temb_bytes;
|
||||
rad_buf dbg_dit_mod; /* modulation table (b_modg) f32, this step */
|
||||
int64_t dbg_dit_mod_bytes;
|
||||
rad_buf dbg_dit_blk; /* [n_layer, DBG_ROWS, D] f32: a row window after every block */
|
||||
int64_t dbg_dit_blk_bytes;
|
||||
} RadVideoGenDecl;
|
||||
|
||||
int rad_declare_video_generator(RadBuilder* b, const RadVideoGenDecl* d);
|
||||
|
||||
@@ -169,6 +169,8 @@ static const int kSegMod[kSegs] = { 1, 2, 0 };
|
||||
* container that carries the encoder tensors, and verify a ref-present-vs-ref-absent run differs. */
|
||||
enum { kMaxSegs = 8 };
|
||||
static const int kRefConsume = 1;
|
||||
/* Rows captured after every DiT block by the R4D_DIT_SEL window shadow (see b_dbgl). */
|
||||
enum { kDbgL = 64 };
|
||||
|
||||
/* ================================================================== geometry, on the host */
|
||||
/* diffusers' AutoencoderKLMiniMaxH3._split_tiles in latents: the first latent of each tile across
|
||||
@@ -585,6 +587,12 @@ struct Model {
|
||||
* pass so the step pass can read it back without touching the arena. [4*S, td] f32 PERSIST. */
|
||||
rad_buf b_tembd = 0;
|
||||
rad_op op_tembd = 0;
|
||||
/* The per-block window shadow: the first kDbgL rows of the stream, cast to f32 after every
|
||||
* block. A per-block std fingerprint for the CPU-replay bisection -- full [R, D] per block is
|
||||
* gigabytes; a 64-row window over a 5376-wide stream is 69 MB and plenty to tell whose forward
|
||||
* diverges first. [L * kDbgL, D] f32 PERSIST. */
|
||||
rad_buf b_dbgl = 0;
|
||||
rad_op op_dbgl = 0;
|
||||
/* The step's gathered modulation table (b_modg) cast to f32: every block's and segment's cell,
|
||||
* both ranks' column halves, the exact vectors the norms consume. PERSIST f32 twin of a bf16
|
||||
* scratch (the b_ax2 lesson). [world * L * kMaxSegs, Ws] f32. */
|
||||
@@ -1266,7 +1274,17 @@ static int declare_dit(RadBuilder* b, const RadModelMeta* meta, Model& m) {
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.b_temb }, { m.b_tembd });
|
||||
}
|
||||
if (!m.op_dh0 || !m.op_modd || (m.curve > 0 && !m.op_tembd)) return RAD_E_INVAL;
|
||||
/* The per-block window shadow: the stream's first kDbgL rows after every block. Full-width
|
||||
* per-block capture is gigabytes; a 64-row fingerprint tells whose forward diverges first. */
|
||||
m.b_dbgl = decl_b(b, nm.f("dit.blkdbg"), RAD_F32,
|
||||
{ (int64_t)L * kDbgL, D }, RAD_BUF_PERSIST);
|
||||
m.op_dbgl = rw(b, RAD_OP(b, "cast",
|
||||
RAD_PARAMS(RAD_RANGE("M", 1, kDbgL), RAD_INT("n", D),
|
||||
RAD_STR("from", "bf16"), RAD_STR("to", "f32")),
|
||||
RAD_NOWEIGHTS),
|
||||
{ m.b_ao }, { m.b_dbgl });
|
||||
if (!m.op_dh0 || !m.op_modd || !m.op_dbgl || (m.curve > 0 && !m.op_tembd))
|
||||
return RAD_E_INVAL;
|
||||
}
|
||||
/* Learn the trunk's weight format from one linear before declaring the activation code planes.
|
||||
* An int8 (W8A8) denoiser quantises its per-token activations to int8 too -- E4M3's three
|
||||
@@ -3233,6 +3251,8 @@ static int declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* c
|
||||
d.dbg_dit_mod = m.b_modd;
|
||||
d.dbg_dit_mod_bytes =
|
||||
m.b_modd ? (int64_t)gd.world * gd.n_layer * kMaxSegs * m.Ws * 4 : 0;
|
||||
d.dbg_dit_blk = m.b_dbgl;
|
||||
d.dbg_dit_blk_bytes = m.b_dbgl ? gd.n_layer * kDbgL * m.D * 4 : 0;
|
||||
}
|
||||
RAD_ARCH_TRY(rad_declare_video_generator(b, &d));
|
||||
}
|
||||
@@ -3669,6 +3689,12 @@ static void step_dit(RadCtx* c, const RadBatch* batch, const Model& m) {
|
||||
for (int h = 0; h < nh; ++h) {
|
||||
const int64_t r0 = hr0[h], n = hn[h];
|
||||
if (h > 0 && l > 0) wait_ar();
|
||||
/* The dump's per-block window (R4D_DIT_SEL): block l-1's output rows [0, kDbgL) --
|
||||
* exactly the rows and the ordering point this block's own norm reads them at, so no
|
||||
* extra lane dance is needed. */
|
||||
if (m.dit_dbg && V->step == 0 && l > 0 && h == 0 && R >= kDbgL)
|
||||
RAD_ISSUE_N(c, m.op_dbgl, kDbgL, brow_slice(m.b_ao, 0, kDbgL, D),
|
||||
brow_slice(m.b_dbgl, (l - 1) * kDbgL, kDbgL, D));
|
||||
RAD_ISSUE_N(c, B.op_mq1, n, l > 0 ? brow_slice(m.b_ao, r0, n, D) : RAD_NONE,
|
||||
l > 0 ? modh(h, l - 1, 5, 1) : RAD_NONE, modh(h, l, 0, 2),
|
||||
RAD_W(B.w_n1), segh[h], brow_slice(m.b_h, r0, n, D),
|
||||
@@ -3716,6 +3742,9 @@ static void step_dit(RadCtx* c, const RadBatch* batch, const Model& m) {
|
||||
}
|
||||
}
|
||||
wait_ar();
|
||||
if (m.dit_dbg && V->step == 0 && R >= kDbgL)
|
||||
RAD_ISSUE_N(c, m.op_dbgl, kDbgL, brow_slice(m.b_ao, 0, kDbgL, D),
|
||||
brow_slice(m.b_dbgl, (L - 1) * kDbgL, kDbgL, D));
|
||||
const char* nout = (const char*)rad_buf_ptr(c, m.b_nout) +
|
||||
(lane * m.S + V->step) * ng * 2 * D * (int64_t)sizeof(uint16_t);
|
||||
RAD_ISSUE_N(c, m.op_nout, R, brows(m.b_ao, R), mod(L - 1, 5, 1),
|
||||
|
||||
@@ -323,7 +323,8 @@ int VideoDriver::init(const Program& prog, PositionsFn positions,
|
||||
dit_vel_b_ = decl_.dbg_dit_vel_bytes;
|
||||
dit_temb_b_ = decl_.dbg_dit_temb_bytes;
|
||||
dit_mod_b_ = decl_.dbg_dit_mod_bytes;
|
||||
const int64_t sum = dit_h0_b_ + dit_vel_b_ + dit_temb_b_ + dit_mod_b_;
|
||||
dit_blk_b_ = decl_.dbg_dit_blk_bytes;
|
||||
const int64_t sum = dit_h0_b_ + dit_vel_b_ + dit_temb_b_ + dit_mod_b_ + dit_blk_b_;
|
||||
dit_host_ = static_cast<char*>(rad_dev_alloc(sum, RAD_MEM_HOST_PINNED));
|
||||
dit_dbg_ = dit_host_ != nullptr;
|
||||
if (!dit_dbg_)
|
||||
@@ -1203,10 +1204,10 @@ const RadBatch* VideoDriver::build_step(Job& j, int step) {
|
||||
if (dit_dbg_ && j.step == 0 && !small && !j.ref_wide && j.ref_tab.empty()) {
|
||||
char* p = dit_host_;
|
||||
int64_t off = 0;
|
||||
const rad_buf hh[4] = { decl_.dbg_dit_h0, decl_.dbg_dit_temb, decl_.dbg_dit_mod,
|
||||
decl_.dbg_dit_vel };
|
||||
const int64_t nn[4] = { dit_h0_b_, dit_temb_b_, dit_mod_b_, dit_vel_b_ };
|
||||
for (int i = 0; i < 4; ++i)
|
||||
const rad_buf hh[5] = { decl_.dbg_dit_h0, decl_.dbg_dit_temb, decl_.dbg_dit_mod,
|
||||
decl_.dbg_dit_blk, decl_.dbg_dit_vel };
|
||||
const int64_t nn[5] = { dit_h0_b_, dit_temb_b_, dit_mod_b_, dit_blk_b_, dit_vel_b_ };
|
||||
for (int i = 0; i < 5; ++i)
|
||||
if (hh[i] && nn[i] > 0) {
|
||||
rb_.push_back(Readback{ hh[i], nn[i], p + off });
|
||||
off += nn[i];
|
||||
@@ -1504,7 +1505,7 @@ int VideoDriver::done() {
|
||||
case RAD_GEN_PASS_VSTEP: {
|
||||
++j->step;
|
||||
if (dit_used_) {
|
||||
/* The step-0 dump landed: slab (h0 | temb | mod | vel) to raw files, plus the few
|
||||
/* The step-0 dump landed: slab (h0 | temb | mod | blk | vel) to raw files, plus the few
|
||||
* facts the driver knows (R4D_ENC_DUMPDIR; the prep script supplies D=5376 and the
|
||||
* harness .meta files). */
|
||||
char* p = dit_host_;
|
||||
@@ -1514,6 +1515,8 @@ int VideoDriver::done() {
|
||||
p += dit_temb_b_;
|
||||
dit_dump_file("dit_mod.f32", p, (size_t)dit_mod_b_);
|
||||
p += dit_mod_b_;
|
||||
dit_dump_file("dit_blk.f32", p, (size_t)dit_blk_b_);
|
||||
p += dit_blk_b_;
|
||||
dit_dump_file("dit_vel.f32", p, (size_t)dit_vel_b_);
|
||||
if (std::getenv("R4D_ENC_DUMPDIR")) {
|
||||
const std::string path =
|
||||
@@ -1526,9 +1529,10 @@ int VideoDriver::done() {
|
||||
std::fclose(f);
|
||||
}
|
||||
}
|
||||
RAD_ERR("dit_dbg: dumped step 0 -- rows %lld h0 %lld temb %lld mod %lld vel %lld",
|
||||
RAD_ERR("dit_dbg: dumped step 0 -- rows %lld h0 %lld temb %lld mod %lld blk %lld "
|
||||
"vel %lld",
|
||||
(long long)dit_rows_, (long long)dit_h0_b_, (long long)dit_temb_b_,
|
||||
(long long)dit_mod_b_, (long long)dit_vel_b_);
|
||||
(long long)dit_mod_b_, (long long)dit_blk_b_, (long long)dit_vel_b_);
|
||||
dit_used_ = false;
|
||||
}
|
||||
VideoEvent e;
|
||||
|
||||
@@ -233,7 +233,8 @@ private:
|
||||
* decl_.dbg_dit_h0 null and dit_dbg_ stays false, so a normal run never touches these. */
|
||||
bool dit_dbg_ = false;
|
||||
char* dit_host_ = nullptr;
|
||||
int64_t dit_h0_b_ = 0, dit_vel_b_ = 0, dit_temb_b_ = 0, dit_mod_b_ = 0;
|
||||
int64_t dit_h0_b_ = 0, dit_vel_b_ = 0, dit_temb_b_ = 0, dit_mod_b_ = 0,
|
||||
dit_blk_b_ = 0;
|
||||
bool dit_used_ = false; /* the running pass staged a dump */
|
||||
int64_t dit_rows_ = 0; /* packed rows R of the dumped step */
|
||||
|
||||
|
||||
Reference in new issue
Block a user