Skip to content

Conversation

@lambertwjh
Copy link
Contributor

What does this PR do?

Fixes # (issue)

Before submitting

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@lambertwjh
Copy link
Contributor Author

This is a small CogView4 alignment fix:
What this PR does

CogView4: remove the SiLU right before the final AdaLN.
Add a small switch use_silu (default True) to AdaLayerNormContinuous.
In CogView4Transformer2DModel, set norm_out = AdaLayerNormContinuous(..., use_silu=False) and keep SiLU only for the block path (temb_blocks = F.silu(temb_raw)) while feeding the raw temb_raw to the final AdaLN.

Why

In Megatron (our reference), adaln_final is a plain Linear (no activation).
In diffusers, temb was passed through F.silu before norm_out, which makes the final modulation differ from Megatron and causes hidden-state @@mismatches.
This PR aligns diffusers’ CogView4 with Megatron’s behavior.

@lambertwjh lambertwjh changed the title Fix/adaln remove silu remove silu for CogView4 Aug 15, 2025
@zRzRzRzRzRzRzR
Copy link
Contributor

@a-r-r-o-w can you check this

@a-r-r-o-w
Copy link
Contributor

Instead of making this change here, can we just copy the layer into the CogView transformer files where required and use the correct code?

@lambertwjh
Copy link
Contributor Author

“CogView4-only fix: final AdaLN without SiLU to match Megatron; generic normalization remains unchanged.”
please check again @a-r-r-o-w

Copy link
Contributor

@a-r-r-o-w a-r-r-o-w left a comment

Choose a reason for hiding this comment

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

Thanks @lambertwjh, looks good. I'm adding some changes to update the layer names.

@a-r-r-o-w
Copy link
Contributor

@bot style

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@a-r-r-o-w
Copy link
Contributor

@bot /style

@github-actions
Copy link
Contributor

github-actions bot commented Aug 16, 2025

Style bot fixed some files and pushed the changes.

@a-r-r-o-w
Copy link
Contributor

@lambertwjh @zRzRzRzRzRzRzR Just to confirm, do the changes for the layer name look good to you? If so, I'll merge this :)

@lambertwjh
Copy link
Contributor Author

Looks good to me. The rename to CogView4AdaLayerNormContinuous is clearer and matches the CogView4-only usage. Thanks! @a-r-r-o-w

@a-r-r-o-w a-r-r-o-w merged commit 76c809e into huggingface:main Aug 18, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants