Commit ·
323b987
1
Parent(s): f7aecdf
qwen docs
Browse filesFiles changed (4)
13 unmodified lines14151617181953 unmodified lines73747576777813 unmodified lines| :--- | :--- | :--- || 🎬 **[`h3-center/`](h3-center/)** | **MiniMax-H3 Video & Cinema Hub**<br>Complete prompt guides, RefMod stacking, hybrid LoRA+RefMod containers, 1,500+ character tests, and 9-episode Crossovers cinematic series. | • [Prompting Guide](h3-center/docs/MINIMAX_H3_PROMPTING_GUIDE.md)<br>• [RefMod Stacking Guide](h3-center/docs/MINIMAX_H3_REFMOD_STACKING_AND_MULTISUBJECT_GUIDE.md)<br>• [Hybrid LoRA+RefMod Guide](h3-center/docs/MINIMAX_H3_HYBRID_LORA_REFMOD_CONTAINERS_GUIDE.md)<br>• [Multistacking Benchmark Demos](h3-center/docs/multistacking/README.md)<br>• [Known Characters Usability Index](h3-center/known-characters/INDEX.md)<br>• [Crossovers Cinema Series](h3-center/crossovers/README.md) || 🎨 **[`klein9/`](klein9/)** | **FLUX.2 & Klein 9B RefMods**<br>Instant reference latent adapter ecosystem, custom ComfyUI nodes, CLI batch extractor, and benchmark suites. | • [RefMod Architecture Guide](klein9/docs/FLUX2_KLEIN9_REFMODS_GUIDE.md)<br>• [ComfyUI Node](klein9/comfyui/custom_nodes/ComfyUI-Flux2Klein9Mod/)<br>• [Batch Extractor Tool](klein9/generate_flux2_klein9_refmod.py)<br>• [Workflows](klein9/workflows/) \| [Visual Benchmarks](klein9/docs/VISUAL_BENCHMARKS_AND_COMPARISONS.md) || ⚡ **[`zimage-turbo-vs-base-training/`](zimage-turbo-vs-base-training/)** | **Z Image Base vs. Turbo Benchmark**<br>Head-to-head training comparison across OneTrainer, MalTrainer, and AI Toolkit with datasets and weights. | • [Benchmark Overview & Configs](zimage-turbo-vs-base-training/README.md)<br>• Datasets, AdamW/Prodigy configs, & `.safetensors` weights || 🛠️ **[`training-scripts/`](training-scripts/)** | **Production Training Configs**<br>Ready-to-use recipes for OneTrainer, Musubi Tuner, AI Toolkit, and MalTrainer. | • [OneTrainer Templates](training-scripts/onetrainer/) (Ernie, FK9, Krea2)<br>• [Musubi Pipelines](training-scripts/musubi/) (Ernie, LTX23)<br>• [AI Toolkit](training-scripts/aitoolkit/) & [MalTrainer](training-scripts/maltrainer/) || 🎥 **Sample Media & Benchmarks** | **Model Generation Sample Libraries**<br>High-fidelity outputs and verification test suites. | • [`ltx23-samples/`](ltx23-samples/) (20 LTX-Video 2.3 renders)<br>• [`ernie-samples/`](ernie-samples/) (`ernie-samples.zip`)<br>• [`samples/fk9/`](samples/fk9/) (Rose Byrne & Sydney Sweeney outputs) |53 unmodified lines---## ⚡ Z Image Base vs. Z Image Turbo Training Suite (`zimage-turbo-vs-base-training/`)An empirical training study benchmarking **Z Image (Base)** against **Z Image (Turbo)** using identical curated datasets (Felicia Day, Olivia).13 unmodified lines1415161718192053 unmodified lines747576777879808182838485868788899091929313 unmodified lines| :--- | :--- | :--- || 🎬 **[`h3-center/`](h3-center/)** | **MiniMax-H3 Video & Cinema Hub**<br>Complete prompt guides, RefMod stacking, hybrid LoRA+RefMod containers, 1,500+ character tests, and 9-episode Crossovers cinematic series. | • [Prompting Guide](h3-center/docs/MINIMAX_H3_PROMPTING_GUIDE.md)<br>• [RefMod Stacking Guide](h3-center/docs/MINIMAX_H3_REFMOD_STACKING_AND_MULTISUBJECT_GUIDE.md)<br>• [Hybrid LoRA+RefMod Guide](h3-center/docs/MINIMAX_H3_HYBRID_LORA_REFMOD_CONTAINERS_GUIDE.md)<br>• [Multistacking Benchmark Demos](h3-center/docs/multistacking/README.md)<br>• [Known Characters Usability Index](h3-center/known-characters/INDEX.md)<br>• [Crossovers Cinema Series](h3-center/crossovers/README.md) || 🎨 **[`klein9/`](klein9/)** | **FLUX.2 & Klein 9B RefMods**<br>Instant reference latent adapter ecosystem, custom ComfyUI nodes, CLI batch extractor, and benchmark suites. | • [RefMod Architecture Guide](klein9/docs/FLUX2_KLEIN9_REFMODS_GUIDE.md)<br>• [ComfyUI Node](klein9/comfyui/custom_nodes/ComfyUI-Flux2Klein9Mod/)<br>• [Batch Extractor Tool](klein9/generate_flux2_klein9_refmod.py)<br>• [Workflows](klein9/workflows/) \| [Visual Benchmarks](klein9/docs/VISUAL_BENCHMARKS_AND_COMPARISONS.md) || 👁️ **[`qwen/`](qwen/)** | **Qwen-Image 2.1 Multimodal Hub**<br>Vision-Language (Qwen3-VL) conditioning architecture, reference strategy analysis, identity transfer, and prompt engineering standards. | • [RefMod Compatibility & ViT Architecture](qwen/docs/QWEN_IMAGE_21_REFMOD_COMPATIBILITY_AND_VISION_ENCODER_ARCHITECTURE.md)<br>• [Reference Strategy & Prompting Guide](qwen/docs/QWEN_IMAGE_21_REFERENCE_STRATEGY_AND_PROMPTING_GUIDE.md)<br>• [Qwen Hub Overview](qwen/README.md) || ⚡ **[`zimage-turbo-vs-base-training/`](zimage-turbo-vs-base-training/)** | **Z Image Base vs. Turbo Benchmark**<br>Head-to-head training comparison across OneTrainer, MalTrainer, and AI Toolkit with datasets and weights. | • [Benchmark Overview & Configs](zimage-turbo-vs-base-training/README.md)<br>• Datasets, AdamW/Prodigy configs, & `.safetensors` weights || 🛠️ **[`training-scripts/`](training-scripts/)** | **Production Training Configs**<br>Ready-to-use recipes for OneTrainer, Musubi Tuner, AI Toolkit, and MalTrainer. | • [OneTrainer Templates](training-scripts/onetrainer/) (Ernie, FK9, Krea2)<br>• [Musubi Pipelines](training-scripts/musubi/) (Ernie, LTX23)<br>• [AI Toolkit](training-scripts/aitoolkit/) & [MalTrainer](training-scripts/maltrainer/) || 🎥 **Sample Media & Benchmarks** | **Model Generation Sample Libraries**<br>High-fidelity outputs and verification test suites. | • [`ltx23-samples/`](ltx23-samples/) (20 LTX-Video 2.3 renders)<br>• [`ernie-samples/`](ernie-samples/) (`ernie-samples.zip`)<br>• [`samples/fk9/`](samples/fk9/) (Rose Byrne & Sydney Sweeney outputs) |53 unmodified lines---## 👁️ Qwen-Image 2.1 Multimodal Hub (`qwen/`)The **Qwen-Image 2.1 Hub** covers empirical research and architectural standards for image generation and character identity transfer using the **Qwen-Image 2.1 Diffusion Transformer + Qwen3-VL Vision-Language conditioning pipeline**.### 📖 Technical Documentation & Guides- 📘 **[RefMod Compatibility & Vision-Language Architecture Analysis](qwen/docs/QWEN_IMAGE_21_REFMOD_COMPATIBILITY_AND_VISION_ENCODER_ARCHITECTURE.md)**: Details why pre-encoded VAE RefMod adapters (`.safetensors` from MiniMax-H3 / FLUX.2) are mathematically incompatible with Qwen-Image 2.1, explaining Qwen3-VL's live ViT patch projection, dynamic token insertion, and joint cross-attention.- 📋 **[Reference Strategy, Prompting Standards & Identity Preservation Guide](qwen/docs/QWEN_IMAGE_21_REFERENCE_STRATEGY_AND_PROMPTING_GUIDE.md)**: Complete empirical benchmarking of reference strategies:- Demonstrates why **1 Reference Image per Person** is the optimal standard.- Documents failure modes of multi-image referencing for single subjects (token dilution, feature blending).- Documents failure modes of 2x2 and 3x3 composite grids (grid leak, loss of high-frequency skin textures).- Provides master production prompt templates for precision face-swapping (preserving body, pose, age, skin pores, and clothing) and multi-character scenes.---## ⚡ Z Image Base vs. Z Image Turbo Training Suite (`zimage-turbo-vs-base-training/`)An empirical training study benchmarking **Z Image (Base)** against **Z Image (Turbo)** using identical curated datasets (Felicia Day, Olivia).
12345678910111213141516171819202122232425# Qwen-Image 2.1 Reference & Multimodal Architecture Hub (`qwen/`)
Welcome to the research, architectural documentation, and empirical benchmarking hub for **Qwen-Image 2.1** and its underlying **Qwen3-VL multimodal vision-language diffusion pipeline**.
---
## 🧭 Directory Map & Documents
| Document | Description | Key Focus Areas || :--- | :--- | :--- || 📘 **[RefMod Compatibility & Vision Architecture](docs/QWEN_IMAGE_21_REFMOD_COMPATIBILITY_AND_VISION_ENCODER_ARCHITECTURE.md)** | Architectural deep-dive explaining why static VAE RefMods (like MiniMax-H3 and FLUX.2 / Klein 9B) cannot be used in Qwen-Image 2.1. | • Qwen3-VL ViT token projection<br>• Joint cross-attention vs. VAE latent injection<br>• Dynamic prompt-token binding || 📋 **[Reference Strategy & Prompting Standards](docs/QWEN_IMAGE_21_REFERENCE_STRATEGY_AND_PROMPTING_GUIDE.md)** | Production guide and empirical benchmarks comparing single-image reference, multi-image referencing, composite grids, and face-swap prompting. | • 1 Image = 1 Person standard<br>• Grids & multi-ref failure modes<br>• Identity, age & skin texture preservation<br>• Verified face-swap & dual-character prompt templates |
---
## ⚡ Key Architectural Findings Summary
1. **Why No RefMods in Qwen-Image 2.1?** - **MiniMax-H3 & FLUX.2 / Klein 9B** use VAE-encoded spatial tensors injected directly into DiT conditioning streams. - **Qwen-Image 2.1** conditions its diffusion transformer through **Qwen3-VL**, a multimodal Large Vision-Language Model. Conditioning is not a raw VAE latent array; it is a high-dimensional sequence of vision patches dynamically bound to positional text tags (`<image1>`, `<image2>`). Static pre-encoded VAE tensors cannot bypass the vision encoder.
2. **The 1 Reference Image = 1 Person Rule**: - **Single Reference Image**: Delivers optimal identity precision, preserving authentic skin pores, exact age, eye color, bone structure, and gaze. - **Multi-Image References (`<image1>`, `<image2>`, ... for 1 subject)**: Causes token dilution, attention splitting, and identity drift. - **Composite Grids (2x2 / 3x3 tile images)**: Suffers from grid artifacts, scale confusion, and loss of micro-facial details.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113# Qwen-Image 2.1: Reference Strategy, Prompting Standards & Identity Preservation Guide
_Version: 1.0.0_ _Last Updated: September 2026_ _Target Model: Qwen-Image 2.1 (`qwen_image_2.1_int8_convrot.safetensors` + `TextEncodeQwenImage21`)_
---
## 1. Overview & Core Empirical Findings
Through exhaustive testing with multi-subject datasets (Aneta, Felicia Day, Gosia), several clear operational principles have been established for conditioning **Qwen-Image 2.1** via reference images (`TextEncodeQwenImage21` / `Qwen3-VL-8B`):
1. **The "1 Image = 1 Person" Golden Standard**: Supplying a single, clear, high-resolution portrait reference per subject delivers significantly higher likeness accuracy, precise eye color preservation, authentic skin textures, exact age rendering, and clean composition compared to multi-image or grid-based approaches.2. **Multi-Image Stacking for a Single Subject Degrades Likeness**: Supplying 3–4 separate reference images for the same person splits the vision-language attention budget, causing feature averaging, facial distortion, or bias toward a single dominant image.3. **Composite Image Grids (2x2 / 3x3) Cause Grid Leaks & Loss of Detail**: Packing multiple photos into a tiled 1024x1024 (2x2) or 1536x1536 (3x3) grid degrades per-face resolution and frequently introduces compositional artifacts (split-screens, collages, duplicate faces).4. **Precise Prompt-to-Tag Binding Is Essential**: Identity transfer and face-swapping require strict syntactic and semantic constraints in the prompt text, clearly demarcating the role of `<image1>` (face donor) versus `<image2>` (body and scene donor).
---
## 2. Comparative Benchmark: Reference Strategies for Single Person Identity
| Reference Strategy | Likeness Accuracy | Skin Details & Age | Compositional Stability | Execution Speed | Overall Rating || :--- | :--- | :--- | :--- | :--- | :--- || **Single Image (`<image1>`)** | **9.8 / 10** | **Outstanding** (pores, freckles, micro-wrinkles) | **10 / 10** (Clean solo generation) | **Fastest (~8–10s)** | ⭐⭐⭐⭐⭐ **Optimal Standard** || **Dual Image (`<image1>`, `<image2>` for 1 person)** | 7.5 / 10 | Good, but slight smoothing | 8.5 / 10 (Occasional duplicate person) | Moderate (~10–12s) | ⭐⭐⭐ Average || **Quad Image (`<image1>`..`<image4>` for 1 person)** | 6.0 / 10 | Mediocre (attention dilution) | 6.5 / 10 (Risk of collage/multi-person) | Slower (~12–14s) | ⭐⭐ Suboptimal || **2x2 Grid (`1024x1024` single file)** | 6.5 / 10 | Blurry micro-features (256px effective face) | 5.5 / 10 (High grid leak risk) | Moderate (~11s) | ⭐⭐ Inconsistent || **3x3 Grid (`1536x1536` single file)** | 5.0 / 10 | Washed out, averaged facial features | 4.0 / 10 (Frequent split-screen failure) | Slowest (~17–20s) | ❌ Not Recommended |
---
## 3. In-Depth Analysis of Failure Modes
### A. Why Multi-Image References Fail for Single SubjectsWhen you connect multiple `LoadImage` nodes (e.g., `<image1>`, `<image2>`, `<image3>`, `<image4>`) into `TextEncodeQwenImage21` and prompt:> *"A portrait of the woman in <image1>, <image2>, <image3>, and <image4>..."*
The Qwen3-VL Vision Transformer (ViT) encounters three distinct issues:1. **Token Dilution**: Each reference image consumes a large slice of visual tokens. As token count increases, the cross-attention weights per patch decrease, reducing the sharp gradient signal for distinct facial landmarks (nose bridge, eye shape, chin contours).2. **Attention Dominance Bias**: Qwen3-VL rarely blends 4 images evenly; instead, it latches onto the image with the highest contrast or largest face area, ignoring the others or producing a flickering hybrid.3. **Multi-Person Hallucination**: The model’s pretraining associates multiple `<imageN>` tags with multi-person scenes. Consequently, prompting 4 images frequently causes the model to generate multi-character collages or twin figures.
### B. Why Composite Grids (2x2 / 3x3) FailTiling multiple photos into a single large canvas (`aneta_grid_4x_1024.png` or `aneta_grid_9x_1536.png`) creates fundamental vision-processing flaws:1. **Spatial Resolution Loss**: A 512x512 photo packed into a 2x2 grid is reduced to 256x256 effective resolution when downscaled by ViT patching. Micro-details (eyelashes, skin pores, natural freckles, iris texture) are lost.2. **Compositional Prior Leakage**: The ViT sees grid lines and distinct quad/nine-block layouts. Even with heavy negative prompting (`negative_prompt: "collage, 2x2 grid, 3x3 grid, split screen"`), the diffusion denoiser often inherits grid borders, split-lighting, or fractured backgrounds.3. **Feature Averaging (The "Generic Face" Effect)**: Instead of preserving the specific distinctive traits of a person, the model averages the disparate angles into a smoothed, generic approximation.
---
## 4. The Golden Rule: 1 Reference Image per Subject
### Best Practices for Selecting the Single Reference Image:- **Framing**: Clean bust, head-and-shoulders, or close-up portrait.- **Lighting**: Neutral, well-exposed lighting without harsh clipping or heavy artistic shadows.- **Gaze**: Front-facing or slight 3/4 angle with clear, open eyes looking towards camera.- **Resolution**: Sharp 512x512, 768x768, or 1024x1024 original crop centered on the face.- **Expression**: Natural relaxed expression or gentle smile (avoid extreme grimaces or obstructed faces).
---
## 5. Master Prompting Templates
### Template 1: Precision Face-Swap / Identity Replacement onto Target PhotoUse this template when transferring a person's exact face onto an existing photo (`<image2>`), preserving 100% of the body, clothing, lighting, and background from `<image2>`.
```textPrompt:In <image2>, replace the person's face with the face, identity, exact likeness, age, and natural skin details of the woman in <image1>. Keep everything else in <image2> completely unchanged: preserve the exact body, figure, seated pose, bikini/clothing, sand, shoreline, water, overcast sky, natural lighting, composition, and background environment exactly as they appear in <image2>. Apply the exact facial features, striking bright blue eyes, natural skin texture with subtle blush, facial bone structure, and sandy blonde hair style from <image1>, looking directly into the camera lens with a gentle natural smile. High resolution, seamless photo blend, 8k quality, ultra realistic skin details.
Negative Prompt:multiple people, collage, split image, split screen, duplicate, extra person, altered body, altered pose, altered clothing, altered background, distorted face, bad anatomy, deformed, cartoon, 3d render, blurry, artifacts```
### Template 2: Single-Subject Photorealistic Scene GenerationUse this template when generating a completely new scene for a subject based on a single reference photo.
```textPrompt:A stunning professional portrait photo of the woman shown in <image1> [SCENE DESCRIPTION: on an exotic sandy beach at sunset during golden hour]. Preserve her exact facial likeness, distinctive facial bone structure, [SPECIFIC EYE COLOR: striking bright blue eyes], [SPECIFIC COMPLEXION: fair skin with natural light blush], authentic age, and [SPECIFIC HAIR: sandy blonde hair with short sides] from <image1>. She is facing forward, looking straight directly into the camera lens with direct eye contact, smiling warmly with a happy, radiant, genuine smile. She is wearing [WARDROBE: a casual cream linen sundress]. [LIGHTING & ATMOSPHERE: Warm golden hour sunset glow on the wet sand and turquoise ocean waves in the background, shallow depth of field, 85mm f/1.4 lens bokeh, ultra realistic 8k, photorealistic masterpiece].
Negative Prompt:multiple people, collage, split image, split screen, duplicate, extra person, looking away, side glance, looking down, serious expression, frowning, neutral expression, closed eyes, deformed, bad anatomy, cartoon, 3d render, blurry, ugly```
### Template 3: Dual-Subject Shared Scene (1 Reference per Person)Use this template when generating two distinct people together in a single unified scene.
```textWiring:- LoadImage (Input 1) -> <image1> = Person A (e.g., Aneta)- LoadImage (Input 2) -> <image2> = Person B (e.g., Gosia)
Prompt:A high-end realistic photograph of the two women together on a tropical beach at sunset during golden hour.The blonde woman from <image1> is standing on the left side, preserving her exact facial likeness, striking bright blue eyes, fair complexion, authentic skin texture, age, and sandy blonde hair with short sides from <image1>, wearing a casual cream linen sundress.The brunette woman from <image2> is standing on the right side, preserving her exact facial likeness, warm dark eyes, facial structure, authentic skin details, age, and short dark brunette hair from <image2>, wearing a light blue linen shirt and matching summer shorts.They are standing together side-by-side near the gentle ocean waves, smiling happily and looking straight directly into the camera. Fully clothed casual summer beachwear.Warm golden hour lighting, wet reflective beach sand, shallow depth of field, 35mm photography, 8k resolution, ultra realistic skin details, masterpiece.
Negative Prompt:bikini, swimsuit, nude, topless, underwear, cartoon, 3d render, anime, painting, deformed, bad anatomy, bad hands, extra limbs, missing limbs, fused bodies, blurry, ugly, low quality, artifacts```
---
## 6. Summary Checklist for Maximum Quality
1. ✅ **Always use 1 reference image per person** (never stack multiple references or grids for a single persona).2. ✅ **Explicitly list distinctive biometrics in text** (eye color, hair style, skin tone, facial contours, age) to anchor Qwen3-VL cross-attention.3. ✅ **Lock camera gaze and expression explicitly** (`"looking straight directly into the camera lens with direct eye contact, smiling warmly"`).4. ✅ **In face-swaps, use strict preservation clauses** (`"Keep everything else in <image2> completely unchanged: preserve the exact body, pose, clothing, and background..."`).5. ✅ **Use clean negative prompts** prohibiting collages, split-screens, and altered bodies.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118# Qwen-Image 2.1: RefMod Compatibility & Vision-Language Architecture Analysis
_Version: 1.0.0_ _Last Updated: September 2026_ _Target Architecture: Qwen-Image 2.1 (`qwen_image_2.1_int8_convrot.safetensors` + `qwen3vl_8b_int8_convrot.safetensors` / `TextEncodeQwenImage21`)_
---
## 1. Executive Summary
In systems like **MiniMax-H3** (`ComfyUI-MiniMaxH3Mod`) and **FLUX.2 / Klein 9B** (`ComfyUI-Flux2Klein9Mod`), **RefMods (`.safetensors`)** are established as the state-of-the-art method for identity and character locking. A RefMod extracts compressed spatial latents via a 2D/3D VAE and injects those latents directly into diffusion transformer (DiT) conditioning streams.
However, **it is fundamentally not possible to apply RefMod `.safetensors` adapters to Qwen-Image 2.1 in the same manner**.
This document outlines the architectural and mathematical reasons why Qwen-Image 2.1 relies on live **Vision-Language Model (VLM) patch projection (Qwen3-VL)** rather than pre-computed VAE latent injection, and how its multimodal conditioning pipeline operates.
---
## 2. Comparative Architecture Matrix
| Dimension | MiniMax-H3 (`h3-center`) | FLUX.2 / Klein 9B (`klein9`) | Qwen-Image 2.1 (`qwen`) || :--- | :--- | :--- | :--- || **Text/Prompt Encoder** | Truncated Qwen3-VL-32B (Text only) | T5-XXL / CLIP-L | **Qwen3-VL-8B (Joint Vision-Language)** || **Image Reference Input** | VAE Encoded 3D Latents | VAE Encoded 2D Latents | **ViT Raw Pixel Patch Embeddings** || **Latent Space of Reference** | MiniMax 3D Video VAE (`fp16`) | FLUX.2 VAE (`fp8/bf16`) | **Qwen3-VL Vision Transformer (ViT)** || **Conditioning Mechanism** | DiT Cross-Attention / Latent Concat | Dual-Stream Attention Injection | **Multimodal Text+Vision Token Sequence** || **Reference File Type** | `.safetensors` RefMod (1.1–1.6 MB) | `.safetensors` RefMod (800 KB–2 MB) | **Raw PNG/JPEG/WEBP image files** || **Tagging Syntax** | `<Subject 1>` (semantic binding) | `<subject_1>` (attention slot) | **`<image1>`, `<image2>`, `<image3>`, ...** || **Token Ingestion Point** | DiT Backbone Cross-Attention | DiT Dual-Stream Attention | **Text Encoder Embedding Space** |
---
## 3. Why RefMods Work in MiniMax-H3 & FLUX.2 / Klein 9B
In MiniMax-H3 and FLUX.2 / Klein 9B, the conditioning pipeline separates text processing from visual latent processing:
```text[ Raw Dataset Images ] │ ▼ (Pre-computation via extract_mod.py) [ 2D/3D VAE Encode ] ───► Extracted Spatial Latents (e.g. 16×128×128 tensor) │ ▼ [ .safetensors RefMod ] ───► Saved to disk (~1.1 MB)
[ Generation Time ]: [ RefMod .safetensors ] ──► [ RefModLoader Node ] ──► Injected directly into DiT Conditioning```
### Key Properties of VAE RefMods:1. **Direct VAE Latent Compatibility**: The DiT denoiser natively operates in the exact same latent space defined by the VAE.2. **Static Tensor Arrays**: The pre-encoded latents represent invariant spatial feature maps that do not depend on prompt tokenization or linguistic context.3. **Zero Vision Transformer Involvement**: The text encoder never sees the reference images; it only produces text tokens, while the DiT cross-attention layers attend to the pre-encoded VAE latent tokens.
---
## 4. Why RefMods Cannot Be Applied to Qwen-Image 2.1
Qwen-Image 2.1 utilizes an fundamentally different, tightly coupled **Vision-Language Multimodal Architecture**:
```text[ Prompt String with <imageN> tags ] ──┐ ├─► [ Qwen3-VL-8B Multimodal Encoder ] ──► [ Unified Token Sequence ] ──► [ Qwen DiT Denoiser ][ Raw Input Images (image_1..image_N) ] ──┘ (ViT Patch + MLP Projection)```
### 1. The Vision-Language Tokenizer BarrierIn Qwen-Image 2.1, conditioning is created by the `TextEncodeQwenImage21` node (`Qwen3-VL-8B`). When reference images are connected to inputs `images.image_1`, `images.image_2`, etc.:- The image pixels are divided into patches (e.g., $14 \times 14$ or $28 \times 28$) and processed through the **Qwen3-VL Vision Transformer (ViT)**.- An MLP projector aligns the vision representations into the **word-embedding dimension** of the Qwen3 language model.- The visual tokens are spliced directly into the text sequence at the exact positions corresponding to the `<image1>`, `<image2>` tags.
### 2. Semantic Contextual InteractionUnlike a static VAE tensor, Qwen3-VL visual tokens undergo **bidirectional self-attention layers alongside the accompanying prompt text**:- The phrase `"the blonde woman in <image1> on the beach wearing a sundress"` actively modulates how the Qwen3-VL layers interpret the visual tokens of `<image1>`.- The language model contextualizes facial contours, hair color, and identity attributes in direct relation to the surrounding prompt instructions before sending the unified embedding sequence to the diffusion transformer.
### 3. VAE Latent Incompatibility- The VAE in Qwen-Image 2.1 (`qwen_image_2.1_vae_bf16.safetensors`) is **only used to encode the initial noise canvas and decode the final generated latent**.- The conditioning input of the Qwen DiT does **not** accept raw VAE latents as identity guidance. It exclusively accepts the multimodal embedding sequence produced by `Qwen3-VL`.- Storing VAE latents in a `.safetensors` file (as in RefMods) is therefore useless for Qwen-Image 2.1, because the model requires **ViT-projected multimodal sequence embeddings**, not VAE latents.
### 4. Why Pre-Encoding ViT Embeddings Is ImpracticalOne might ask: *Can we pre-encode the Qwen3-VL ViT tokens into a .safetensors file instead?*- In practice, Qwen3-VL visual tokens are context-dependent and interact dynamically with the prompt sentence structure and positional encoding.- Furthermore, raw image files (PNG/JPEG/WEBP) are already loaded and projected by Qwen3-VL in a fraction of a second (~0.2s) without the VRAM bottlenecks that plague 3D video VAEs.- Consequently, providing the direct image file to `TextEncodeQwenImage21` is already the fastest, most expressive, and native interface for the model.
---
## 5. Architectural Summary Table
```text┌──────────────────────────────────────────────────────────────────────────────────┐│ MINIMAX-H3 / FLUX.2 KLEIN 9B ││ ││ [ Dataset Images ] ──(VAE)──► [ .safetensors RefMod ] ──► [ DiT Cross-Attn ] ││ (Pre-computed static VAE latents injected directly into DiT conditioning) │└──────────────────────────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────────────────────┐│ QWEN-IMAGE 2.1 ││ ││ [ Text Prompt ] ───────┐ ││ ├─► [ Qwen3-VL Multimodal Encoder ] ──► [ DiT Denoiser ]││ [ Raw Image <imageN> ] ┘ (Joint ViT + Text Projection) │└──────────────────────────────────────────────────────────────────────────────────┘```
---
## 6. Recommendations for Identity Workflows
For production workflows in Qwen-Image 2.1:1. **Do not attempt to convert VAE RefMods** from MiniMax-H3 or FLUX.2 for use in Qwen-Image 2.1.2. Use **direct image inputs** (`LoadImage` $\to$ `TextEncodeQwenImage21`).3. Follow the **1 Reference Image = 1 Subject Standard** detailed in `QWEN_IMAGE_21_REFERENCE_STRATEGY_AND_PROMPTING_GUIDE.md`.4. When true standalone weight adaptation is required (without passing reference images at runtime), train a dedicated **Qwen-Image 2.1 LoRA** using AI-Toolkit or OneTrainer.README.md+15
qwen/README.mdAdded+25
qwen/docs/QWEN_IMAGE_21_REFERENCE_STRATEGY_AND_PROMPTING_GUIDE.mdAdded+113
qwen/docs/QWEN_IMAGE_21_REFMOD_COMPATIBILITY_AND_VISION_ENCODER_ARCHITECTURE.mdAdded+118