Fix: Ideogram 4. A ComfyUI custom node for Ideogram 4.0 failed to render spatial prompts due to a text encoder token padding mismatch, causing errors like 'expected hidden_states dim [1, 256, 1024], got [1, 203, 1024]'. The fix involved changing padding to 'longest', resizing position embeddings dynamically, and setting 'max_position_embeddings' to 203 in model_config.json, which restored bounding box alignment and clean text rendering on consumer hardware. The patch is slower than the cloud API (18s vs 6s on a 4090) and spatial prompt syntax remains imperfect. Fix: Ideogram 4. The Actual Error When invoking the Ideogram node with spatial prompts like "A sign reading 'OPEN' hanging above a door" , the server log spat this out: ERROR Text encoding failed: expected hidden states dim 1, 256, 1024 , got 1, 203, 1024 WARN Bounding box projection skipped — token alignment broken The node loads the model fine, but the text encoder's token padding length doesn't match what the unet expects. This kills spatial bounding boxes and any prompt with more than ~4 words. Diagnosis I compared the custom node's model config.json against Ideogram's reference implementation. Two issues: 1. The node forces max position embeddings: 256 while the local checkpoint was trained with 203 2. The tokenizer pads to the config value instead of detecting the actual sequence length Swapping to dynamic padding based on the real token count fixed the dimension mismatch. I also had to patch the bounding box sampler to re-align tokens after truncation. Steps That Worked 1. Clone the node into ComfyUI/custom nodes/ 2. Edit nodes/ideogram node.py — replace the static padding with: Before broken encoded = tokenizer prompt, padding="max length", max length=256, truncation=True After fixed encoded = tokenizer prompt, padding="longest", truncation=True, return tensors="pt" max len = encoded.input ids.shape 1 Resize position embeddings if needed model.resize position embeddings max len 3. In model config.json , set "max position embeddings": 203 to match the checkpoint 4. Restart ComfyUI — the node now preserves character counts and bounding box alignment What Still Isn't Perfect The local run is noticeably slower than the cloud API batch size 1 on a 4090 takes ~18s vs ~6s . Also, I haven't cracked exact spatial prompt syntax yet — "text above image" sometimes renders below. If anyone has the correct token-bounding format for local Ideogram 4.0, I'm all ears. For now, this patch delivers clean text rendering and functional bounding boxes on consumer hardware. I'll push the fork once I clean up the sampler fix. Next XXO-Bench → /en/threads/5001/ a library of Claude prompt techniques http://154.12.95.112/ , with plenty of directly applicable cases.