Skip to content

Add from_single_file() support for Ideogram4 transformer - #14126

Open
buffett0323 wants to merge 10 commits into
huggingface:mainfrom
buffett0323:fix/single-file-ideogram4-krea2
Open

buffett0323 wants to merge 10 commits into
huggingface:mainfrom
buffett0323:fix/single-file-ideogram4-krea2

Conversation

@buffett0323

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds from_single_file() support for Ideogram4Transformer2DModel and
Krea2Transformer2DModel.

Fixes #14122

Before submitting

Who can review?

@sayakpaul @yiyixuxu @DN6

@github-actions github-actions Bot added documentation Improvements or additions to documentation models tests single-file fixes-issue size/L PR with diff > 200 LOC labels Jul 6, 2026
@sayakpaul
sayakpaul requested a review from DN6 July 6, 2026 02:42
checkpoint[k.replace("model.diffusion_model.", "")] = checkpoint.pop(k)

return checkpoint

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a check to infer the model type automatically

def infer_diffusers_model_type(checkpoint):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DN6
Sure, I just added in my newest commit, please check, thanks!

@buffett0323
buffett0323 force-pushed the fix/single-file-ideogram4-krea2 branch from ca7e3e7 to b741167 Compare July 9, 2026 05:45
@buffett0323

Copy link
Copy Markdown
Contributor Author

@DN6 Sorry to bother you, I updated the code changes. I would appreciate your help for reviewing, thanks for your time!

@spartanz51

spartanz51 commented Jul 21, 2026 •

Copy link
Copy Markdown

Ran into a gap while testing GGUF loading on top of this branch: the community GGUF exports (vantagewithai, realrebelai) keep the native krea-ai/krea-2 key names (prenorm/postnorm.scale, attn.qknorm.*, flat mod.lin, first/tmlp/tproj/txtmlp/last), which fall through remap_key and fail on meta tensors. Opened #14264 on top of your branch with the extra mappings

Feel free to cherry-pick into this PR if you'd rather keep everything in one place.

@buffett0323

buffett0323 commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@DN6 Pushed an update, cherry-picked #14264 from @spartanz51 to add support for the native krea-ai/krea-2 key layout used by community GGUF exports. Ready for another look whenever you have time, thanks!

@hameerabbasi

Copy link
Copy Markdown
Contributor

cc @DN6 Having this in would be nice.

@buffett0323

Copy link
Copy Markdown
Contributor Author

Hi @DN6 , Sorry to bother you again, gentle reminder for this PR whenever you get a chance! Let me know if you have any questions or feedback. Thanks again for your help!!

@O-J1

O-J1 commented Oct 12, 2026

Copy link
Copy Markdown

Hi @DN6 we have end users asking about this and having this feature (assuming the code is acceptable) would be great, any chance of this getting merged?

@github-actions github-actions Bot removed the models label Oct 17, 2026
@buffett0323

Copy link
Copy Markdown
Contributor Author

Hi @DN6 , Sorry to bother you again, gentle reminder for this PR whenever you get a chance! I solved the conflict against main, please let me know if you have any questions or feedback. Thanks again for your help!!

@hameerabbasi hameerabbasi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were a bunch of issues in the merge commit. I'd resolve these before proceeding, this PR removes code that in principle shouldn't be touched as it stands.

Comment on lines -153 to -160
"flux3": [
"model.diffusion_model.early_stream_modulations.image.lin.weight",
"early_stream_modulations.image.lin.weight",
],
"flux3-distilled": ["model.diffusion_model.ref_time_in.in_layer.weight", "ref_time_in.in_layer.weight"],
"chroma": [
"model.diffusion_model.distilled_guidance_layer.in_proj.bias",
"distilled_guidance_layer.in_proj.bias",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These probably shouldn't be dropped.

Comment on lines -255 to +252
"qwen-image-2.1": {"pretrained_model_name_or_path": "Qwen/Qwen-Image-2.1"},
"krea2": {"pretrained_model_name_or_path": "krea/Krea-2-Raw"},
"minimax-h3": {"pretrained_model_name_or_path": "MiniMaxAI/MiniMax-H3"},
"ideogram4": {"pretrained_model_name_or_path": "ideogram-ai/ideogram-v4"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Comment on lines -704 to -709
elif any(key in checkpoint for key in CHECKPOINT_KEY_NAMES["flux3"]):
# the step-distilled (flow-map) checkpoint carries a second timestep embedder
if any(key in checkpoint for key in CHECKPOINT_KEY_NAMES["flux3-distilled"]):
model_type = "flux-3-image-distilled"
else:
model_type = "flux-3-image"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

Comment on lines -711 to -712
elif any(key in checkpoint for key in CHECKPOINT_KEY_NAMES["chroma"]):
model_type = "chroma"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here.

@buffett0323

Copy link
Copy Markdown
Contributor Author

@hameerabbasi All solved, thanks for your help!

@hameerabbasi

Copy link
Copy Markdown
Contributor

Wait; the Krea2 stuff is now no longer in the PR. 👀 Only Ideogram 4.

@buffett0323

Copy link
Copy Markdown
Contributor Author

Yes, that's intentional. Krea2 single-file support already landed on main in #14914 , and I've changed the title, thanks for the clarification! @hameerabbasi

@buffett0323 buffett0323 changed the title Add from_single_file() support for Ideogram4 and Krea2 transformers Add from_single_file() support for Ideogram4 transformer Oct 17, 2026

@hameerabbasi hameerabbasi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (but I don't have approve or merge rights)

@buffett0323

Copy link
Copy Markdown
Contributor Author

@DN6 can you please help review again? thanks a lot!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation fixes-issue single-file size/L PR with diff > 200 LOC tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

from_single_file() support missing/incomplete for Ideogram4 and Krea2 transformers

5 participants