Skip to content

Fix intermittent "addmm_cuda not implemented for 'Char'" on partial unload (#76)#77

Open
Dawgmastah wants to merge 1 commit into
BobJohnson24:mainfrom
Dawgmastah:fix/int8-lora-partially-unload-lowvram
Open

Fix intermittent "addmm_cuda not implemented for 'Char'" on partial unload (#76)#77
Dawgmastah wants to merge 1 commit into
BobJohnson24:mainfrom
Dawgmastah:fix/int8-lora-partially-unload-lowvram

Conversation

@Dawgmastah

Copy link
Copy Markdown

Summary

Fixes the intermittent "addmm_cuda" not implemented for 'Char' crash reported in #76, which persisted even after the load()-only cleanup in c0cc280.

Root cause

c0cc280 strips ComfyUI's stock LowVramPatch and swaps in the scale-aware INT8LowVramPatch, but only inside INT8ModelPatcher.load().

ComfyUI core also installs a stock LowVramPatch on offloaded INT8 layers inside partially_unload() (comfy/model_patcher.py), and that path does not route through load(). The stock patch's __call__ runs:

calculate_weight(patches, weight, self.key, intermediate_dtype=weight.dtype)

For an INT8 weight the intermediate dtype is torch.int8, so the LoRA matmul hits addmm_cuda not implemented for 'Char'.

Because partially_unload() only fires under memory pressure — and only touches a memory-dependent subset of layers — the failure looked random and appeared to "fix itself" on reload. That matches the reports of the same LoRA working on some runs and failing on others.

Fix

  • Extract the LowVramPatchINT8LowVramPatch swap out of load() into a shared _reinstall_int8_lowvram_patches() helper (behavior unchanged — all three branches preserved).
  • Add a partially_unload() override that calls super() then re-runs the helper, so the scale-aware patch is restored after every core path that can install the stock one.

Net change: +30/-1, contained entirely within INT8ModelPatcher.

Notes

I intentionally did not take the alternative "force intermediate_dtype to float32 for non-float weights" monkey-patch suggested in the issue. It would stop the traceback, but the stock LowVramPatch would then return a float weight with no re-quantization against the per-row scale — silently corrupting those layers instead of crashing.

🤖 Generated with Claude Code

…nload

The addmm_cuda/'Char' crash (BobJohnson24#76) persisted after the load()-only cleanup
in c0cc280 because ComfyUI core re-installs a stock LowVramPatch on
offloaded INT8 layers inside partially_unload() (comfy/model_patcher.py),
which does NOT route through INT8ModelPatcher.load(). That stock patch runs
calculate_weight(..., intermediate_dtype=weight.dtype); for an INT8 weight
the intermediate dtype is torch.int8, so the LoRA matmul fails.

Because partially_unload only fires under memory pressure and only touches a
memory-dependent subset of layers, the failure was random and "fixed itself"
on reload.

Extract the LowVramPatch -> INT8LowVramPatch swap from load() into
_reinstall_int8_lowvram_patches() and also call it from a new
partially_unload() override so the scale-aware patch is restored after every
core path that can install the stock one.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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