Skip to content

[Proposal] Honor cfg.init_weights=False in boot_native and add bridge.init_weights() #1566

Description

@jlarson4

Proposal

Base on dev-4.x. Gate the initialize_native_model(...) call in boot on cfg.init_weights (transformer_lens/model_bridge/sources/native/__init__.py:56-62), and add a public TransformerBridge.init_weights() re-init method.

Motivation

Deprecating HookedTransformer moves train-from-scratch to boot_native, but the bridge ignores cfg.init_weights=False (randomizing weights anyway) and has no re-init entry point, breaking the load-into-empty-shell workflow.

Pitch

  • Gate initialize_native_model(...) on cfg.init_weights, keeping fork_rng for the seeded branch when init runs.
  • Add TransformerBridge.init_weights() re-running initialize_native_model in place, honoring cfg.seed.
  • Raise a clear error when init_weights() is called on a non-native (HF-loaded) bridge.

Acceptance:

  • boot_native(cfg) with init_weights=False leaves default nn.Linear/nn.Embedding reset state
  • bridge.init_weights() re-inits a native bridge in place, honoring cfg.seed
  • init_weights() on an HF-loaded bridge raises an actionable error
  • New unit tests in tests/unit/model_bridge/test_boot_native.py (skip + re-init paths). The file already exists, it just needs to be extended
  • make unit-test and uv run mypy . pass

Mirror: HT gate transformer_lens/HookedTransformer.py:254-255; HT init_weights at HookedTransformer.py:1500.

Checklist

  • I have checked that there is no similar issue in the repo (required)

Metadata

Metadata

Assignees

No one assigned

    Labels

    TransformerBridgeBug specific to the new TransformerBridge systemcomplexity-moderateModerately complicated issues for people who have intermediate experience with the codeenhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is neededv4.x

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions