Skip to content

specs/ml/optimizer/adamw.t27 contains two complete copies of the AdamW module #2807

Description

@gHashTag

Found while classifying the conflicted type names for #2774 (see #2806). AdamWConfig was the one DRIFT row whose two definitions live in the same file — and reading it showed the duplication is not one struct. It is the whole module.

Two independent accounts, and they agree

By top-level name. 1019 lines, 18 names defined twice at module scope:

AdamWConfig             28  483      compute_bias_correction  93  544
AdamWState              38  493      compute_update          117  560
OptimizerStepResult     46  501      apply_weight_decay      111  556
init                    59  513      amsgrad_update          131  573
step                    68  521      update_first_moment      99  548
DEFAULT_LEARNING_RATE   15  420      update_second_moment    105  552
DEFAULT_BETA / _EPSILON / _WEIGHT_DECAY / _AMSGRAD / PHI ...

By section banner — an independent signal that does not go through the name scanner:

 11:  // 1. Constants        414:  // 1. Constants
 25:  // 2. Types            470:  // 2. Types
 54:  // 3. Core Functions   509:  // 3. Core Functions

Across all of specs/, exactly one other file repeats a section banner (specs/nn/attention.t27, one banner) and it has no duplicated top-level names — a second distinct module in one file, not a copy. adamw.t27 is the only file where both signals fire.

Which copy is which

The second copy is the newer design. It replaces use_phi_betas : bool with phi_variant : PhiVariant, and adds the four ablation arms:

Canonical   beta1=phi^(-1)~0.618, wd=phi^(-3)~0.236   (trainer default)
Damped      beta1=0.9/phi~0.556,  wd=0.01
TunedStd    beta1=0.9,            wd=0.01             (AdamW control)
RandomRat   beta1=4/7~0.571,      wd=7/30~0.233       (non-Fibonacci control)

Both copies carry their own test blocks, and the two sets disagree: line 234 has given config = AdamWConfig{.use_phi_betas = true}, line 973 has AdamWConfig{.phi_variant = PhiVariant.Canonical}.

Why it matters

t27c parse keeps both — the AST holds four use_phi_betas and six phi_variant. Zig generation succeeds (37 KB, exit 0); the Zig tests then fail. Whether the duplicate declaration is the cause of that failure has not been measured, and is not claimed here.

What is certain is that any consumer resolving AdamWConfig in this module gets whichever copy its traversal reaches first, and nothing anywhere reports that a choice was made.

Not fixed here, deliberately

Deleting ~470 lines means deciding which copy is canonical, and the newer one carries the φ-variant ablation arms that research claims stand on. That is the owner's call, not a cleanup.

One number withdrawn

An earlier pass of this report claimed 91 files with repeated definitions. That was a scanner artifact: the pattern matched const a = ... inside Zig test bodies, which sit at the same indentation as top-level declarations. specs/numeric/gf16.t27 looked like the worst offender at 561 "extra definitions" and has zero — it has 110 test blocks that each open with const a. The corpus-wide number is withdrawn; only adamw.t27, read directly, survives.

Refs #2774

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions