model_patcher: support setter-backed WeightHooks safely - #15532
Draft
liminfei-amd wants to merge 3 commits into
Draft
model_patcher: support setter-backed WeightHooks safely#15532liminfei-amd wants to merge 3 commits into
liminfei-amd wants to merge 3 commits into
Conversation
Collect state-dict pieces owned by each quantized weight so hook patching skips synthetic entries without hiding real parameters. Signed-off-by: ComfyUI Contributor <91481003+liminfei-amd@users.noreply.github.com>
Use each weight setter's complete converted value across apply, cache, and restore so structured Hook updates preserve storage metadata. Signed-off-by: ComfyUI Contributor <91481003+liminfei-amd@users.noreply.github.com>
Publish a MaxSpeed cache only when the complete HookGroup backup and result set fits the safety budget. Signed-off-by: ComfyUI Contributor <91481003+liminfei-amd@users.noreply.github.com>
This was referenced Aug 12, 2026
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
Use complete replacement semantics for setter-backed Hook weights and make
MaxSpeedcaching an all-or-nothing HookGroup decision.Problem
FP8 and INT8 modules expose setters that reject the Hook path's forced
inplace_update=True. Copy-only backup and restore also lose structuredquantization metadata.
The current per-weight cache decision can additionally publish a partial group
or accumulate the remaining entries on CPU.
Change
return_weight=Trueresult.Tests
The PR branch passes 15/15 focused tests covering FP8, INT8 ConvRot,
cache/restore, A -> B -> none, ordinary parameters, and low/high cache
budgets. All 15 reported GitHub checks are green. Its full CPU suite retains
only the same four environment failures as baseline.
A clean checkout of the combined test branch (#14413, #15532, and #15533)
passes 17/17 focused tests and the complete CPU suite
(
1238 passed, 10 skipped).On one physical gfx1100 GPU with PyTorch 2.9.1 / ROCm 7.2.1 and
comfy-kitchen==0.2.30:mapped weights and produced finite, nonblack output;
prompts in one service;
ended with zero dynamic pins, and RSS/swap reached a stable plateau;
ERROR lora, unloaded-key, OOM,weight_scale, orinplace_updateerror.Public Krea2 FP8 and INT8 Hook workflows also completed on the earlier
PyTorch 2.12 / ROCm 7.13 validation stack.
The #14382 reporter
independently confirmed that the combined branch at
dad437146bworks forINT8, FP8, and BF16 on the original RX 7900 XTX / two-private-LoRA workflow.
This is integration evidence because that branch also contains #14413 and
#15533; the isolated setter/cache contracts are covered by the focused and
physical-GPU tests above.
Full-size independent HookGroups can still exceed the temporary
weight/GEMM-workspace capacity of a 16 GiB board. That hardware envelope is not
claimed by this change.
Follow-up to #14382. Depends on #14413. This draft branch temporarily includes
that prerequisite commit so the follow-up tests remain runnable before it
merges.
Addresses #15530.
This is an experimental, AI-generated code change, reviewed by AMD engineers before submission.
Made with Cursor