[Bug] PyTorch engine ignores use_rslora, so rsLoRA adapters run sqrt(r) times too weak
Los mantenedores suelen responder en 2 días
@Andreas-Hum ya está trabajando en esto.
Desde el 8/11/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Empieza con get_ranks_and_scalings en lmdeploy/pytorch/adapter/adapter.py y compara su cálculo de escalado con el comportamiento de use_rslora descrito en el issue. El script de reproducción permite comprobar el escalado frente a PEFT para los rangos 16, 32 y 64; el issue indica que el escalado esperado es lora_alpha / sqrt(r) cuando rsLoRA está activado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Checklist
- 1. I have searched related issues but cannot get the expected help.
- 2. The bug has not been fixed in the latest version.
- 3. Environment info and a minimal reproducible demo are included below.
Describe the bug
The PyTorch engine ignores use_rslora in PEFT adapter configs. PEFT scales a rank-stabilized LoRA adapter (arXiv:2312.03732) by lora_alpha / sqrt(r), but get_ranks_and_scalings in lmdeploy/pytorch/adapter/adapter.py always uses lora_alpha / r. The adapter loads without any error or warning, and its update is sqrt(r) times too weak: 25% of the intended strength at r = 16, 18% at r = 32 and 12.5% at r = 64.
How common is it and what effect does it have
I sampled 756 LoRA adapters on the Hugging Face Hub for popular base models (Llama-3.1/3.2, Qwen2.5/3, Mistral-7B, Gemma-2 and their unsloth 4-bit versions; the top by downloads and the most recent). 85 of them (11%) have use_rslora: true, most with r = 32.
To test the effect I fine-tuned SmolLM2-135M-Instruct with rsLoRA (lora_alpha 16, all linear projections, Alpaca, 200 steps, 3 seeds) and evaluated it in PEFT with the correct scale and with lora_alpha / r. Held-out loss, base model 1.903:
| r | lora_alpha / sqrt(r) |
lora_alpha / r |
share of the fine-tune's improvement lost |
|---|---|---|---|
| 16 | 1.543 | 1.719 | 49% |
| 64 | 1.539 | 1.801 | 72% |
(33% is lost at r = 8.)
Possible fix
Use lora_alpha / sqrt(r) when cfg.use_rslora is set. I have a PR with a test ready.
Reproduction
import torch
from peft import LoraConfig, get_peft_model
from lmdeploy.pytorch.adapter.adapter import get_ranks_and_scalings
class Tiny(torch.nn.Module):
def __init__(self):
super().__init__()
self.q_proj = torch.nn.Linear(8, 8)
for r in [16, 32, 64]:
cfg = LoraConfig(r=r, lora_alpha=16, target_modules=['q_proj'], use_rslora=True)
peft_scale = get_peft_model(Tiny(), cfg).base_model.model.q_proj.scaling['default']
_, scalings = get_ranks_and_scalings('q_proj', [cfg])
print(f'r = {r}: LMDeploy scale = {scalings[0].item():.4f}, PEFT scale = {peft_scale:.4f}')
Output:
r = 16: LMDeploy scale = 1.0000, PEFT scale = 4.0000
r = 32: LMDeploy scale = 0.5000, PEFT scale = 2.8284
r = 64: LMDeploy scale = 0.2500, PEFT scale = 2.0000
Environment
lmdeploy main at a0102d4 (2026-11-06), PyTorch engine
Python 3.13.13, peft 0.21.2, torch 2.15.0+cpu, Linux
A full install needs nvcc, which this machine doesn't have, so I loaded lmdeploy/pytorch/adapter/adapter.py without running the package __init__. The function only depends on torch.
Error traceback
No error: the adapter loads and silently runs too weak.
- Lenguaje dominante
- Python
- Estrellas
- 8.2k
- Forks
- 797
- Merge medio
- 3 d 15 h
- PR fusionados (30 d)
- 52
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de InternLM/lmdeploy
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
Los mantenedores suelen responder en 2 días
-
[Bug] apply_rotary_pos_emb: leaves output tails unwritten with partial rotationPosiblemente ocupada @shotsan la tomó hace 15 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
[Feature] Expose `max_model_len` (session_len) in `/v1/models` model cardPosiblemente ocupada @FOWEPJF255 la tomó hace 37 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 2 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 2 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 2 días
Todos los issues de InternLM/lmdeploy
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
Techiebutler/freeframe#687 ·
Los mantenedores suelen responder en 1 día
-
bug verbose GC
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
IBM/javacore-analyser#677 ·
Los mantenedores suelen responder en 1 día
-
area/config comp/plugins P1 platform/qqbot tool/file type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
NousResearch/hermes-agent#163932 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
plugins/dsh: todayStr() computes UTC but is documented as local — journal entries written 00:00–08:00 local land in the previous day's filePosiblemente ocupada @Beehtrix la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
zilliztech/memsearch#907 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[integration]: SynapCoresAbiertoexternal
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
langchain-ai/docs#8386 ·
Los mantenedores suelen responder en 1 día