When weight_inplace_update=True and a set_func (e.g. fp8_scaled ops)
replaces the parameter with a new QuantizedTensor, the backup records
inplace_update=True. On restore, unpatch_model uses copy_to_param
which calls param.data.copy_(). QuantizedTensor.__torch_dispatch__
routes copy_() through _dequant_and_fallback, which copies into a
temporary float tensor without updating the underlying quantized data.
The weight silently remains LoRA-patched after "restore", and the next
generation backs up the already-patched weight and applies LoRA again,
causing progressive quality degradation (washout).
Fix: when set_func is present, force backup_inplace=False so restore
uses set_attr_param (parameter replacement) instead of copy_to_param
(in-place copy). set_attr_param correctly replaces the parameter
object, which works for both regular tensors and QuantizedTensors.
Fixes#11021
2026-03-15 14:52:30 -07:00
7 changed files with 86 additions and 28 deletions
tone_instructions:"Only comment on issues introduced by this PR's changes. Do not flag pre-existing problems in moved, re-indented, or reformatted code."
reviews:
profile:"chill"
request_changes_workflow:false
profile:"assertive"
request_changes_workflow:true
high_level_summary:false
poem:false
review_status:false
review_details:false
review_details:true
commit_status:true
collapse_walkthrough:true
changed_files_summary:false
@ -39,6 +39,14 @@ reviews:
- path:"**"
instructions:|
IMPORTANT:Only comment on issues directly introduced by this PR's code changes.
Treat AGENTS.md as mandatory repository policy, not optional style guidance.
Flag PR changes that violate AGENTS.md even when the code is otherwise functional.
In particular, enforce architecture boundaries, dtype/device/memory rules,
interface contracts, import style, no unnecessary try/except blocks, no inline
imports, no outbound internet paths in core ComfyUI, and narrow scoped fixes.
Prefer direct findings over suggestions when a rule is violated. Only ignore
AGENTS.md when it clearly conflicts with a newer explicit maintainer instruction
in the PR.
Do NOT flag pre-existing issues in code that was merely moved, re-indented,
de-indented, or reformatted without logic changes. If code appears in the diff
only due to whitespace or structural reformatting (e.g., removing a `with:` block),
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.