ComfyUI-H3-Text-Encoders
Zero-gradient Orthogonal Procrustes & Ridge (Plato's Key) text encoder adapters to use Qwen 3.5, Qwen 3.8, Gemma 4, and more with MiniMax-H3 (T2VA/Image, FL2VA, Ref2VA) in ComfyUI.
ComfyUI-H3-Text-Encoders
[!IMPORTANT] NEW (
v0.1.8) — ALL 6v4 Clean Sink-Free Multi-Layer (4-Layer Concat) Ridgecross-family keys are LIVE (Gemma 4 31B: 95.78% cos,26B-A4B MoE: 95.24%,E4B: 95.14%,E2B: 94.93%,Inkling-2-Mini: 94.80%,12B: 93.42%), PLUS unified ComfyUI-native single-fileGemma 4 31Btext encoders (bf16,int8_convrot,w4a8,nvfp4) andv3 Direct-32B Streaming Ridgefor all Qwen 3.5 & Qwen 3.8 27B (0.985–0.992 R²)!
- Recommendation: use
*_pk_ridge_*.safetensorsfor Qwen 3.5 / 3.8 and*_pk_ridge_4layer_*.safetensorsfor Gemma 4 & Inkling-2-Mini (strength = 1.0).
[!WARNING] Upgrading from early releases (
< v0.1.8)? Please update your custom node (cd ComfyUI/custom_nodes/ComfyUI-H3-Text-Encoders && git pullor update via ComfyUI Manager) and restart ComfyUI! Recent updates (v0.1.5–v0.1.8) added critical fixes (options_defaulttuple parity, Gemma 4<bos>sink handling, Multi-Layerdonor_layers, andtext_encoders/dropdown scanning inPlatosKeyHFTextEncoderLoader). If you downloaded early single-layer Gemma 4 keys, replace them with the new*_pk_ridge_4layer_*.safetensorskeys!
[!NOTE] Spoken Dialogue / Speech Audio Note (Cross-Family Encoders):
- For crisp spoken dialogue & lip-sync: use Qwen 3.5 (
9B/2B/4B/0.8B) or Qwen 3.827B— they share the exact BPE tokenizer with nativeQwen3-VL-32Band are calibrated 1:1 per token, preserving crystal-clear English speech.- Cross-family encoders (
Gemma 4/Inkling-2-Mini): v4 keys excel at visuals, motion, Ref2VA identity, and ambient SFX, but spoken dialogue can currently sound garbled/gibberish due to coarse 12-bin pooling across different tokenizers. We are actively working on av5exact word-span (offset_mapping) + dialogue-enriched calibration to fix spoken dialogue on Gemma 4!
Use modern ComfyUI-native text encoders (Qwen 3.5 0.8B / 2B / 4B / 9B, Qwen 3.8 27B, Google Gemma 4) — or any HuggingFace LLM/VLM (like Inkling-2-Mini or Gemma 4 26B-A4B) — as a conditioning encoder for MiniMax-H3 (T2VA / Image-to-Video, FL2VA, and Ref2VA) in ComfyUI — zero gradient training, zero LoRA, and zero external MLP weights.
Powered by Plato's Key (closed-form Ridge & Multi-Layer Ridge, inspired by Stanford Hazy Research's Plato's Key), each adapter is a compact .safetensors key (~20–157 MB) that projects a donor encoder's hidden states directly into MiniMax-H3's native 5,120-dim Qwen3-VL-32B geometric space:
$$\hat{Y} = (X - \mu_{\text{donor}}) W + \mu_{\text{target}}, \qquad W = (X_c^\top X_c + \lambda I)^{-1} X_c^\top Y_c$$
All downstream MiniMax-H3 nodes (MiniMaxH3ReferenceToVideo, MiniMaxH3ImageToVideo, SamplerCustomAdvanced, VAEDecode) work out of the box.
Key Engineering Breakthroughs
- Closed-Form Ridge >> Orthogonal Procrustes on MiniMax-H3: MiniMax-H3's native 5,120-dim
Qwen3-VL-32Bspace (layer 50, unnormalized) has strong anisotropic outlier channels. Rigid isotropic Procrustes stops atR² ≈ 0.04, whereas closed-form Ridge scales each channel independently, reachingR² = 0.990–0.992(147× lower MSE) on Qwen 3.5 & Qwen 3.8. - Multi-Layer Plato's Key (
4-Layer Concat) Unlocks Cross-Family Gemma 4: Single-layer linear maps across different architectures/tokenizers (Google Gemma 4 → Qwen3-VL-32B) hit a ceiling (~70% cos). Concatenating 4 evenly-spaced transformer layers (e.g.,[-2, -10, -18, -26]→10,240 → 5,120) before a single closed-form Ridge projection jumps Gemma 4 to93.4–95.2%cosine (26B-A4B MoE: 95.24%,E4B: 95.14%,E2B: 94.93%,12B: 93.42%) with zero gradient training and zero extra forward passes in ComfyUI! - Token-0 Attention Sink Filtering (
v4Clean 20k): UnnormalizedQwen3-VL-32Blayer 50 puts a massive attention sink on token 0 (rms ≈ 18.25, max > 3,000vsrms ≈ 3.42for normal text). Dropping bin 0 during cross-family bin-pooled calibration eliminates a 33× Frobenius blow-up inW, cutting MSE by 42× (59.2 → 1.40) and liftingGemma 4 E4Bto95.14%cosine (p10 = 87.91%)! - Exact ComfyUI CLIP Parity (
v0.1.5+): Automatically enforcesoptions_defaulttuple override, layer &RMSNormparity,llama_template="{}", LTXVmin_length=1padding strip, Gemma 4<bos>attention-sink retention (stripping token 0 post-encode), andminimax_token_tags. - Universal HuggingFace Loader (
v0.1.6):Plato's Key Load Any HF Text Encoder (H3)loads anytransformersLLM/VLM (even models without a native ComfyUICLIPLoader, likethinkingmachines/Inkling-2-Mini) with automatic single- or multi-layer projection and automatic CPU offload to keep 100% of VRAM free for the H3 DiT.
Visual Comparison (Zero-Gradient Ridge, No LoRA, No MLP)
4-Way Ref2VA — Native 32B vs Qwen 3.5 9B/2B vs Google Gemma 4 E4B (4-Layer, strength = 1.0)

