Skip to content

[WIP] Depth-recurrent QAT: 3x4 loops, 768d, 15.6MB artifact - #51

Closed
hacksurvivor wants to merge 3 commits into
openai:mainfrom
hacksurvivor:depth-recurrent-qat
Closed

hacksurvivor wants to merge 3 commits into
openai:mainfrom
hacksurvivor:depth-recurrent-qat

Conversation

@hacksurvivor

Copy link
Copy Markdown

Summary

Depth-recurrent transformer with quantization-aware training.

Key optimizations

  • Depth recurrence: 3 shared blocks looped 4x = 12 effective layers (vs baseline 9)
  • Wider model: dim 768, 12 heads, 6 KV heads
  • Per-loop LoRA: rank-4 adapters on Q/V for loop specialization
  • QAT: STE fake-quantize in CastedLinear — minimal post-quant degradation
  • LAWA: Weight averaging during warmdown
  • fp16 tied embedding export

A10G validation (200 iterations, 1 shard)

Metric Value
val_bpb 2.0799
Post-quant val_bpb 2.0485
Artifact size 15.6 MB

Full 8xH100 multi-seed results pending compute grant.

Test plan

  • CPU forward/backward pass
  • Int8+zlib roundtrip under 16MB
  • A10G CUDA training (200 steps)
  • Full 8xH100 10-min training run
  • Multi-seed validation (p < 0.01)

Depth recurrence (3 shared blocks x 4 loops = 12 effective layers),
QAT via STE fake-quantize, per-loop LoRA adapters, LAWA weight
averaging, fp16 tied embedding export. Validated on A10G.
H100 multi-seed results pending.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c5e06c38e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1116 to +1121
lawa_state = {k: v.detach().cpu().clone().float() for k, v in base_model.state_dict().items()}
lawa_count = 1
else:
lawa_count += 1
for k, v in base_model.state_dict().items():
lawa_state[k] += (v.detach().cpu().float() - lawa_state[k]) / lawa_count

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep LAWA averaging off the CPU hot path

Once warmdown starts, this code copies the entire state_dict() from GPU to CPU and casts it to float on every step. For the default 13M-parameter model that is tens of MB of host transfer per step, and over a 400-step warmdown it turns into many GB of extra PCIe traffic and Python-side work on every rank. In the challenge’s 10-minute setting, that overhead can easily consume the remaining wallclock budget and force an earlier stop or a worse final score.

Useful? React with 👍 / 👎.

