fix(comfyui): #411 — robust QwenImageLayered arch detection for RGBA ref staging
#397's RGBA-ref PNG-staging gate keyed off cfg["_arch"], but _arch comes from
the per-file fingerprint (fingerprint_arch_from_keys) which collapses a
Qwen-Image-Layered model to plain "QwenImage" on several load layouts:
- a flat lighting/prequant export whose metadata _class_name is the SHARED
QwenImageTransformer2DModel (short-circuits to "QwenImage" before the
addition_t_embedding key check);
- a non-shard-1 shard read with no sibling config/model_index;
- a model_dir handed in as a directory (sibling-probe expects <root>/transformer/<shard>).
So pipeline_wants_rgba stayed False -> the RGBA ref was staged as an RGB-only
QFRAW01 blob -> the engine's QwenImageLayered VAE encoder calls
load_image(channels=4), which bypasses the QFRAW decoder -> cv::imread on a raw
blob -> "RuntimeError: Failed to load image .qfraw" (a800/SM80, regressed #397).
This is why 远程-linux PASSED (shard-1 + sibling model_index.json hit the correct
path) but a800 FAILED on the same model — a per-machine load-layout difference,
not a misreport.
Fix mirrors the engine's OWN source of truth (model_index.json _class_name ==
QwenImageLayeredPipeline — the signal it uses to set refImageChannels()==4):
- nodes_format_adapters.py build(): upgrade cfg["_arch"] -> "QwenImageLayered"
when model_dir/model_index.json says so, or a "layered" marker is in the
model_dir / precision_config basename. Fixes _arch for ALL consumers.
- nodes.py: pipeline_wants_rgba gate gets the same model_index/marker fallback
as defense-in-depth.
A false positive is harmless (a real PNG loads at 3 OR 4 channels); a false
negative crashes — so the detection biases toward layered. Unit-tested:
online_quant/flat-export/precision_config all upgrade; plain QwenImage does not.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Y
yejianhui committed
fa36026d5c7da1ad8c66415b33177d66ec4b9561
Parent: 049c5dc