Skip to content

MagCache support for WAN 2.1 models#365

Open
prishajain1 wants to merge 3 commits intomainfrom
prisha/magcache
Open

MagCache support for WAN 2.1 models#365
prishajain1 wants to merge 3 commits intomainfrom
prisha/magcache

Conversation

@prishajain1
Copy link
Collaborator

This PR adds support for Magnitude Aware Caching (An inference acceleration technique designed to speed up Diffusion models like Wan 2.1 by skipping heavy model passes).
Reference: https://github.com/Zehong-Ma/MagCache/tree/main/MagCache4Wan2.1
Details about implementation and validation related experiments can be found here: go/magcache

MagCache support for WAN 2.2 shall be added in the upcoming PRs

@prishajain1 prishajain1 requested a review from entrpn as a code owner March 25, 2026 12:13
@github-actions
Copy link

@prishajain1 prishajain1 requested a review from Perseus14 March 25, 2026 12:15
return noise_pred_merged, noise_cond


def nearest_interp(src, target_len):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you think it's better to move this to utils?

Copy link
Collaborator Author

@prishajain1 prishajain1 Mar 25, 2026

Choose a reason for hiding this comment

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

Not sure its purpose fits into any of the existing utils file. One option is to create a separate wan_magcache_utils.py file and move nearest_interp, init_magcache and magcache_step methods into it (this can help keep wan_pipeline.py cleaner).
If the current approach seems ok, we can keep it as it is.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The nearest_interp seems like something that could be used by others in the future

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Which file do you suggest to move this into?

@prishajain1
Copy link
Collaborator Author

@syhuang22 can you help review that the changes in this PR do not impact CFG Cache?

@prishajain1 prishajain1 requested a review from syhuang22 March 25, 2026 13:31
@prishajain1 prishajain1 marked this pull request as draft March 25, 2026 13:31
@prishajain1 prishajain1 marked this pull request as ready for review March 25, 2026 16:09
@syhuang22
Copy link
Collaborator

Ran the CFG test here to see if anything was affected, the test passed so the current change doesn't impact CFG cache.

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.

3 participants