[peft] Optional seeded re-init in model-level init_adapter_slot - #34
Merged
Conversation
Slot weights currently come from construction or the previous clear's unseeded reset, so creating an adapter is not reproducible. With seed, init_adapter_slot now rebuilds the RNG-tracker streams from the seed (via tracker.add, so byte-tensor and graph-safe generator states both work), re-inits every layer's slot, and restores the streams.
yushengsu-thu
added a commit
to radixark/miles
that referenced
this pull request
Aug 30, 2026
install_adapter_slot now passes seed straight to the bridge's init_adapter_slot (radixark/Megatron-Bridge#34), which owns LoRA weight init and the RNG-tracker reseeding; the local _seeded_rng_scope dance is gone. A seed is ignored when loading a state_dict.
yushengsu-thu
added a commit
to radixark/miles
that referenced
this pull request
Aug 30, 2026
install_adapter_slot now passes seed straight to the bridge's init_adapter_slot (radixark/Megatron-Bridge#34), which owns LoRA weight init and the RNG-tracker reseeding; the local _seeded_rng_scope dance is gone. A seed is ignored when loading a state_dict.
yushengsu-thu
added a commit
to radixark/miles
that referenced
this pull request
Aug 31, 2026
install_adapter_slot now passes seed straight to the bridge's init_adapter_slot (radixark/Megatron-Bridge#34), which owns LoRA weight init and the RNG-tracker reseeding; the local _seeded_rng_scope dance is gone. A seed is ignored when loading a state_dict.
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.
What
init_adapter_slot(model, idx, rank, alpha, seed=None): with a seed, every layer's slot weights are re-initialised deterministically before the rank/alpha mask is applied. The RNG-tracker streams are rebuilt from the seed throughtracker.add(so both megatron byte-tensor states and TE graph-safe generator states work) and restored afterwards; layers draw sequentially from the reseeded streams, so a given seed reproduces the same adapter on every rank and run. Without a seed, behavior is unchanged.Why
Slot weights currently come from construction or the previous
clear_adapter_slot's unseeded reset, so creating an adapter into a reused slot is not reproducible. Miles' multi-LoRA v2 (tinker frontend, radixark/miles#2775) needs deterministic per-adapter creation and previously carried this RNG dance on its side; it belongs here next toreset_adapter's tracker discipline.Tests
tests/unit_tests/peft/test_multi_lora_layers.py -k "ModelHelpers or GPU": 24 passed on H200 (torch 2.11, TE graph-safe tracker).