phammminhhieu's picture
TRACE-VLA code snapshot 2026-11-22 11:47 +07: 456 canonical files + SHA256 manifest + sync report
b4396f0 verified
|
Raw History Blame Contribute Delete
9.79 kB
## SPEC β€” E1 QueST graft (registered 2026-11-18 ~18:2x, BEFORE
## any E1 code or training; arm name sera-v4-q-quest)
### Stage I β€” tokenizer (QueST-style, action-only), trained first
- Architecture (fixed): input window [32,7] of actions in the
POLICY's normalized space (MEAN_STD stats from init_skillroute
normalizer). Encoder: causal Conv1d 7->192 (k5,s1), 192->192
(k5,s2), 192->256 (k5,s2), GELU, causal left-padding (length
32->8, F=4); 1 causal transformer layer (d 256, 4 heads);
Linear 256->4; FSQ levels [8,5,5,5] -> 1000 codes, code index
= mixed radix (basis 1,8,40,200). Decoder: Linear 4->256 per
code + positional emb (8); 2-layer transformer decoder (d 256)
with 32 learned queries; Linear 256->7. Loss = L1 ONLY.
- Data: lerobot/libero rev v3.0. Train episodes = per task, all
but the last ceil(0.1*n_task) episodes (== trainer eval_split);
held-out = those last episodes. Windows fully inside an
episode; sampling uniform over (episode, start).
- Training: AdamW lr 3e-4 cosine -> 3e-5, batch 256 windows,
20,000 steps, bf16. TIMEBOX 1.5 h: step time measured at
smoke; steps trimmed to fit <= 75 min if needed (documented);
ONE documented extension allowed if recon still clearly
improving at the timebox.
- Reports: held-out reconstruction L1 (eval episodes, stride-16
windows); codebook utilization on held-out windows (stride 8):
fraction of the 1000 codes used >= 1 time + usage perplexity
exp(H(usage)); per-position utilization too.
- TOKEN-HEALTH GATE (override, from the E1 brief): held-out
utilization < 5% of codes = E1 FAIL regardless of all other
numbers. Kill: a single code > 80% of all token positions on
held-out = tokenizer collapse -> stop the leg, document, no
improvised redesign.
- After training: tokenizer FROZEN for everything downstream;
saved as quest_probe/quest_tokenizer.pt. Codes precomputed
for EVERY episode (train + eval) and every anchor frame:
32-window from the anchor, edge-padded (repeat last action)
when < 32 frames remain; int16 array [1693, max_len, 8] +
manifest, quest_probe/codes_all.npy.
### Stage II β€” policy arm sera-v4-q-quest
- Recipe = arm D exactly (init from init_quest, skillroute
mode, joint, seed 42, same data order, 10,000 micro-steps,
batch 8 x accum 4, LR peak 1e-4 warmup 200 cosine -> 1e-5,
eval_split 0.1). THE single change: the FM/action stack is
conditioned on skill tokens (below). MoE, routers, goal
branch, losses (fm + 0.01 balance + 0.0002 spec) unchanged.
- New modules (in SERAVLAV3Model; names verified byte-level
when the patch is written):
* skill_embed = Linear(4,512); skill_pos = Parameter[8,512].
Skill summary s = mean_i( skill_embed(fsq_vec_i) +
skill_pos_i ), fsq_vec = parameter-free mixed-radix decode
of the code index to its 4 FSQ values.
* skill_film = Linear(512,1024), ZERO-INIT (mirrors the goal
branch's goal_action).
* skill_prior (the prior head): ctx = Linear(1536,256) over
last_router_input (skillroute router input = [fusion
context mean 512; state 512; pooled instruction 512]);
Embedding(1000,256) + positional emb; 2-layer causal
TransformerDecoder (d 256, 4 heads, ff 1024); head
Linear(256,1000). Input seq = [ctx_token, emb(c_1..c_7)]
(length 8); outputs predict c_1..c_8. Output = logits
[B,8,1000]; prior loss = mean cross-entropy over positions.
- WHERE TOKENS ENTER (velocity_prediction, v3 override): (1)
h += s[:,None] right after the state addition, before the 4
MoE blocks; (2) after the blocks and after the goal FiLM:
gamma,beta = skill_film(s).chunk(2); h = h + gamma[:,None] *
final_norm(h) + beta[:,None]; then the velocity head.
- Train-time flow (teacher forcing): batch carries
skill_codes [B,8] (long) looked up from codes_all.npy by
(episode_index, frame_index) via a class-level __getitem__
patch inside train_q.py ONLY (repo files untouched by the
patch mechanism; the policy patch itself adds the modules +
config flags). s is computed from GT codes; the prior is
trained on the same GT codes by NLL. total = D_total +
lambda_prior * prior_nll.
- Inference flow: NO encoder, NO GT. predict_action_chunk:
prior GREEDY autoregressive decode (8 steps) from
last_router_input -> codes -> fsq decode -> s -> FM Euler
loop unchanged (4 steps, execute via select_action as usual).
- lambda_prior: initial 0.01 (at init prior NLL ~= ln 1000 ~=
6.9 -> term ~0.069, ~4% of FM ~1.7 β€” inside the program's
1-5% magnitude rule). MEASURED at smoke on real batches;
corrected BEFORE launch if the term falls outside
[0.02, 0.09]; correction documented here (arm-I precedent).
- Config: v4_quest_enabled (bool, default False),
v4_quest_lambda (float, default 0.0), validated in
__post_init__. Defaults-off must reproduce D exactly.
- Init: init_quest = init_skillroute + skill_* tensors from a
freshly constructed quest-enabled policy (fixed seed 1234
for the new modules), built by surgery script (D-init
precedent); shared tensors bitwise identical to
init_skillroute.
- Pre-launch numerical checks (check_quest.py, all must pass):
[0] flag OFF: total == fm + 0.01 bal + 0.0002 spec exactly
(diff < 1e-6) on a fixed batch, velocity output identical
to flag-off reference given identical weights + noise;
[1] flag ON: total - D-terms == lambda * prior_nll
(diff < 1e-6); [2] grads: skill_prior/skill_embed/skill_film
receive grad, tips params receive none; [3] predict path:
greedy codes deterministic across two calls, chunk
[B,16,7]; [4] record FM with GT codes vs prior codes at
init (pathway-live sanity, no threshold).
### Measurements at 2k/5k/10k (parallel with training, batch 8)
- (a) Token metrics (measure_tokens.py): ENCODER-side β€” 200
windows/task (seed 7, all episodes) -> per-task usage
histograms (pooled positions, 1000 bins): cross-task JS
(mean pairwise), cross-phase JS (phase = episode-progress
thirds of the window centre β€” HEURISTIC, labelled), unique
sequences / total. PRIOR-side β€” the standard 3,840-obs
measurement cache -> arm-Q prior greedy codes per obs ->
same stats with the manifest's task + phase labels (phase
HEURISTIC, labelled). Utilization + perplexity per
milestone (prior-side; encoder-side is frozen/constant).
- (b) Routing for the record: measure_routing.py on ckpt
2k/5k/10k -> measurement/results/q-quest-{2000,5000,10000}
.json (same P1 set; NO Stage-1 gate applies to Q β€” reported
as anatomy only).
- (c) RSA (B4, CPU-only, measure_rsa.py): Spearman rho
between pairwise token-distribution dissimilarity (JS,
prior-side and encoder-side) and pairwise verb/object
attribute dissimilarity (1 - Jaccard over the _TASK_FACTORS
verb+object sets, 40 tasks, 780 pairs). Reference only:
SkillNet SCMoE rho 0.48 vs vanilla MoE 0.08 (different
attribute system β€” not a gate).
### Closed-loop probe at 10k
- eval_v4.py on ckpt 010000, fixed 7 tasks x 10 ep, seed 0 ->
quest_probe/results/q-quest.jsonl. References: D@10k 5/70,
F1 7/70, G@10k 7/70. Reported as the closed-loop SIGNAL;
NOT a reuse gate.
### Composition test (decisive reuse test) β€” 6 audited tasks
- Set: rollout task_ids {1,3,4,6,7,8} = skill_obj_02, 04, 05,
07, 08, 09 (audit: unseen-composition; ids 0/2 = seen
duplicates, id 5 = partial-overlap β€” all excluded, matching
Test 1 of the Skill Transfer experiment). 10 ep/task = 60
ep per variant, seed 0, via rollout_skill_v4.py.
- Variant Z (zero-shot): Q ckpt 010000 as-is (tokenizer +
prior + FM frozen β€” the whole policy is frozen at eval).
- Demos for F (source/protocol locked by the earlier
experiment's preregistration): official LIBERO-Skill demos
DO NOT EXIST -> scripted oracle in sim (privileged state),
5 demos/task, each demo VERIFIED by the BDDL goal
predicate at termination (only verified demos kept; a task
with < 5 verified demos after reasonable attempts is
reported with its coverage). Demo init states = fresh
BDDL-sampled resets β€” the 10 test init states are NEVER
used as demos (preregistration rule). Demo format (npz,
same as the earlier protocol): images [T,2,256,256,3]
uint8 @10 Hz, states [T,8] raw, actions [T,7] raw,
instruction str. SOURCE (scripted oracle) declared in all
reports.
- Variant F (few-shot, prior-only): copy of Q ckpt 010000;
freeze everything except skill_prior.*; train on the demo
anchors (frames with a full 32-window ahead, stride 2):
target = frozen-encoder codes of the GT window; loss =
prior NLL only. Protocol mirrors the earlier experiment's
adaptation: 500 optimizer updates, eff batch 32 (8 anchors
x accum 4), AdamW lr 5e-5 cosine -> 5e-6, warmup 25,
seed 0. Original checkpoint never written to. Adapted
checkpoint rolled out on all 6 tasks x 10 ep.
- GATES (verbatim from the E1 brief, registered now):
* PASS-REUSE: variant Z >= 5/60 successes (monolith
reference: SERA-v2 and v3 each scored 0/30 at 5 ep/task
on this set).
* PARTIAL: Z < 5/60 but F >= 10/60 -> reuse exists but
needs prior adaptation.
* FAIL: otherwise. Token-health override: codebook
utilization < 5% on held-out windows = FAIL regardless
of other numbers.
* The 70-ep probe is reported as the closed-loop signal
against the 5/70 and 7/70 references; it is not a reuse
gate.
### Chain order + kill rules
- Tokenizer -> codes precompute -> checks -> arm Q train
(measurements in parallel) -> probe -> composition Z ->
oracle demos (built in parallel from Stage II on) -> F
fine-tune -> F rollout -> verdict. Kill: NaN/divergence,
tokenizer collapse (above), repeated OOM. If a leg is
blocked after reasonable attempts: document here and run
the legs that do not depend on it; the machine must not
idle while E1 is unfinished.