fix(format-adapters): fail-loud when a wrong-channel VAE is wired for QwenImageLayered
After #470's arch-enumeration fix, loading a QwenImageLayered raw checkpoint with the WRONG VAE crashed deep in the engine with a cryptic `Failed to load weight 'conv_out.bias' (dst [4] = 8 bytes, src [3] = 6 bytes)`. First-principles root cause (why qwen-image/edit work but layered crashes with the SAME raw-checkpoint + standard qwen_image_vae method): - QwenImageLayered decomposes into N RGBA layers, each carrying a per-layer ALPHA channel, so its VAE genuinely decodes 4 channels. The official Qwen-Image-Layered VAE has decoder.conv_out=[4] (ground truth: the working diffusers model's vae/). - Qwen-Image / Qwen-Image-Edit output plain RGB (decoder.conv_out=[3], no per-pixel alpha) — edit is i2i but still RGB. Only QwenImageLayered.json sets input_channels=4 (correct); qwen-image/edit have none → default 3-ch → match the standard qwen_image_vae. So the 4-ch requirement is CORRECT architecture, not a plugin mistake. The defect was the EXPERIENCE: a user wiring the standard 3-ch qwen_image_vae got a cryptic engine-deep crash instead of a clear "wrong VAE" message. Fix (plugin staging, no build): detect the wired VAE's REAL decoder output channel count (reads decoder.conv_out / decoder.head.2 shape — handles both diffusers and ComfyUI-flat QwenImage VAE namings) and fail LOUD with an actionable message when an RGBA-VAE arch (QwenImageLayered) is given a non-4-channel VAE: "QwenImageLayered requires a 4-channel RGBA VAE ... wire the layered model's own vae/, not the base qwen_image_vae." Wired into ALL FOUR adapters that stage a separately-wired VAE (comfyui_unet, nunchaku_svdq, hf_native, bundled_checkpoint). NO-OP for every other arch and when the channel count can't be read (best-effort, never a false block). Verified on the real ground-truth files: channel detection 3 (standard flat head.2) vs 4 (layered diffusers conv_out); regression qwen-image/edit + 3-ch → no raise; (a) layered + 3-ch → clear error at staging (not cryptic crash); (b) layered + 4-ch → staging succeeds (the 4-ch decode path = pre-existing working run, untouched). worker.py untouched. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Y
yejianhui committed
8ece5bbb3b11f9e9522fae8a0527074c1ec0ca96
Parent: 8677d71