[peft] fix: Guard dense Multi-LoRA grouped MM layouts - #5768
Merged
yaoyu-33 merged 1 commit intoAug 28, 2026
Merged
Conversation
Contributor
Author
|
/ok to test 16f0e32 |
Signed-off-by: Yu Yao <yaoyu.094@gmail.com>
yaoyu-33
force-pushed
the
yuya/landscape-multilora-grouped-mm-fallback-20260824
branch
from
August 24, 2026 19:19
16f0e32 to
d67579f
Compare
Contributor
Author
|
/ok to test d67579f |
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 does this PR do?
Guards dense Multi-LoRA's private grouped-MM calls with the installed kernel's forward/backward contract. Eligible CUDA layouts retain the grouped-MM fast path; unsupported layouts, architectures, dtypes, empty batches, and any zero-count adapter slot use per-slot
torch.nn.functional.linear.This is a narrow correctness follow-up to the supported Multi-LoRA path introduced in #4218. A downstream production report reproduced the failure at TP8 with a BF16 local rank of 2: radixark/Megatron-Bridge#32. The governing 16-byte pointer and stride requirements are defined by PyTorch GroupedMMUtils.h.
Supported trigger and impact
Dense Multi-LoRA may call the private grouped-MM operation for both A and B projections. TP can shard the physical BF16 rank to a width whose contiguous backward gradient has a row stride below the required 16-byte boundary. Misaligned views, FP32 autograd, pre-SM80 devices, empty inputs, and zero-count slots are also ineligible. Passing a mixed layout such as
[2, 0, 2]to grouped-MM can make backward unsafe before the first optimizer update.Root cause
The prior path assumed that valid logical LoRA shapes implied valid grouped-MM storage and routing layouts. PyTorch additionally requires aligned pointers, aligned batch and matrix strides, supported autograd dtypes, non-empty groups, an aligned output-gradient row stride, and an SM80-or-newer CUDA device.
Changelog
set_tokens_per_adapter_slot(), derive SP-local splits on the host, and remove per-layer.tolist()synchronization.Validation
Fail-before on
dd150c1d73ed9a25ad3ee87149cb98a0a2ca3614with production code unchanged:Pass-after with the identical command:
Correction-focused contracts:
The skipped test is the real SM80+ CUDA mixed-zero-slot backward test. The available host driver reports CUDA 12.4 and is too old for the installed PyTorch CUDA runtime, so CUDA could not initialize; no GPU result is simulated.
Focused adjacent coverage:
Additional gates:
Non-goals
Before your PR is Ready for review
Additional Information
d67579f477ad99c2ed9040eb57d9a77d408b2bf0.