devnull37 commited on
Commit
77414ce
Β·
verified Β·
1 Parent(s): a506c6a

Upload DIMBA_REBUILD_SPEC.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. DIMBA_REBUILD_SPEC.md +84 -0
DIMBA_REBUILD_SPEC.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DIMBA rebuild spec β€” full fixes + plan
2
+ **3 Jul 2026.** Everything learned from the $358 budget28 run, its post-mortem (docs/ROOT_CAUSE_BUDGET28.md), the repair session (~$31), and the repo audit β€” as a clean-rebuild checklist. Ordered by importance within each section.
3
+
4
+ ---
5
+
6
+ ## 1. Objective / loss fixes (the proven root cause)
7
+
8
+ **1.1 min-SNR floor: 0.5, not 1e-3 β€” as the DEFAULT.**
9
+ `weight = clamp(snr_flow, min=0.5, max=5.0)`. The old floor (1e-3) removed all gradient pressure at high t, so the model converged to a noise-independent blend exactly where every generation starts (t=1.0). In the current repo the fix exists but is opt-in (`snr_floor` param, trainer.py:117) β€” every call site except `repair_finetune.py` still trains broken. In the rebuild: make the fixed behavior the only behavior. *Validated: this + 1.2 took an overfit probe from unigram soup to locally-coherent text.*
10
+
11
+ **1.2 CE anchor must fade with noise.**
12
+ `ce_loss = (ce_per_sample * (1 - t)).mean()`. Unweighted CE at t=1.0 has the marginal token distribution as its optimum β€” it literally *teaches* unigram output at pure noise. Default-on.
13
+
14
+ **1.3 Timestep sampling: 50/50 uniform + logit-normal.**
15
+ Logit-normal alone undersamples tβ‰ˆ1, so the dead zone gets almost no training coverage even with a fixed loss. Cheap, keep it.
16
+
17
+ **1.4 SFT loss: response-CE at uniform t + snr-floored latent MSE anchor on the diffuse mask** (commit 1d6ee9e in the old repo). Without the anchor, SFT unpins the flow-ODE geometry at high t that 1.1–1.3 bought.
18
+
19
+ **1.5 Classifier-free guidance (NEW β€” likely the missing "commitment" piece).**
20
+ Train with prompt dropout (~10% of batches get a null/empty prompt), sample with guidance scale ~2–4: `v = v_uncond + sΒ·(v_cond βˆ’ v_uncond)`. The SFT-repaired model's exact failure was *no mode commitment* β€” prompt-relevant texture but never an answer. CFG is the standard diffusion mechanism for forcing commitment to the conditioning signal, and DIMBA never had it. Cheap to add, high expected value.
21
+
22
+ **1.6 Self-conditioning (NEW).**
23
+ On 50% of training steps, run one no-grad forward, feed the resulting x0Μ‚ back as an extra input channel for the graded step. Standard in continuous text diffusion (Analog Bits, CDCD) precisely because it dramatically improves sample commitment/quality at small scale. If DIMBA lacks it, add it.
24
+
25
+ ---
26
+
27
+ ## 2. Distillation pipeline fixes
28
+
29
+ **2.1 Keep KD on through stage 3.** `kd_weight` annealed 1.0β†’0.3 over the run, never 0. Teacher forward on the same batch, KL from teacher logits into the student's x0-logits. The original run had the teacher connected for 1,000 of ~855k steps β€” 99.9% of the $358 was from-scratch diffusion pretraining at 135M, which cannot work. Currently `kd_weight=0.0` is still the default in every preset (train_4090.py:174,180; train_h100.py:196,292). *(Untested at scale β€” today's optional KD run is the cheap test.)*
30
+
31
+ **2.2 Stage 1/2 alignment: run to convergence, not a fixed 500 steps.**
32
+ β‰₯5–10k steps each, stop on flattening of the alignment loss. Stage 2 ended at 0.556 last time β€” visibly unconverged β€” and it was the only bridge across the ARβ†’diffusion gap.
33
+
34
+ **2.3 BLOCKING coherence gates between every phase.**
35
+ Generation-based, not loss-based: sample N=16 fixed prompts with the production sampler, score the outputs with teacher PPL, hard-assert a threshold or abort the pipeline. The warnings already exist as log lines (train_4090.py:1149, 1399: "SFT cannot fix an incoherent base", "GRPO cannot bootstrap…") β€” they fired last time and the run proceeded anyway. Losses looked healthy at every stage of a run that produced an unusable model; only generations tell the truth.
36
+
37
+ **2.4 Plateau early-stop in stage 3.**
38
+ Stop when loss improvement < Ξ΅ over a sliding window. Budget28's stage-3 loss converged at ~1.6B of 28B tokens; ~93% of stage-3 compute was spent flat. Would have refunded ~$300.
39
+
40
+ **2.5 Per-t-bucket loss logging.**
41
+ Log the *unweighted* diffusion loss separately for t-buckets (e.g. [0, .3), [.3, .7), [.7, .9), [.9, 1.0]). The aggregate min-SNR-weighted loss is dominated by mid/low-t and mathematically cannot show a dead high-t region β€” that's why babysitting missed it for 28B tokens.
42
+
43
+ **2.6 Partial-noise recovery ladder as a standard periodic eval.**
44
+ The diagnostic that found the root cause: noise a held-out row to t_start ∈ {0.3, 0.7, 0.9, 1.0}, integrate the ODE to 0, report token recovery. Run every ~5k steps. A cliff between 0.9 and 1.0 = objective broken; catch it in the first $5, not after $358.
45
+
46
+ **2.7 Free-generation probes in the training log** (repair_finetune.py already does this β€” 2 prompts every EVAL_EVERY steps, decoded into the log). Make it standard in every trainer.
47
+
48
+ ---
49
+
50
+ ## 3. Code hygiene
51
+
52
+ **3.1 One shared checkpoint loader.** The 49152β†’49154 (block-CoT think tokens) vocab mismatch is hand-patched with `strict=False` in 9+ scripts; `generate.py` can silently construct a *random* model when keys mismatch. The loader should: read config from the checkpoint, adopt the checkpoint's actual embedding rows, load strict, and hard-fail on any missing key.
53
+ **3.2** Fix `trust_remote_code` dataset loads in the GRPO data path (Bespoke-Stratos-17k errors β€” non-fatal but noisy and skips data).
54
+ **3.3** Kill hardcoded paths / dead code flagged in the audit (`/root/dimba_repo_audit.md`).
55
+ **3.4** Sampler entry point should assert the checkpoint's training family (flow vs DDPM) instead of letting you sample a flow model with a DDIM schedule.
56
+
57
+ ---
58
+
59
+ ## 4. Strategy: the actual rebuild path
60
+
61
+ **Recommended: Plan A β€” pretrained Mamba init, one gap at a time.**
62
+
63
+ - **Phase 0 β€” infra ($0):** implement Β§1–§3 in the clean repo. Contract tests: overfit-8-sentences must pass free generation; partial-noise ladder must show no cliff.
64
+ - **Phase 1 β€” base model ($0):** take `state-spaces/mamba2-130m` (pretrained AR Mamba-2). Bidirectionalize (init forward+backward directions from the AR weights). Keep its tokenizer. *(Alternative Plan B: MOHAWK-distill SmolLMβ†’AR Mamba yourself, 3–5B tokens β‰ˆ $15–25, verify it generates coherent text, then proceed β€” pick this only if you need the SmolLM tokenizer/quality.)*
65
+ - **Phase 2 β€” diffusion conversion, validation slice (~$10):** 1–2B tokens with the full fixed objective (Β§1), KD from the original AR Mamba (Β§2.1), all gates and evals (Β§2.3–2.7) on. **Hard gate:** free generations must show phrase-level coherence and the ladder must be cliff-free, or stop and rethink β€” do not scale a run that fails here.
66
+ - **Phase 3 β€” diffusion conversion, full (~$60–120):** 10–20B tokens only after Phase 2 passes. Early-stop on plateau.
67
+ - **Phase 4 β€” SFT (~$10–15):** fixed SFT loss (Β§1.4) + CFG prompt-dropout data. Gate: fixed prompts must get *answered*, even badly.
68
+ - **Phase 5 β€” RL (~$10, optional):** GRPO only if Phase 4's policy produces parseable answers at >0 rate; otherwise there is no reward gradient (proven twice now).
69
+ - Total: **~$100–170**, roughly a third of budget28, with 5 abort points instead of 0.
70
+
71
+ **Seriously consider before committing: switch to masked *discrete* diffusion (MDLM / LLaDA-style) instead of continuous-latent flow.** Continuous-latent text diffusion at 135M is the hardest known regime for this task β€” the t=1.0 "posterior mean blend" pathology and the commitment problem are both *inherent* to the continuous parameterization, which is exactly where both of our failures live. Masked discrete diffusion demonstrably produces coherent text at small scale, keeps the bidirectional Mamba backbone, and makes Β§1.1/1.2 moot (no SNR weighting, CE-native objective). Bigger rebuild, but it removes the two failure modes instead of patching them.
72
+
73
+ **Scale honesty:** budget28 + the recovery session validated one negative jointly: *135M continuous diffusion + ≀$400 does not produce a QA-capable model*, even with a perfect denoiser as the starting point. If the goal is a model that answers questions, either the discrete-diffusion switch or ~350M+ params should be part of the plan.
74
+
75
+ ---
76
+
77
+ ## 5. Assets that survive (private HF repo `devnull37/d1-135m-28b`)
78
+
79
+ | File | Use in rebuild |
80
+ |---|---|
81
+ | `repaired_final.pt` | Best continuous-diffusion checkpoint (perfect denoiser t≀0.9 on unseen text). Init for any continuation of Plan-continuous. |
82
+ | `budget28_distill_final.pt` | The collapsed original β€” negative-control / ablation baseline. |
83
+ | `sft_repaired_final.pt`, `budget28_sft_final.pt`, `budget28_grpo_final.pt` | Forensics only. |
84
+ | `ROOT_CAUSE_BUDGET28.md` | The full experiment chain (overfit contract β†’ clamp β†’ partial-noise ladder) β€” reuse these diagnostics as the Phase-0 contract tests. |