Skip to content

docs: add boot_native train-from-scratch recipe to migration guide - #1600

Merged
jlarson4 merged 2 commits into
TransformerLensOrg:dev-4.xfrom
priyanka25aug:docs/migration-api-recipes
Aug 4, 2026
Merged

docs: add boot_native train-from-scratch recipe to migration guide#1600
jlarson4 merged 2 commits into
TransformerLensOrg:dev-4.xfrom
priyanka25aug:docs/migration-api-recipes

Conversation

@priyanka25aug

Copy link
Copy Markdown

Closes #1557

The migrating_to_v3.md on dev-4.x already has 13 API migration table rows and 4 runnable prose recipes, but boot_native / TransformerBridgeConfig only appeared as a table row with no runnable before/after snippet.

This PR adds the missing ### Build a TL-native model from scratch recipe, showing the direct replacement for HookedTransformerConfig + HookedTransformer(cfg). Notes included: no HF Hub call, cfg.seed reproducibility, TypeError on legacy config objects, and bridge.init_weights() for re-randomisation.

Base branch: dev-4.x (targets the v4 preview line where the rest of the migration API section lives).

@priyanka25aug

Copy link
Copy Markdown
Author

@jlarson4 — tagging you for review when you get a chance. This adds the missing boot_native / TransformerBridgeConfig runnable recipe to the migration guide (closes #1557). CI is running on dev-4.x. No rush!

@jlarson4 jlarson4 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hey @priyanka25aug, great work on this! Just a couple small documentation items to update before I merge this. The example itself is well built, thank you for your hard work on this

Comment thread docs/source/content/migrating_to_v3.md Outdated
import. `cfg.seed` seeds the weight initialiser; omitting it lets the
global RNG advance normally. Passing a `HookedTransformerConfig` (or any
other legacy config object) to `boot_native` raises `TypeError` — construct
a `TransformerBridgeConfig` directly. To re-randomise weights after

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Under this recipe's own seed=42, init_weights() regenerates identical weights. 0 of 38 parameters changed when I ran it because it rebuilds its generator from cfg.seed. Can you please match the table row's "reinitialize in place" wording (migrating_to_v3.md line 240) and note that re-randomising needs a changed or cleared seed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 870ccb9 — switched to "reinitialize in place" wording and added a note that init_weights() rebuilds from cfg.seed when set, producing identical weights. The note now says to clear or change cfg.seed first for a genuinely fresh draw.

```

`boot_native` makes no HuggingFace Hub call and requires no `transformers`
import. `cfg.seed` seeds the weight initialiser; omitting it lets the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

HT's init_weights calls torch.manual_seed(cfg.seed) globally, while boot_native forks the RNG, so a training loop migrated verbatim silently loses reproducible data shuffling. Could this note state that difference explicitly?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Also fixed in 870ccb9 — added an explicit note that boot_native forks the RNG (unlike HookedTransformer.init_weights() which calls torch.manual_seed(cfg.seed) globally), so training loops ported verbatim will silently lose reproducible data shuffling.

…ence

Per jlarson4's feedback:
- Match 'reinitialize in place' wording from table row
- Note that init_weights() with cfg.seed set reproduces identical weights
- Note that boot_native forks the RNG (unlike HookedTransformer which calls
  torch.manual_seed globally), so ported training loops silently lose
  reproducible data shuffling
@jlarson4
jlarson4 merged commit b3093c4 into TransformerLensOrg:dev-4.x Aug 4, 2026
25 checks passed
@jlarson4

jlarson4 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Thanks for taking care of those changes! Merged now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants