Repository navigation
feat(wan): load ComfyUI int8 convrot checkpoints - #10185
Merged
Merged
Conversation
Keep marked layers in int8 for A14B experts and TI2V-5B and refuse undecodable files at install. Choose LoRA sidecar patching per loaded expert, so int8 experts are never patched directly.
Commit figures on Windows include VRAM, so the page overstated RAM use.
5 of 7 tasks
lstein
approved these changes
Nov 8, 2026
lstein
left a comment
Collaborator
There was a problem hiding this comment.
Approving at f147243. I reviewed the install guard, the int8 load path and the per-expert LoRA sidecar decision, and the focused tests pass (loader, int8 keys, expert swapper, checkpoint config: 163 tests). I also broke the key map, skip patterns, header read and RAM reservation one at a time, and in each case the tests failed. Three low-severity notes, none blocking:
- int8 branch skips
_strip_quantization_metadata(load/model_loaders/wan.py:475).drop_unconsumed_quantization_sidecarsremoves only.comfy_quantand input scales. A stray top-levelscaled_fp8key, or a.weight_scalebeside a dense weight, therefore reaches Wan's fatal unexpected-key check. The error then blames an Animate/S2V variant:RuntimeError ... (modules: scaled_fp8). This is a Wan variant with extra conditioning branches. The fp8 branch drops the same keys silently. Suggest also strippingSTRAY_METADATA_KEYSand weight-scale keys whose layer has neither an int8 marker nor an fp8 weight. - A mixed int8 + fp8_scaled file passes install and fails at load. The guard (
configs/main.py,_raise_for_undecodable_int8_weights) only looks at int8.weighttensors, so it does not see fp8 weights with scales.reject_foreign_quantization_scalesthen refuses the file at first render, with a clear message. No known Wan build does this, and the other int8 configs share the gap. - The install guard doesn't validate the marker layout. A marker with
convrot_groupsize: 512(not a power of 4) or0installs and is refused at load. This is the shared helper's behaviour and is already listed under "Remaining limits".
Not checked: GPU runs, real released checkpoints, I2V-A14B, the family E2E.
A top-level scaled_fp8 flag or a weight scale beside a dense weight no longer fails the load as an unsupported Wan variant; the int8 branch now drops them like the fp8 branch does.
Member
Author
|
Thanks for the review, and especially for the mutation pass.
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lstein
enabled auto-merge
November 8, 2026 13:47
lstein
added a commit
to Pfannkuchensack/InvokeAI
that referenced
this pull request
Nov 8, 2026
Resolved the import conflict in model_loaders/wan.py with invoke-ai#10185 by keeping both sides' imports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pfannkuchensack
added a commit
to Pfannkuchensack/InvokeAI
that referenced
this pull request
Nov 9, 2026
Since invoke-ai#10185 a marked int8 file takes the int8 branch and stays int8, and an unmarked one is refused, so no int8 weight reaches the fold any more. The int8 branch reserves before its split and has its own reservation test.
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
ComfyUI
int8_tensorwise(convrot) single-file Wan 2.2 transformers now load and generate. Before, they installed and then failed at load with "this loader has no int8 branch".WanCheckpointModelkeeps marked layers asInt8ConvrotLinear: both A14B experts and TI2V-5B.condition_embedder, which reads its dtype from a parameter, is decoded dense at load.format == GGUFQuantized, so an int8 expert would have been patched directly into its int8 buffers. The decision is now made per loaded expert withrequires_sidecar_patching, so mixed pairs work._raise_for_undecodable_int8_weights), including int4 builds and files marked only{"convrot": true}. Animate and Wan 2.1 stay unrecognized.reject_unmarked_int8_weightsno longer claims a marked file has no marker.File sources: Comfy-Org only publishes Wan Animate in int8, which Invoke does not run. T2V, I2V and TI2V-5B builds are community uploads. Note that
FartingBackwards/wan2.2-t2v-14B-int8-convrotships the same file twice: itslow_noisefile is byte-identical tohigh_noise(same LFS hash). It loads, but runs the high expert for both phases.Related Issues / Discussions
Follow-up: Wan's RAM use sits above
max_cache_ram_gb. The main cause for int8 is the expert swap, which holds both experts in memory; casting formats (fp16, scaled fp8) also double while loading, and Diffusers folders pin their fp32 source. These affect every Wan format, not only int8, and are unchanged here. #10192 fixes them. Measured below.QA Instructions
Local, RTX 4090, Windows, clean scratch root,
use_cache=false, cache emptied between models. T2V at 832x480, 17 frames; TI2V-5B at 832x480, 25 frames.Decode against dense weights (sampled layers per file, float64): cosine 0.99996, relative error 0.9 %; without derotation cosine 0.06. This also confirms high and low map to
transformerandtransformer_2.One forward per expert through the real loader, int8 against bf16, same random input: cosine 0.9985-0.9996, relative error 3-5.5 %, 400 of 400 layers int8.
Time per clip after warmup (blocks of 1 warmup + 3 clips; TI2V-5B dense measured before and after int8):
int8_computeint8 saves memory. A14B is faster here because it fits in 24 GB and bf16 does not; where both fit (TI2V-5B), plain int8 is about 8 % slower.
Clip PSNR against bf16, same seeds, mean over frames:
The A14B numbers are low for Q8_0 too: sampling diverges in motion and position while subject and composition stay. int8 sits 2-7 dB below Q8_0. At 20 steps both clips are clean; at 8 steps (undersampled, artifacts on both sides) int8 showed more of them in seed 101. Two dense runs with the same seed are bit-identical, so the difference comes from the weights. int8 is not pixel-faithful to bf16 on A14B.
Lightning LoRA (4 steps) on the int8 pair: 20 s per clip, clean and sharp, confirming the sidecar path on real weights. PSNR against dense + LoRA is 13.5-18.4 dB; the two apply the LoRA differently (sidecar against merged).
Peak RAM (working set) with both experts and UMT5 cached: int8 41 GB. With
max_cache_ram_gb: 16, int8 still runs at about 58-70 s per clip with a 30 GB peak, because the swap holds both experts; see the follow-up above. Windows commit reads about 20 GB higher in both cases (64 and 46 GB) because VRAM counts toward it. An earlier version of this description gave commit figures as process memory.Focused suites after rebase pass (about 7100 tests):
tests/backend/model_manager/load,configs,tests/backend/quantization,pid,qwen3_5,tests/app/invocations.Not run: I2V-A14B on a GPU (key mapping and unit tests only; it differs in the dense
patch_embedding),int8_computetogether with LoRA, AMD, Linux, the docs build, the family E2E.Review
Resolved: the install guard mirrors what the loader discards, so all-in-one files with a bundled int8 encoder still install; refusal wording; docs for int4 (
R), DoRA andint8_compute; added regression coverage for prefixed header-only files, sidecar drop and asymmetric expert pairs.Remaining limits:
Compatibility / Rollout
No migration. Generated API files change only by a docstring.
_ExpertSwapperloses itshigh_is_quantizedandlow_is_quantizedparameters; it has no callers outside the two Wan denoise invocations.Checklist
What's Newcopy (if doing a release after this PR)