-
Notifications
You must be signed in to change notification settings - Fork 226
[MoE] MoE Calibration with calibrate_all_experts
#1760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Change Purpose: - Add calibrate_all_experts option to improve MoE calibration Change Details: - Add `calibrate_all_experts` flag to MoE layers - Update `replace_modules_for_calibration` and `moe_calibration_context` to propagate the flag into modules - Modify expert forward passes: * Normal mode (default): compute output only for tokens routed to top-k experts, and combine their weighted results in the final output * Calibration mode (`calibrate_all_experts=True`): compute output for all tokens on every expert, but still apply the top-k gating to decide which token outputs contribute to the final result. Testing: - Add unit test to verify all experts are triggered during MoE calibration
Signed-off-by: Kyle Sayers <[email protected]>
👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review. Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed. |
Signed-off-by: Kyle Sayers <[email protected]>
calibrate_all_experts
Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment below. I also agree with @brian-dellabetta's point that this could maybe be simplified by patching self.top_k
temporarily.
Signed-off-by: Kyle Sayers <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not get a chance to run through these as of yet but it would be good to run through nvfp4 for llama4 and qwen3 and validating performance on the b200 before landing this, if anybody has bandwidth to run these
Running those examples now |
@@ -974,7 +974,8 @@ def getattr_chain(obj: Any, chain_str: str, *args, **kwargs) -> Any: | |||
return res | |||
|
|||
|
|||
class DisableKVCache: | |||
@contextlib.contextmanager | |||
def disable_cache(module: torch.nn.Module): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely agree with these changes, but might be better in a separate PR or added in the PR summary. Seems orthogonal to calibrate_all_experts
Coauthored with @dichn!
Purpose
calibrate_all_experts
option, which sends all tokens to all experts, but still produces the same outputs as if tokens had been gatedChanges
calibrate_all_experts=True
token gating occurs after passing tokens to experts, rather than beforeTesting