Repository navigation
Restore construction-time state after a meta-device build - #267
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
timothyngo
self-requested a review
October 15, 2026 18:24
timothyngo
reviewed
Oct 15, 2026
timothyngo
reviewed
Oct 15, 2026
timothyngo
approved these changes
Oct 26, 2026
timothyngo
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for addressing all of the comments, LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
init_weightsskipped every parameter with fewer than two dimensions, on theassumption they keep their constructor defaults. That holds for a direct build
but not after
to_empty(), which replaces every parameter and buffer withuninitialised memory. Norm weights therefore held whatever the allocator
returned.
via an explicit list (
RMSNorm,nn.LayerNorm,SigmoidTopKRouter) anddeterministic fills. Not a blanket
reset_parameters()over every module:nn.Linear's would overwrite the initialisation below and consume RNG, whichcan leave replicas disagreeing across ranks.
router's
expert_biasis one-dimensional, and itsexpert_emais a buffer— which the parameter loop could never have reached, since it only ever walked
parameters.
tp > 1issimply the only thing that currently gates that path. Pure PP, plain FSDP,
EP-only and single-GPU runs build directly on device and were never affected.
Nine shipped configs set
tp.Testing
uv run ruff check kempnerforge/ tests/passesuv run ruff format --check kempnerforge/ tests/ scripts/passesuv run pyright kempnerforge/passes (0 errors)uv run pytest tests/unit/ -v --timeout=60passesuv run torchrun --nproc_per_node=4 -m pytest tests/distributed/ -vuv run pytest tests/e2e/ --e2e -vCloses #214