fix: recognize EXL3 base layers in LoRA device detection#1712
Merged
Conversation
_get_lora_device() determines where to place LoRA adapter tensors by checking a fixed allowlist of quant-method-specific weight attribute names (weight, weight_packed, qweight, w2_weight, ..., w2_qweight). EXL3's Exl3LinearMethod stores its quantized weights under different attribute names (suh, svh, trellis, mcg, mul1), which were never added to this list, so any attempt to enable LoRA on an EXL3-quantized model fails during LoRA layer construction with: ValueError: Unsupported base layer: MergedColumnParallelLinear(...) This affects EXL3 models generally, not just GDN/hybrid architectures (see companion PR for a GDN-specific EXL3+LoRA weight-loading fix). Fix: add a branch recognizing the 'trellis' attribute. EXL3 is CUDA-only by construction (Exl3LinearMethod.create_weights raises NotImplementedError on non-CUDA platforms), and its tensors are always placed on torch.cuda.current_device() in process_weights_after_loading(), so using the current CUDA device directly is correct and avoids relying on a placeholder attribute whose .device would not reflect where the real per-shard tensors live.
AlpinDale
requested changes
Jul 16, 2026
…tion Address review feedback on dphnAI#1712 - torch.cuda usage makes hardware-agnostic inference harder to maintain.
Contributor
Author
|
Good catch, thanks — updated to use |
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
Enabling
--enable-loraon any EXL3-quantized model fails during LoRA layer construction with:Root cause
aphrodite/lora/layers/utils.py's_get_lora_device()determines where to place LoRA adapter tensors by checking a fixed allowlist of quant-method-specific weight attribute names:Exl3LinearMethod(inaphrodite/model_executor/layers/quantization/exl3.py) stores its quantized weights under EXL3-specific attribute names —suh,svh,trellis,mcg,mul1— none of which are in this list. So EXL3 + LoRA has apparently never been exercised: any EXL3 model hits thisValueErroras soon as LoRA layer wrapping runs, regardless of architecture.Fix
Add a branch recognizing the
trellisattribute.Exl3LinearMethod.create_weights()raisesNotImplementedErroron non-CUDA platforms (EXL3 is CUDA-only by construction), andprocess_weights_after_loading()always moves the per-shard tensors totorch.device("cuda", torch.cuda.current_device()). So using the current CUDA device directly is correct here — the placeholdertrellisparameter's own.devicewouldn't reflect where the real tensors actually live (they're stored in a separateexl3_tensorsdict per shard, not in the parameter's.data), so checking for the attribute's presence (to select EXL3) and then querying the current device (rather thanbase_layer.trellis.device) is the correct approach.Test plan
Verified end-to-end on
Qwen3.6-27B-exl3-3.08bpw(TP=2, RTX 5070 ×2) with--enable-lora --max-lora-rank 64: LoRA layer construction now succeeds past this point instead of raising immediately. (A separate, GDN-architecture-specific EXL3 weight-loading issue was also found and fixed — see companion PR #1711; both were needed together to get a working EXL3+LoRA launch on this architecture.)