Comment on lines +898 to +901
if os.environ.get("SKIP_COMPILE", "0") == "1":
compiled_model = base_model
else:
compiled_model = torch.compile(base_model, dynamic=False, fullgraph=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make SKIP_COMPILE disable all torch.compile calls

This branch suggests SKIP_COMPILE=1 is enough to bypass Inductor, but main() still unconditionally runs torch.compile(zeropower_via_newtonschulz5) earlier at line 789. On the smoke-test machines where people set SKIP_COMPILE because compile is slow or unsupported, the script can still fail or spend a long time compiling before it ever reaches this branch, so the escape hatch is incomplete.

Useful? React with 👍 / 👎.

hacksurvivor and others added 2 commits March 19, 2026 16:10
INT8_KEEP_FLOAT_MAX_NUMEL=1M accidentally kept attention weights
(589K params) in fp16 instead of int8, inflating artifact to 17.6MB.
Fix: name-based pattern keeps only tok_emb in fp16, threshold back to
65K. Reduces raw payload from 19.5MB to 14.2MB.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- LAWA averaging now stays on GPU using lerp_() instead of copying to
  CPU every step. Eliminates PCIe overhead during warmdown.
- SKIP_COMPILE=1 now also skips torch.compile(zeropower_via_newtonschulz5)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@0hq 0hq closed this Mar 19, 2026
jzmyres pushed a commit to jzmyres/parameter-golf that referenced this pull request May 19, 2026
…ode sync

Post-production review of the three preceding commits (iter163 promotion +
cleanup openai#47 + cleanup openai#50) using coderabbit, pr-review-toolkit, and four
exploration agents found ~25 drift items that the prior cleanups missed.

iter163 correctness fixes:
  - bf16 invariant: _consistency_extend_no_grad cast Parcae coefficients
    to z.dtype so the no-grad extension target follows the same bf16
    trajectory as the actual training-time DEQ solve (was silently fp32
    because _parcae_a_bar/_parcae_b_bar return fp32). Without this, the
    consistency target was biased relative to what the model produces.
  - Split _consistency_*_loss_raw (with-grad, used in assembly) from
    _consistency_*_loss_t (detached log copy) to match the convention
    used by every other loss component.

iter163 P0 sibling-fanout DRY fix:
  - The iter163 promotion commit emitted consistency_anchor_loss /
    consistency_ext_loss to run.log but had no entries in plot_metrics.py
    parse_log, tests/test_training_contracts.py required_fields, or any
    plot fixture. Added a CONSISTENCY_LOSS_FIELDS registry in
    plot_metrics.py driving both the out-dict initializer and the parser
    loop; added the fields to the contract-test required_fields.

opg_doc.tex doc-code sync:
  - Parameter table: dropped stale router_load_cv_coef / mos_load_cv_coef
    rows (cleanup openai#50 removed the fields but left the rows with
    arithmetically wrong values); replaced with the new
    multi_k_consistency_anchor_coef / extension_coef / extension_delta
    rows (loss-form-triple-touch compliance).
  - Loss equation block: dropped the λ_rcv·CV² and λ_mcv·CV² terms that
    the cleanup commit removed from code but left in equations, while
    the prose two paragraphs later claimed they were "gone" — internally
    inconsistent.
  - Feature table: flipped deq_prefix_anchors from false to true to match
    CLAUDE.md (default-on since iter152 promotion, 2026-05-13).
  - Local Stability Guarantee section: rewrote the lip_ub_F-as-gate
    paragraphs to point at rho_F (necessary AND sufficient by
    Hartman-Grobman); annotated the historical narrative paragraphs with
    'removed 2026-05-15'.
  - Bumped document date 2026-05-06 -> 2026-05-15.

train_gpt.py docstring sweep:
  - Annotated or rewrote ~10 stale lip_ub_F / fp_bound / power_jvp_F
    references in _collect_routing_losses, _prescribe_failure_fix,
    _parcae_cycle_F, _joint_F_residual_at_saved_fp, the Hyperparameters
    Lyapunov section, and the Lyapunov FD branch comments.
  - Removed the redundant docstring bullet listing mos_load_cv_coef as a
    prescription lever (the prescription itself correctly notes the
    removal).

New audit-checklist row (the user's explicit ask for a prevention
principle): 'Removal-symmetry sweep' in CLAUDE.md. When removing a
Hyperparameter / loss term / diagnostic, the same commit MUST drop the
field from Hyperparameters + CLI + opg_doc.tex (equation AND parameter
table), annotate every train_gpt.py docstring that names the field, and
preserve intentional backward-compat parsing with a co-located comment.
The worst failure mode is removing the implementation but leaving the
equation in opg_doc.tex and a paragraph two pages later saying 'removed'
— that produces an internally contradictory paper.

Enforced by NEW tests/test_removal_symmetry.py (5 tests, all passing):
  - Greps opg_doc.tex, train_gpt.py, CLAUDE.md for an explicit ledger of
    removed names (REMOVED_NAMES tuple); asserts each occurrence is in
    an annotated 3-line context window (REMOVAL_ANNOTATIONS markers).
  - Asserts removed Hyperparameters fields are absent from the dataclass
    body.
  - Asserts iter163 log fields are in plot_metrics.py + contract test
    (the addition-direction analogue of the same DRY rule).

EXPERIENCE.md gains #removal-symmetry-sweep section with the full
incident write-up and index row.

Verification:
  - 158 tests pass across tests/ + experiments/test_*.py.
  - LaTeX compiles cleanly (pdflatex exit 0).
  - grep verification: all remaining lip_ub_* / fp_bound mentions in
    opg_doc.tex and train_gpt.py are in annotated context windows.

Simplify pass (post-review): consolidated cv_sum/mos_cv detach to single
site at assignment (removed redundant aggregation-side detach);
condensed verbose iter163 anchor-loss comment (cross-references
opg_doc.tex Section 7 instead of restating the math); merged
required/optional loss-tensor assertion loops in
test_loss_component_logging.py; replaced O(N*M) line+name scan in
test_removal_symmetry.py with a single compiled combined regex.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants