| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
fix(gguf): honor ComfyUI's comfy.gguf.orig_shape metadata (#9564) * fix(gguf): honor ComfyUI's comfy.gguf.orig_shape metadata ComfyUI's GGUF converter can only quantize 2-D tensors, so it reshapes any tensor the quantizer rejects and records the native shape under a `comfy.gguf.orig_shape.<tensor name>` KV entry. `gguf_sd_loader` ignored those entries and used the stored shape, so such a checkpoint failed at load with a size mismatch. Concretely, Krea-2's `first.weight` is (6144, 64) but is stored as (1536, 256), which produced: size mismatch for img_in.weight: copying a param with shape torch.Size([1536, 256]) from checkpoint, the shape in current model is torch.Size([6144, 64]) The loader now reads the metadata and uses the declared native shape, rejecting an entry whose element count doesn't match the stored tensor and warning on a malformed one. This is architecture-agnostic, not a Krea-2 special case. Verified end-to-end: the affected checkpoint from the issue installs, loads and generates a coherent image. Closes #9537 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(gguf): reshape numpy dequant fallback and harden orig_shape parsing Follow-up to the comfy.gguf.orig_shape support, addressing review feedback. Qtypes without a torch dequantize kernel fall back to gguf's numpy implementation, which infers the output shape from the stored data. That matched the logical shape only as long as both were identical -- with a ComfyUI-reshaped tensor the fallback returned the stored shape, so loading succeeded and inference then failed. Reshape the fallback output to tensor_shape, as the torch path already does via oshape. Dimension values from comfy.gguf.orig_shape.* were passed straight to int(), which truncates non-integral values (int(2.5) == 2) and raises an uncaught OverflowError on inf. Both contradict the documented warn-and-ignore behaviour. Reject anything that is not a finite, integral, positive number, and verify that the metadata is an array at all. Tests cover the fallback qtype shape and the malformed-metadata cases. --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com> | 6 天前 | |
feat - Migrate to Transformers 5.5.4 (#9248) * Update to Transformers 5.1.0 * remove extra stuff * chore(deps): compel fork + transformers>=5.9.0 + remove override Switches compel from PyPI 2.1.1 to invoke-ai/compel@main fork which supports transformers 5.x. Bumps transformers floor to 5.9.0. Removes the transformers>=5.1.0 uv override that was only needed to bypass compel 2.1.1's <5.0 constraint. NOTE: compel fork pulls notebook dep (full Jupyter stack); flag to maintainer for cleanup. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(z_image): resolve rope_theta from rope_parameters for transformers 5.x transformers 5.x no longer exposes rope_theta as a top-level attribute on Qwen3Config; the value is stored in the rope_parameters (and rope_scaling) dict instead. Read it from there with a getattr fallback so the inv_freq buffer is computed from the configured base (1e6 / 256) instead of raising AttributeError. Applies to both the safetensors and GGUF Qwen3 encoder paths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(model_manager): replace removed hf_hub get_token_permission with whoami huggingface_hub 1.x removed get_token_permission(). HFTokenHelper.get_status() now validates the token via whoami(), which returns user info for a valid token and raises HfHubHTTPError for an invalid one. Preserves the original three-way status: VALID on success, INVALID on HfHubHTTPError (e.g. 401), UNKNOWN on any other error (e.g. network failure). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * chore(deps): regenerate uv.lock after upstream merge Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(sd3): resolve merge conflict marker, drop T5TokenizerFast The upstream merge left an unresolved conflict marker in _t5_encode and reintroduced T5TokenizerFast. Keep our v5 assertion (T5Tokenizer only) plus upstream's new t5_device logic, and drop the now-dead T5TokenizerFast monkeypatch in the test (the name no longer exists in the module). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * style: ruff fixes on merge-resolved files - flux_text_encoder.py: drop unused typing.Union (F401) left by v5 import merge - huggingface.py: ruff format (wrap append(SimpleNamespace(...))) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * chore(deps): pin transformers <5.6 (diffusers single-file CLIP incompat) transformers 5.6 flattened CLIPTextModel (removed the self.text_model wrapper, hoisted embeddings/encoder/final_layer_norm to the top level). diffusers' single-file checkpoint loader (create_diffusers_clip_model_from_ldm) still assumes the nested layout, so loading SD1.5 .safetensors checkpoints fails on 5.6+ with 'CLIPTextModel object has no attribute text_model' and, once that read is shimmed, 'Cannot copy out of meta tensor' (weights never populate the flattened model). Pin to >=5.5,<5.6 (last pre-flattening release) which keeps both the single-file and from_pretrained paths working. The invoke-ai/compel fork accepts any 5.x. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * @ chore(deps): replace compel fork with official compel 2.4.0 compel 2.4.0 (released 2026-05-30) merges the transformers-5 support that the invoke-ai fork carried (both descend from upstream PR #129), plus the maintainer-reviewed padding rework and added diffusers/T5 smoke coverage. Switch from the git fork to the PyPI release. - pyproject: compel git+main -> compel>=2.4.0,<3 - uv.lock: compel 2.3.1 (git 8f404b45) -> 2.4.0 (pypi) - transformers stays 5.5.4 (satisfies compel >=5,<6 and our <5.6 pin) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> @ * chore(uv): update uv.lock --------- Co-authored-by: Your Name <you@example.com> Co-authored-by: 4pointoh <97913726+4pointoh@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Alexander Eichhorn <alex@eichhorn.dev> Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com> | 2 个月前 | |
fix(model loaders): ignore unexpected checkpoint keys, report them at debug only (#9581) * fix(model loaders): ignore unexpected checkpoint keys, report them at debug only Single-file loaders disagreed, loader by loader, about what an unexpected key from `load_state_dict(strict=False)` means: some raised, one warned, most ignored it silently, and the rest used `strict=True` and let torch raise. The ones that hard-failed turned any harmless extra tensor an exporter happened to serialize into a user-facing crash that needed a code change and a release — Anima went through this twice (#9201, #9402) for tensors the model does not need and the official checkpoint does not contain. Per the team decision on #9437, extra keys are now reported at DEBUG and otherwise ignored everywhere. New `invokeai/backend/util/state_dict_loading.py` holds the single policy: - `log_unexpected_keys()` — DEBUG only, never raises. - `load_state_dict_ignoring_extras()` — a drop-in for `strict=True` that keeps the strictness that matters (every required parameter must be filled, shape mismatches still raise) and drops the strictness that only produces whack-a-mole. - `reject_incomplete_load()` — the meta-device completeness sweep, generalized out of krea2. Stronger than `missing_keys` for models built under `init_empty_weights()`: immune to non-persistent buffers and tied weights. Every previously existing missing-key guard is preserved exactly; only the unexpected-key policy changed. `flux.py`'s bare `assert len(unexpected_keys) == 0` — which carried no message and was stripped entirely under `python -O` — is gone with it. Two consequences worth calling out: - `configs/pid_decoder.py` rejected unexpected keys at *identification* time, deliberately mirroring the loader ("both are fatal there"). Left alone, the PiD relaxation would have been unreachable and the installer would refuse a file that now loads fine. It keeps refusing non-string keys, which `load_state_dict` genuinely cannot survive. - Anima's unexpected-key `RuntimeError` was its only hard load-time guard, so it is replaced with the meta-device sweep rather than dropped — otherwise an incomplete checkpoint would fail mid-inference with "Cannot copy out of meta tensor" instead of at load time. `wan.py::_raise_for_incompatible_keys` deliberately keeps raising: Wan derivatives (Animate, S2V, Fun-Camera) are supersets whose extra branches are the feature the checkpoint exists for, not exporter noise, and it strips the benign extras before that check. Closes #9437 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V4nLTdWBQaaDUFVLx9TyZH * docs(model loaders): fix two stale unexpected-key comments Review follow-up for #9581. The ideogram4 fp8 encoder branch and the z_image SDNQ Qwen3 loader still described unexpected checkpoint keys as fatal, but both now go through helpers that log them at DEBUG and ignore them (`load_fp8_state_dict`, `raise_on_incomplete_sdnq_load`). Update the comments to match the code; missing-key strictness is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NxYxw5RUtuRTBRWTn79M9d --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com> | 6 天前 | |
Move requantize.py to the quatnization/ dir. | 2 年前 | |
feat(mm): add Qwen Image single-file checkpoint loader with fp8 support (#9253) * feat(model-manager): add Qwen Image single-file checkpoint loader with fp8 support Adds Main_Checkpoint_QwenImage_Config and QwenImageCheckpointModel so that single-file safetensors checkpoints (e.g. Qwen-Image-Edit 2511 fp8_scaled from Civitai) can be imported. ComfyUI-style fp8 weights are dequantized to bf16 at load time; the existing default_settings.fp8_storage toggle then optionally re-casts to fp8 for VRAM savings. Also wires _apply_fp8_layerwise_casting into the Qwen Image diffusers loader so the fp8 storage option works across all three formats (diffusers, single- file checkpoint, GGUF stays untouched as it carries its own quantization). Shared variant inference (marker tensor → filename heuristic) and transformer architecture auto-detection are extracted into module-level helpers so the GGUF and checkpoint loaders stay in sync. * chore(frontend): openapi & typegen * fix(qwen-image): align ComfyUI-prefix detection with loader, tighten edit heuristic, dedupe fp8 helpers - strip ComfyUI key prefixes in _has_qwen_image_keys so prefixed checkpoints are identified and reach the loader - match "edit" as a filename token instead of any substring (no credited/edited/unedited false positives) - reuse _dequantize_comfyui_fp8 / _strip_quantization_metadata in the QwenVL encoder loader - size make_room reservation after the bf16 cast to avoid fp32 undercount - add Path type hint on _infer_qwen_image_variant * fix(qwen-image): reduce dequant RAM, fix VL encoder classification, silence int8 warning - qwen_image: dequantize ComfyUI fp8_scaled weights directly to compute_dtype instead of a full-precision float32 intermediate. The previous path materialised a 4-byte/param copy of the whole model before downcasting, spiking peak RAM to ~2x the final bf16 size (~80GB for the 20B transformer). bf16 shares float32's exponent range and fp8 has only 3 mantissa bits, so no meaningful precision loss. - qwen3_encoder: reject checkpoints that bundle a Qwen-VL visual tower (visual.blocks.* / visual.patch_embed.*). A Qwen2.5-VL file satisfies the Qwen3 key heuristic too, so it matched both configs and the tiebreak misrouted it to Qwen3Encoder, hiding it from the Qwen Image loader's encoder field. Qwen3 (text) and QwenVLEncoder (vision+language) are now mutually exclusive. - bnb_llm_int8: silence the per-matmul "inputs will be cast from bfloat16 to float16" UserWarning. LLM.int8 only supports fp16 activations; the bf16->fp16 cast is correct and intended, so the warning is pure log spam on every layer. * Chore Ruff --------- Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com> | 2 个月前 | |
Install sub directories with folders correctly, ensure consistent dtype of tensors in flux pipeline and vae | 2 年前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 6 天前 | ||
| 2 个月前 | ||
| 6 天前 | ||
| 2 年前 | ||
| 2 个月前 | ||
| 2 年前 |