cd /news/artificial-intelligence/fix-ideogram-4 · home topics artificial-intelligence article
[ARTICLE · art-86867] src=promptcube3.com ↗ pub= topic=artificial-intelligence verified=true sentiment=· neutral

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.

read2 min views1 publishedAug 4, 2026
Fix: Ideogram 4.
Image: Promptcube3 (auto-discovered)

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

  1. 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:

encoded = tokenizer(prompt, padding="max_length", max_length=256, truncation=True)

encoded = tokenizer(prompt, padding="longest", truncation=True, return_tensors="pt")
max_len = encoded.input_ids.shape[1]
model.resize_position_embeddings(max_len)
  1. In model_config.json

, set "max_position_embeddings": 203

to match the checkpoint

  1. 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 →

a library of Claude prompt techniques, with plenty of directly applicable cases.

── more in #artificial-intelligence 4 stories · sorted by recency
── more on @ideogram 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/fix-ideogram-4] indexed:0 read:2min 2026-08-04 ·