Skip to content

model_patcher: support setter-backed WeightHooks safely - #15532

Draft
liminfei-amd wants to merge 3 commits into
Comfy-Org:masterfrom
liminfei-amd:amd-rocm/15530-setter-hook-cache
Draft

model_patcher: support setter-backed WeightHooks safely#15532
liminfei-amd wants to merge 3 commits into
Comfy-Org:masterfrom
liminfei-amd:amd-rocm/15530-setter-hook-cache

Conversation

@liminfei-amd

@liminfei-amd liminfei-amd commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Use complete replacement semantics for setter-backed Hook weights and make
MaxSpeed caching 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 structured
quantization metadata.

The current per-weight cache decision can additionally publish a partial group
or accumulate the remaining entries on CPU.

Change

  • Install the setter's complete return_weight=True result.
  • Preserve copy/replacement mode across backup, cache, and restore.
  • Preflight the full HookGroup cache requirement.
  • Publish only complete caches; otherwise keep the group uncached.

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:

  • full public INT8 and FP8 Hook workflows each applied and restored all 264
    mapped weights and produced finite, nonblack output;
  • two independent reduced MaxSpeed HookGroups completed 10 consecutive
    prompts in one service;
  • the whole-group budget check selected the uncached fallback, every prompt
    ended with zero dynamic pins, and RSS/swap reached a stable plateau;
  • logs contained no ERROR lora, unloaded-key, OOM, weight_scale, or
    inplace_update error.

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 dad437146b works for
INT8, 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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant