[AWQ] allow for use of model-wide kwargs cache #1985
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY:
It appears AutoAWQ makes an implicit assumption that, when caching inputs to the forward call of certain modules, only the first input is needed, and all other kwargs can be shared, so that they don't have to be redundantly stored in GPU VRAM.
When we first ported AutoAWQ, we thought this seemed incorrect and could lead to poor behavior. Our implementation cached all the args into a given module's forward call, so that it is guaranteed to be replicated correctly at the expense of GPU VRAM.
Now that we are revisiting performance improvements for AWQ, I wanted to add AutoAWQ's design choice as a toggleable field on AWQModifier.
AWQModifier(..., use_auto_awq_mem_hack=True), we will use AutoAWQ's technique to cache to a field_model_kwargs_cache: IntermediatesCache_parent_kwargs_cache: dict[Module, IntermediatesCache]I am pretty sure that's what this PR has, but when I compare the running of
examples/awq/qwen3_moe_example.pyside-by-side with the field False or True, I don't see any meaningful difference in the VRAM usage. I need to do some more debugging to make sure this is working as intended (and compare to VRAM usage when running AutoAWQ)TEST PLAN:
"please outline how the changes were tested"