Both fixes seem to have landed on main, so here are a few additional checks I ran:
I confirmed the 3-D parameter-targeting issue in the actual PEFT runtime and the documentation issue in two release source trees. One additional symptom: after temporary LoRA parametrizations accumulated, disabling the adapter did not recover the original parametrized-base output.
For anyone coming across this thread later, there is a distinction between the released package and main. PEFT 0.22.0 was released on November 19, 2026. Both relevant PRs were merged on November 25, after that release:
- #4214 addresses temporary LoRA proxy removal on an already-parametrized 3-D weight (#4162).
- #4210 synchronizes documented argument names with actual signatures, including the four reported functions and additional classes (#4216).
The release listing and PyPI still showed 0.22.0 when I checked on November 27. Here are the CPU results from that released package. The right column uses a local diagnostic change to the cleanup predicate, not the exact merged PR commit.
| Check in the small PEFT 0.22.0 model |
Unmodified |
Local cleanup change |
| Parametrization counts after three successive forwards |
2, 3, 4 |
1, 1, 1 |
| Max absolute difference, first vs third output |
3.11147547 |
0 |
| Count after a subsequent intentional forward exception |
5 |
1 |
| Max absolute difference, adapter disabled after exception vs original parametrized base |
6.22295094 |
0 |
| Original parametrization object retained after ordinary forwards |
Yes |
Yes |
| Cleanup warnings |
4 |
0 |
For the second finding, all four reported docstring mismatches were visible in the source trees of both 0.21.3 and 0.22.0. The agreement with the original measurements is in the failure mechanism and the observed contracts, not necessarily in the numerical magnitude of the output drift in different fixtures.
The short practical route
For the first issue, start with a fixed-input test on a fresh model: a named 3-D parameter, an existing PyTorch parametrization, and the temporary factors-proxy path. Compare the original parametrized base, enabled outputs, and the disabled output; inspect the chain immediately outside each call.
My default would be a compatible release or pinned revision containing #4214 and a clean reconstruction. A growing residual proxy list points directly to #4162; a stable list with varying outputs calls for other checks. Preventing accumulation and recovering an affected instance are separate. For the documentation issue, inspect the actual signature and matching source version.
An intentional exception is a useful extra check on a disposable fixture, not a live model.
1. Additional runtime observations on an already-parametrized 3-D weight
Test conditions and sequence
The HF-879 check illustrates the accumulation; the Desk reports a separate 0.21.3 package run with four entries and a gap of about 2.5205317. My fixture deliberately uses P(w) = 2 * w so losing the original parametrization is numerically observable.
| Item |
Actual-package test condition |
| PEFT |
0.22.0 |
| Transformers / Accelerate |
5.24.0 / 1.16.0 |
| PyTorch |
2.14.1+cu130 |
| Python |
3.13.16 |
| Device |
CPU (CUDA unavailable to this worker) |
| Seed / Torch threads |
1234 / 1 |
| Weight / input shape |
(4, 8, 8) / (4, 5, 8) |
| Weight initialization |
randn(...) * 0.1 |
| Base calculation |
torch.bmm(x, weight) |
| Existing parametrization |
2 * w |
| LoRA config |
r=2, target_parameters=["experts.weight"], target_modules=[], init_lora_weights=False |
Fresh models used the same construction, default training mode, no stochastic base operation, zero LoRA dropout, and no optimizer updates. The reference was recorded after installing the original transformation but before injecting PEFT.
The test sequence was:
- Construct the parametrized base and record its output for the fixed input.
- Inject one LoRA adapter. Call the model three times, retaining the outputs and counting the entries after each call.
- Make the underlying expert module raise a known exception on a fourth call, turn off the failure flag, and inspect the list.
- Evaluate the same input with the adapter disabled and compare with the reference from step 1.
- Run a backward smoke test on the retained third enabled output.
The fourth call deliberately failed after three ordinary calls. The count of five includes the three earlier residual entries. Both runs retained the original object as the first entry after ordinary forwards; the rest of the chain matters too.
What the numerical result establishes
The unmodified gaps were 3.1114754676818848 and 6.2229509353637695, finite but not close (atol=1e-5, rtol=1e-4). Both candidate gaps were zero and close. The warning count, structural result and output comparison agree.
The disabled baseline already includes 2 * w. Removing the whole chain could produce a stable but incorrect result. Residual proxies explain the disabled-output discrepancy without assuming a permanent write to the raw base tensor.
Backward used the retained third enabled output. Both runs recorded finite adapter gradients: absolute sums A/B about 32.356503/47.865810 unmodified versus 4.445920/6.043941 candidate. The unmodified trainable-parameter report also contained a finite gradient on parametrizations.weight.original (sum 28.697033), absent in the candidate report. This does not establish an optimizer update, gradient parity or checkpoint corruption; finite gradients alone are not a pass criterion.
A separate component-level check
In a separate extracted-function PyTorch 2.10.0+cpu fixture, both release implementations left four entries after three contexts (one with a deliberate exception), versus one after the predicate change. Original transformation and underlying parameter identities were preserved. Its first/last gap was about 0.4000000954 vs zero; post-context reference gap 0.6000001431 vs zero.
Those were component tests, not additional complete-package runs of 0.21.3.
The extra evidence here is the failed call plus disabled/reference comparison. No long training, historical checkpoint, memory-growth, model-quality or independent enabled-delta parity test was performed.
2. Why the proxy can remain registered, and the scope of the merged fix
The lifetime contract
An expert may store several weights in one parameter rather than expose individual nn.Linear modules. PEFT target_parameters targets that parameter through ParamWrapper.
PyTorch parametrizations compose transformations on an underlying parameter; registration creates the exposed attribute. A legitimate existing transformation is not a bug.
For original weight W, existing transform P and temporary LoRA transform F, the enabled computation uses F(P(W)); outside the call the reference is P(W).
In the v0.22.0 LoRA layer implementation, the relevant sequence is:
- An active, unmerged
ParamWrapper.forward enters _activate_lora. Disabled and merged states follow other paths.
_activate_lora filters active adapters to those applicable to the layer. One applicable adapter, a multi-expert parameter (num_experts > 1) and a dtype not requiring the upcast path select _LoraFactorsProxy; the other path materializes a delta and uses _LoraParameterProxy.
- The temporary parametrization is registered alongside the existing one(s), and the base calculation takes place inside a parametrization cache context.
- On leaving the context, including when its body raises, the implementation calls
_remove_parametrizations. With several registered entries, this selectively searches backward for a LoRA proxy rather than removing the entire parametrization chain.
The cleanup implementation also has a single-entry branch that removes the temporary parametrization entirely with leave_parametrized=False. It is the multi-entry branch that needs selective removal to preserve the original transformations. This explains why the original issue describes an already-parametrized expert weight and why merely targeting a 3-D weight is not enough to identify the failure. An ordinary 2-D parameter, or a different active-adapter/dtype branch, may exercise different cleanup logic. That is not a reason to change precision or adapter targeting as a generic workaround: it would change the experiment, and possibly the intended model behavior.
The factors proxy avoids materializing a separate full-sized delta. The affected selective cleanup recognizes _LoraParameterProxy but not _LoraFactorsProxy, so the latter remains registered and the warning is emitted.
A finally clause already calls cleanup; the problem is its type recognition. Nor is it a stale value cache: parametrize.cached() scopes cached computed values, not registration lifetime.
Here is the intended structural sequence, with P the original object and each F a temporary registration:
before adapter call: [P]
inside adapter call: [P, F1]
after adapter call: [P]
inside next adapter call: [P, F2]
after adapter call: [P]
The affected sequence instead looks like this:
before adapter call: [P]
after call 1: [P, F1]
after call 2: [P, F1, F2]
after call 3: [P, F1, F2, F3]
after failed call 4: [P, F1, F2, F3, F4]
With an unchanged additive update, accumulation conceptually gives P(W) + k * delta. That is not a universal formula for nonlinear transformations, changed weights or rounding. Inspect the chain and reference instead of extrapolating a drift slope.
Disabling can skip new activation without removing older proxies: the base reads the same composed attribute. The invariant is both removal of invocation-owned temporary state and preservation of the original chain in order.
The local intervention vs the upstream change
In the CPU experiment the intervention was deliberately narrow. I temporarily replaced the selective cleanup function in that test process, changing just the recognition predicate in its existing loop:
- if isinstance(module, _LoraParameterProxy):
+ if isinstance(module, (_LoraParameterProxy, _LoraFactorsProxy)):
The initial adapter tensors and forward calculation were not changed. This is a causal diagnostic, not a second patch I would recommend distributing or installing in a live application.
The merged commit 302d206 instead gives both proxies a private _LoraProxyBase and recognizes that type. I tested the tuple predicate, not this exact commit.
The PR regression uses a Qwen3MoE fixture with an orthogonal expert-projection parametrization. It checks the nontrivial original and LoRA effects, repeated-output consistency, no cleanup warning, and disabled/unloaded parity with the parametrized base. The PR describes its before/after results.
An intentional failure adds a complementary lifetime check even without a usable output of that call. My candidate result supports the expected cleanup, not a claim that the merged PR fails on this path.
A closely related boundary
#4148, the earlier related report, concerns merging into already-parametrized weights. A stable unmerged forward and a correct merge/export are separate contracts. If only merge or reload changes behavior, compare at that boundary rather than assuming #4162.
3. Small CPU reproduction and regression checks
This standalone aid adds diagnostics to the original CPU worker without changing the installed cleanup. The extra enabled/base and full-chain identity prints are suggestions; the measurements above come from the original worker. This exact standalone script has not been runtime-tested here.
import importlib.metadata as metadata
import warnings
import torch
from torch import nn
from torch.nn.utils import parametrize
from peft import LoraConfig, get_peft_model
class Experts(nn.Module):
def __init__(self):
super().__init__()
self.weight = nn.Parameter(torch.randn(4, 8, 8) * 0.1)
self.fail = False
def forward(self, x):
if self.fail:
raise RuntimeError("intentional forward failure")
return torch.bmm(x, self.weight)
class Model(nn.Module):
def __init__(self):
super().__init__()
self.experts = Experts()
def forward(self, x):
return self.experts(x)
class ExistingParametrization(nn.Module):
def forward(self, w):
return 2 * w
def gap(a, b):
a = a.detach().float()
b = b.detach().float()
assert a.shape == b.shape, (a.shape, b.shape)
d = (a - b).abs()
return {
"max_abs": float(d.max()),
"finite": bool(d.isfinite().all()),
"allclose": bool(torch.allclose(a, b, atol=1e-5, rtol=1e-4)),
}
def chain(module):
if not parametrize.is_parametrized(module, "weight"):
return ()
return tuple(module.parametrizations.weight)
def chain_names(module):
return [type(p).__name__ for p in chain(module)]
def same_objects(a, b):
return len(a) == len(b) and all(x is y for x, y in zip(a, b))
for package in ("peft", "transformers", "accelerate", "torch"):
print(package, metadata.version(package))
# Default CPU device, FP32, same seed for each fresh invocation.
torch.set_num_threads(1)
torch.manual_seed(1234)
base = Model()
original_p = ExistingParametrization()
parametrize.register_parametrization(base.experts, "weight", original_p)
x = torch.randn(4, 5, 8)
reference = base(x).detach().clone()
original_chain = chain(base.experts)
model = get_peft_model(
base,
LoraConfig(
r=2,
target_parameters=["experts.weight"],
target_modules=[],
init_lora_weights=False,
),
)
wrapper = model.base_model.model.experts
experts = wrapper.get_base_layer()
print("wrapper:", type(wrapper).__name__)
print("initial chain:", chain_names(experts))
print("same original chain:", same_objects(chain(experts), original_chain))
counts = []
outputs = []
with warnings.catch_warnings(record=True) as recorded:
warnings.simplefilter("always")
for i in range(3):
outputs.append(model(x))
counts.append(len(chain(experts)))
print("after forward", i + 1, chain_names(experts))
print("counts:", counts)
print("first vs third:", gap(outputs[0], outputs[-1]))
print("first active vs reference:", gap(outputs[0], reference))
print("original object present:", any(p is original_p for p in chain(experts)))
experts.fail = True
try:
model(x)
except RuntimeError as exc:
if str(exc) != "intentional forward failure":
raise
print("observed intentional exception:", str(exc))
else:
raise AssertionError("the intended failure was not triggered")
finally:
experts.fail = False
print("after failure:", chain_names(experts))
print("same original chain after failure:", same_objects(chain(experts), original_chain))
with model.disable_adapter():
disabled = model(x)
print("disabled vs reference:", gap(disabled, reference))
print("chain after disabled forward:", chain_names(experts))
# Optional smoke check on the retained graph, not a training-parity test.
outputs[-1].square().mean().backward()
for name, p in model.named_parameters():
if p.requires_grad:
if p.grad is None:
print(name, "gradient is absent")
else:
print(name, "finite gradient:", bool(p.grad.isfinite().all()))
cleanup_warnings = [
w for w in recorded if "Could not find any LoRA parametrization" in str(w.message)
]
print("LoRA cleanup warnings:", len(cleanup_warnings))
Run in a fresh process per release or pinned commit, with the same compatible dependencies, seed, input, dtype and adapter config. The structural result is more direct than a particular gap magnitude. No local patch is needed to test the installed implementation.
init_lora_weights=False makes a nonzero adapter effect observable; it is a diagnostic choice, not training advice. A neutral initialization can hide drift even when registrations accumulate.
What a small test can distinguish
| Property |
Useful observation |
| Intended target is reached |
Inspect the actual wrapper and targeted parameter |
| Original transformation matters |
Use a non-identity parametrization and reference |
| Adapter participates |
Compare enabled output with the parametrized base |
| Temporary registration has ended |
Compare count, ordered object identity and types outside each call |
| Repeated deterministic forward is stable |
Reuse the same input and unchanged state |
| Exception path reached |
Check for the specific intended error inside the underlying calculation |
| Cleanup after failure |
Inspect the chain after the exception is caught |
| Disabled base remains usable |
Compare with the reference from before adapter injection |
| Unload preserves base behavior |
Separate API boundary, covered by the merged PR regression |
| Retained graph remains differentiable |
Backward and gradient smoke check, not gradient equivalence |
Count, object identity and numerical behavior complement each other: equal outputs can be vacuous with a zero update, and count alone misses replacement of an original object.
Use a deterministic diagnostic that reaches the relevant path. Changing inputs, dropout, routing, weights or precision can legitimately alter outputs. Exact equality here is not a universal mixed-precision tolerance.
The deliberate error is inside the active calculation, not a test of failure during registration, cleanup itself, or concurrent calls. For a more narrowly isolated exception test, the same small fixture could also be reconstructed before its first deliberately failed call. That would distinguish a failure on a previously clean object from the additional residual entry on the already affected object measured here. The success condition is still the same: exactly the original chain, propagated intended error, and the original disabled-reference output. I have not run that separate complete-package comparison.
I would record warning text/count along with the structural checks, rather than require all warnings of every kind to disappear. In the actual unmodified run the four warnings were the missing-LoRA-parametrization warning from cleanup, and each corresponded to an extra retained registration. The proposed check would fail even if the same retention happened without a warning.
4. Preventing accumulation vs recovering an already affected instance
The original construction, enabled call, already changed instance and saved artifact are different reference states. Preserve known-good inputs independently; disabled output after accumulation is not automatically a base oracle.
| Situation |
Useful next comparison |
| Newly constructed model |
Before injection, after repeated enabled forwards, then disabled |
| Growing residual proxy list |
Compare with a fresh instance on fixed code using the same intended inputs |
| Fix only in source, not installed package |
Compare the small test on the release and pinned fixed revision |
| Previously trained adapter artifact |
Fresh load into the intended base and compare with an independently preserved reference if available |
| Merged/exported model |
Compare the export representation against its intended pre-export reference |
| Incorrect documented argument only |
Inspect the actual signature and matching version documentation |
Why not remove every parametrization?
remove_parametrizations removes the whole attribute parametrization. leave_parametrized=True keeps the effective value; False restores the original where supported. Neither selects one entry. The former may bake in residual contributions; the latter may discard a legitimate transform.
A real model may intentionally compose several transformations, including trainable ones. Deleting every entry after the first is not a general repair, nor does an equal effective value at one instant preserve later behavior.
The upstream fix prevents new accumulation; it is not necessarily a migration of an already affected object. Prefer a fresh reconstruction from known inputs where available. Existing-instance recovery was not tested.
What about existing trained adapters?
No optimizer updates, exports or checkpoint round trips were tested. The learned tensors and the ability to load them correctly are separate questions; this does not establish that any historical adapter needs retraining.
Preserve the artifact and config, reconstruct the intended base and compare with an independent reference if available. A reference from an already affected instance can encode the unwanted behavior. A successful load or library upgrade alone cannot certify recovery.
A cheap decision path for similar symptoms
Different outputs on consecutive calls?
First establish whether the comparison should be deterministic.
If it should:
Inspect the targeted parameter and its existing parametrizations.
If there is a growing residual LoRA proxy list:
Check release/revision and compare a fresh instance with fixed code.
Check the disabled output against the original parametrized base.
If the list is stable:
Investigate the other conditions rather than assuming #4162.
If the change appears only after merge or reload:
Compare that separate boundary using an appropriate reference.
The PEFT troubleshooting guide helps inspect adapter state. Here the chain and fixed-input reference are still essential because reported and effective state can differ.
5. The documentation findings and the broader merged correction
The second finding can be checked without invoking the methods. I inspected the actual definitions and docstrings in both 0.21.3 and 0.22.0 source snapshots. All four reported locations in #4216 matched the finding:
| Function |
Stale documented name |
Actual argument names (both releases) |
OFTRotationModule._cayley_batch |
data |
Q, block_size, use_cayley_neumann, num_neumann_terms |
BaseTuner._check_tied_module_exists |
config |
peft_config, key |
BaseTuner._check_target_module_exists |
config |
peft_config, key |
BaseTuner.get_model_config |
default |
model |
The receiver is omitted where appropriate. See the versioned OFT and BaseTuner sources in 0.22.0, and the corresponding OFT and BaseTuner files in 0.21.3. The HF-880 check summarizes the comparison.
Q is a 2-D tensor of independent upper-triangular entries for skew-symmetric blocks, not a batch of full matrices. The other arguments specify block size and configure the Cayley approximation. Both inspected definitions default use_cayley_neumann to True and num_neumann_terms to 5. These are part of the actual signature; the stale text does not describe them. The documentation change need not change the computation.
The middle rows matter to keyword callers even if positional calls work. get_model_config(model) has an internal DUMMY_MODEL_CONFIG fallback for an absent config attribute, not a caller-supplied default argument.
What landed
The description of #4210 (merged as commit f0f69ca) reports a docstring-only audit spanning 31 files: the four functions, 27 tuner classes, RankAllocator, PeftMixedModel, and BaseTunerLayer, with legitimate forwarded kwargs distinguished. I independently checked only the four original definitions in the two releases.
A targeted, read-only source check
This read-only helper prints signatures and docstrings from an unpacked source tree, without model imports. It is not a repository-wide semantic linter.
import ast
import pathlib
import sys
root = pathlib.Path(sys.argv[1])
checks = {
"src/peft/tuners/oft/layer.py": {
"OFTRotationModule": {"_cayley_batch"},
},
"src/peft/tuners/tuners_utils.py": {
"BaseTuner": {
"_check_tied_module_exists",
"_check_target_module_exists",
"get_model_config",
},
},
}
for path, owners in checks.items():
tree = ast.parse((root / path).read_text(encoding="utf-8"))
found = set()
for owner in tree.body:
if not isinstance(owner, ast.ClassDef) or owner.name not in owners:
continue
for item in owner.body:
if not isinstance(item, (ast.FunctionDef, ast.AsyncFunctionDef)):
continue
if item.name not in owners[owner.name]:
continue
found.add((owner.name, item.name))
print(f"\n{path}:{item.lineno}")
print(f"{owner.name}.{item.name}({ast.unparse(item.args)})")
print(ast.get_docstring(item) or "[no docstring]")
expected = {(owner, name) for owner, names in owners.items() for name in names}
if found != expected:
print("definitions not found:", sorted(expected - found))
For example, save it as inspect_four.py and use:
python inspect_four.py peft-0.22.0
Missing definitions are reported, not treated as a clean audit. For an installed package, inspect.signature on the actual callable can complement AST inspection. Neither checks every type, shape, default or example.
6. Reusing this kind of docstring check after a refactor
Comparing explicit signatures and structured Args: entries is cheap. The PEFT documentation conventions specify Google-style sections and continuation indentation. Wrapped prose, examples, Returns: and Attributes: are not additional arguments.
The Desk already distinguishes the scanner’s over-reads from the four confirmed findings. That is a useful practice: treat candidates as locations to inspect, not a count of defects before checking each contract.
| Situation |
What the scanner needs to distinguish |
| Explicit function arguments |
Name and parameter kind from its definition |
| Method receiver |
self or cls is usually not a separately documented option |
| Positional-only / keyword-only |
A correct name can still be used with the wrong calling form |
| Inherited constructor |
Accepted arguments may be defined on a parent |
| Dataclass |
Effective constructor fields can include inherited fields and omit non-init fields |
**kwargs forwarding |
A documented name may be accepted through another component |
| Attribute or property |
May be documented without being a constructor argument |
| Decorated/generated callable |
Syntactic and exposed runtime signatures can differ |
Class docs can describe inherited constructors; dataclasses can generate them. For **kwargs, follow the receiving code before accepting or rejecting a documented name. This differs from get_model_config(model), which has no forwarding interface.
Optional tools include preview Ruff DOC102 and pydoclint, with configuration options for conventions and argument checks:
ruff check --preview --select DOC102 src/peft
I did not run this linter on PEFT. A small scanner test set could include renamed/removed arguments, a correct signature, wrapped prose, inherited constructors and forwarded keywords. Distinguish confirmed mismatches from candidates needing review.
One reason to preserve a small set of confirmed examples such as these four functions is that a later scan can distinguish a fix to the source from a change in the scanner’s own behavior. On a fixed source revision the same targeted inspection should find the definitions and show the corrected contract; if a scanner’s output changes but the inspected source has not, examine the parser or its configuration. Conversely, a generated docs page from another version is not evidence that the installed package still accepts a removed keyword. Keep the source revision, the inspection tool and the rendered-documentation revision distinct.
Name consistency is not semantic consistency: the Q shape also needs correction. Types, shapes, defaults, forwarding and examples need their own checks. Runtime tests can pass despite stale keyword documentation, so signature comparison is complementary.
In short, both notes were reproduced at the stated evidence levels. The failed-call and disabled-reference checks add a useful lifetime test, while the four documentation findings can be verified without model execution. The merged changes are the natural reference for future installations.