Skip to content

[peft] Optional seeded re-init in model-level init_adapter_slot - #34

Merged
yushengsu-thu merged 1 commit into
bridgefrom
multilora-seeded-slot-init
Aug 30, 2026
Merged

[peft] Optional seeded re-init in model-level init_adapter_slot#34
yushengsu-thu merged 1 commit into
bridgefrom
multilora-seeded-slot-init

Conversation

@yushengsu-thu

Copy link
Copy Markdown
Collaborator

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 through tracker.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 to reset_adapter's tracker discipline.

Tests

  • CPU (fake-adapter suite): unseeded init keeps slot weights; seeded init re-inits every layer (A re-drawn, B zero) and sets rank/alpha.
  • Single-GPU integration: same seed reproduces identical weights after arbitrary tracker advancement; different seed differs; tracker streams restored afterwards.
  • tests/unit_tests/peft/test_multi_lora_layers.py -k "ModelHelpers or GPU": 24 passed on H200 (torch 2.11, TE graph-safe tracker).
  • End-to-end: miles multi-LoRA GPU gate (2-rank keep-grads/optimizer/save-load/seeded-rebind suite) green against this branch.

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
yushengsu-thu merged commit 582783a into bridge Aug 30, 2026
3 of 4 checks passed
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.
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.

1 participant