Environment
- opacus: 1.5.4
- peft: 0.18.1
- torch: 2.11.0+cu128
- Python: 3.10
What Happened
I ran DP-LoRA fine-tuning across 6 runs (2 models × 3 epsilon values, ~45 GPU-hours
total). Training appeared completely normal throughout:
- Loss decreased as expected
- Epsilon accumulated correctly
- No errors or warnings at any point
- Checkpoints saved successfully
All 6 models were unusable at inference time.
Minimal Reproduction
from peft import LoraConfig, get_peft_model
from transformers import AutoModelForCausalLM
from opacus import PrivacyEngine
import torch, torch.optim as optim
from torch.utils.data import DataLoader, TensorDataset
model = AutoModelForCausalLM.from_pretrained("gpt2", dtype=torch.float32)
config = LoraConfig(r=16, lora_alpha=32, lora_dropout=0.0,
target_modules=["c_attn"], task_type="CAUSAL_LM")
model = get_peft_model(model, config)
optimizer = optim.AdamW(
[p for p in model.parameters() if p.requires_grad], lr=1e-4)
dummy = torch.randint(0, 1000, (4, 32))
dl = DataLoader(TensorDataset(dummy), batch_size=4)
pe = PrivacyEngine(accountant='rdp')
model, optimizer, dl = pe.make_private_with_epsilon(
module=model, optimizer=optimizer, data_loader=dl,
target_epsilon=8.0, target_delta=1e-5, epochs=1, max_grad_norm=1.0,
)
param_name = [n for n in dict(model._module.named_parameters())
if 'lora_B' in n][0]
before = dict(model._module.named_parameters())[param_name].clone()
model.train()
optimizer.zero_grad()
batch = dummy.cuda() if torch.cuda.is_available() else dummy
out = model(input_ids=batch, labels=batch)
out.loss.backward()
optimizer.step()
after = dict(model._module.named_parameters())[param_name]
print(f"Weight changed: {not torch.allclose(before.cpu(), after.cpu())}")
print(f"Max delta: {(after.cpu() - before).abs().max():.8f}")
With PEFT 0.18.1:
Weight changed: False
Max delta: 0.00000000
With PEFT 0.13.2:
Weight changed: True
Max delta: 0.00010004
The only way to detect the failure was:
- Noticing identical utility collapse across all epsilon values
simultaneously (genuine epsilon-dependent collapse would scale with ε)
- Manually comparing saved adapter weight norms against known
initialization values
- Running inference and observing broken output
Suspected Root Cause
PEFT 0.18.x changed LoRA parameter naming from lora_A.weight to
lora_A.default.weight by introducing a ModuleDict with a named
adapter key. Opacus 1.5.4 was written before this change and does not
correctly handle the new parameter structure when registering per-sample
gradient hooks via GradSampleModule.
The exact mechanism varies by architecture as some models show near-zero
updates, others show partial corrupted updates ,but all produce
unusable models.
Workaround
Confirmed working across full multi-epoch training runs on both 2 models.
Suggestion
Opacus's LoRA+PEFT tutorial should specify a compatible PEFT version,
or add a version compatibility check that warns users when an
incompatible PEFT version is detected.
Environment
What Happened
I ran DP-LoRA fine-tuning across 6 runs (2 models × 3 epsilon values, ~45 GPU-hours
total). Training appeared completely normal throughout:
All 6 models were unusable at inference time.
Minimal Reproduction
With PEFT 0.18.1:
Weight changed: False
Max delta: 0.00000000
With PEFT 0.13.2:
Weight changed: True
Max delta: 0.00010004
The only way to detect the failure was:
simultaneously (genuine epsilon-dependent collapse would scale with ε)
initialization values
Suspected Root Cause
PEFT 0.18.x changed LoRA parameter naming from
lora_A.weighttolora_A.default.weightby introducing aModuleDictwith a namedadapter key. Opacus 1.5.4 was written before this change and does not
correctly handle the new parameter structure when registering per-sample
gradient hooks via
GradSampleModule.The exact mechanism varies by architecture as some models show near-zero
updates, others show partial corrupted updates ,but all produce
unusable models.
Workaround
Confirmed working across full multi-epoch training runs on both 2 models.
Suggestion
Opacus's LoRA+PEFT tutorial should specify a compatible PEFT version,
or add a version compatibility check that warns users when an
incompatible PEFT version is detected.