Multi-Layer 4-Way Video Showcase (Gemma 4 Before/After + Parisian Café Ref2VA + Swiss Alps Train T2VA)
- Watch / download the 3-segment 4-way comparison video (
showcase/H3_PlatosKey_MultiLayer_4Way_Showcase.mp4) — featuring Gemma 4 E4B 1-Layer vs 4-Layer Clean, Parisian Café Ref2VA (Native 32B|Qwen 3.5 9B|Gemma 4 E4B 4L|Gemma 4 E2B 4L), and Swiss Alps Steam Train Pure T2VA (Native 32B|Qwen 3.5 9B|Qwen 3.5 2B|Gemma 4 E4B 4L) atstrength = 1.0.
10-Second 6-Way Action Stress Test (3 Model Families: Qwen + Google Gemma 4 + Inkling-2-Mini)
- Watch / download the 20s 6-way action showcase (
showcase/H3_PlatosKey_10s_6Way_Action_Showcase.mp4) — fixed seed,strength = 1.0, full prompts on screen, comparingNative 32B|Qwen 3.5 9B|Gemma 4 31B|Gemma 4 26B-A4B MoE|Gemma 4 E4B|Inkling-2-Miniacross 10s Tokyo Neon Rain (Ref2VA) and 10s Medieval Blacksmith Forge (Pure T2VA).
Pre-Calibrated Weights & Direct Download Links
All .safetensors Plato's Key adapters live in Alissonerdx/TE-PK-Minimax-H3 (calibrated on 20,029 prompts directly to Native Qwen3-VL-32B Layer 50).
Text Encoder Downloads & Matching Plato's Keys
| Encoder | ComfyUI Loader | Text Encoder Download (HuggingFace) | Method | Val Cos | Key File (Alissonerdx/TE-PK-Minimax-H3) |
|---|---|---|:---:|---:|---|
| Qwen 3.5 9B | CLIPLoader + PlatosKeyPatchCLIP | Comfy-Org/Qwen3.5 (qwen3.5_9b_int8_convrot.safetensors 9.8 GB / bf16 19.3 GB) | Ridge (-1) | 93.05% (R² 0.9905) | minimax_h3_32b_pk_ridge_qwen3.5_9b.safetensors |
| Qwen 3.5 2B | CLIPLoader + PlatosKeyPatchCLIP | Comfy-Org/Qwen3.5 (qwen3.5_2b_bf16.safetensors 4.6 GB) | Ridge (-1) | 92.57% (R² 0.9916) | minimax_h3_32b_pk_ridge_qwen3.5_2b.safetensors |
| Qwen 3.5 4B | CLIPLoader + PlatosKeyPatchCLIP | Comfy-Org/Qwen3.5 (qwen3.5_4b_bf16.safetensors 9.3 GB) | Ridge (-1) | 91.82% (R² 0.9902) | minimax_h3_32b_pk_ridge_qwen3.5_4b.safetensors |
| Qwen 3.5 0.8B | PlatosKeyHFTextEncoderLoader | Qwen/Qwen3.5-0.8B | Ridge (-1) | 91.11% (R² 0.9901) | minimax_h3_32b_pk_ridge_qwen3.5_0.8b.safetensors |
| Qwen 3.8 27B | CLIPLoader + PlatosKeyPatchCLIP | Comfy-Org/Qwen3.8-27B (qwen3.8_27b_w4a8.safetensors 17.3 GB) | Ridge (-1) | 89.94% (R² 0.9846) | minimax_h3_32b_pk_ridge_qwen3.8_27b.safetensors |
| Gemma 4 26B-A4B (MoE) | PlatosKeyHFTextEncoderLoader | google/gemma-4-26B-A4B-it | 4L Ridge | 95.24% (p10 87.9%) | minimax_h3_32b_pk_ridge_4layer_gemma4_26b_a4b.safetensors |
| Gemma 4 E4B ⭐ | CLIPLoader + PlatosKeyPatchCLIP | Comfy-Org/gemma-4 (gemma4_e4b_it_int8_convrot.safetensors 8.1 GB / fp8 9.1 GB / bf16 16.0 GB) | 4L Ridge | 95.14% (p10 87.9%) | minimax_h3_32b_pk_ridge_4layer_gemma4_e4b.safetensors |
| Gemma 4 E2B ⭐ | CLIPLoader + PlatosKeyPatchCLIP | Comfy-Org/gemma-4 (gemma4_e2b_it_int8_convrot.safetensors 5.2 GB / bf16 10.3 GB) | 4L Ridge | 94.93% (p10 87.5%) | minimax_h3_32b_pk_ridge_4layer_gemma4_e2b.safetensors |
| Gemma 4 12B (experimental) | CLIPLoader + PlatosKeyPatchCLIP | Comfy-Org/gemma-4 (gemma4_12b_int8_convrot.safetensors 12.1 GB) | 4L Ridge | 93.42% (p10 82.8%, ⚠️ weaker) | minimax_h3_32b_pk_ridge_4layer_gemma4_12b.safetensors |
| Gemma 4 31B 🏆 | CLIPLoader + PlatosKeyPatchCLIP | Alissonerdx/TE-PK-Minimax-H3/text_encoders (nvfp4 19.1 GB / w4a8 19.1 GB / int8_convrot 31.9 GB / bf16 62.6 GB) | 4L Ridge | 95.78% (p10 89.5%) | minimax_h3_32b_pk_ridge_4layer_gemma4_31b.safetensors |
| Inkling-2-Mini | PlatosKeyHFTextEncoderLoader | thinkingmachines/Inkling-2-Mini | 4L Ridge | 94.80% (p10 88.4%) | minimax_h3_32b_pk_ridge_4layer_inkling2_mini.safetensors |
[!TIP] Plug & Play recommendation: For native ComfyUI
CLIPLoader(single.safetensorsinComfyUI/models/text_encoders/), start withGemma 4 E4B(8.1 GB int8or9.1 GB fp8, 95.14% cos),Gemma 4 E2B(5.2 GB int8, 94.93% cos), orQwen 3.5 9B / 2B. For sharded HuggingFace models (google/gemma-4-31B-it,google/gemma-4-26B-A4B-it,thinkingmachines/Inkling-2-Mini), use ourPlato's Key Load Any HF Text Encoder (H3)node directly.
Step-by-Step Setup (Where to Place Files)
- Install this custom node:
cd ComfyUI/custom_nodes
git clone https://github.com/alisson-anjos/ComfyUI-H3-Text-Encoders.git
cd ComfyUI-H3-Text-Encoders
pip install -r requirements.txt
-
Download a Text Encoder from the table above and place single-file
.safetensorsmodels inComfyUI/models/text_encoders/(or skip manual downloads for any HuggingFace repo by usingPlato's Key Load Any HF Text Encoder (H3)). -
Download the matching
.safetensorskey fromAlissonerdx/TE-PK-Minimax-H3and place it inComfyUI/models/clip_projections/:
ComfyUI/models/
├── text_encoders/
│ ├── qwen3.5_9b_int8_convrot.safetensors
│ └── gemma4_e4b_it_fp8_scaled.safetensors
└── clip_projections/
├── minimax_h3_32b_pk_ridge_qwen3.5_9b.safetensors
└── minimax_h3_32b_pk_ridge_4layer_gemma4_e4b.safetensors
- Restart ComfyUI and wire:
- Native ComfyUI encoders:
Load CLIP→Plato's Key Patch CLIP (H3 Plug & Play)(strength = 1.00,apply_to_pooled = False) →MiniMax H3 Reference to Video/MiniMax H3 Image to Video. - Any HuggingFace model:
Plato's Key Load Any HF Text Encoder (H3)(model_id,key_file,offload_to_cpu = True) →MiniMax H3 Reference to Video/MiniMax H3 Image to Video.
- Native ComfyUI encoders:
Included ComfyUI Nodes (conditioning/platos_key)
Plato's Key Patch CLIP (H3 Plug & Play): Drop-in wrapper for native ComfyUICLIPLoader(auto layer, multi-layerdonor_layers,RMSNorm,<bos>, andminimax_token_tagsparity).Plato's Key Load Any HF Text Encoder (H3): Loads anytransformersmodel from HuggingFace or disk, applies single- or multi-layer Plato's Key, and auto-offloads to CPU after encoding.Plato's Key Apply (Procrustes): Projects an existingCONDITIONINGtensor directly.Plato's Key CLIP Text Encode: One-step text encode + Plato's Key projection.
Calibration & Conversion Script (Create Your Own Key — Zero Gradients)
Convert any HuggingFace text encoder in minutes with calibrate_platos_key.py (--method ridge by default, with automatic held-out λ selection):
python calibrate_platos_key.py \
--donor Qwen/Qwen3.5-2B \
--target Qwen/Qwen3.5-9B \
--method ridge \
--align token \
--output keys/my_ridge_key.safetensors
Python API (platos_key_core.py)
from platos_key_core import fit_ridge_key, evaluate_platos_key, save_platos_key
key = fit_ridge_key(x_donor_train, x_target_train, ridge_lambda=100.0)
metrics = evaluate_platos_key(x_donor_val, x_target_val, key)
save_platos_key(key, "ComfyUI/models/clip_projections/my_custom_key.safetensors")
License
Apache 2.0 — see LICENSE. Inspired by Stanford Hazy Research's Plato's Key.