Skip to content

Fix Qwen Image 2.1 compile recompiles - #15074

Open
solo938 wants to merge 1 commit into
huggingface:mainfrom
solo938:qwenimage21-fix
Open

solo938 wants to merge 1 commit into
huggingface:mainfrom
solo938:qwenimage21-fix

Conversation

@solo938

@solo938 solo938 commented Oct 18, 2026

Copy link
Copy Markdown

Summary

  • Replace the cache write slice argument with an integer cache write length to avoid recompilation caused by varying slice objects.
  • Add regression coverage for both Qwen Image 2.1 attention processors across varying generation inputs.

Testing

  • Full Qwen Image 2.1 transformer test file passes.
  • Regression tests pass for both attention processors.
  • Ruff lint and formatting checks pass.
  • git diff --check passes.

Closes #15027

layer_cache=layer_cache,
kv_cache_mode=kv_cache_mode,
cache_write_slice=cache_write_slice,
cache_write_len=cache_write_len,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a breaking change.


torch.testing.assert_close(outputs[0], outputs[1])

@pytest.mark.parametrize("processor_name", ["QwenImage21FlexAttnProcessor", "QwenImage21AttnProcessor"])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have a dedicated compilation tester class which should be used here.

@sayakpaul sayakpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need to defer to @naykun for a review here.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Qwen Image 2.1 with torch.compile triggers a recompile on each run with varying image size

2 participants