fix: pass dynamic=True to torch.compile to stop dynamo recompilation#1685
Draft
rahulp7801 wants to merge 1 commit intointel:mainfrom
Draft
fix: pass dynamic=True to torch.compile to stop dynamo recompilation#1685rahulp7801 wants to merge 1 commit intointel:mainfrom
dynamic=True to torch.compile to stop dynamo recompilation#1685rahulp7801 wants to merge 1 commit intointel:mainfrom
Conversation
Generated by opensrcer agentic solve (dispatch d_2026-04-15T06-29-56_e4a9bb). Exploration + diff authored by Claude Code via the opensrcer MCP tools (list_files / read_file / grep / find_definition / find_references). Review the full exploration log at .dispatches/d_2026-04-15T06-29-56_e4a9bb.log.
|
Azure Pipelines: 6 pipeline(s) were filtered out due to trigger conditions. 1 pipeline(s) require an authorized user to comment /azp run to run. |
SeanThomasWilliams
added a commit
to SeanThomasWilliams/auto-round
that referenced
this pull request
Apr 15, 2026
Cherry-pick of intel#1685 (still open upstream as of 2026-04-15). Fixes torch._dynamo recompile storm during AutoRound quantization when per-layer weight shapes differ. With dynamic=True, dynamo traces quant_tensor_sym / block_forward symbolically instead of specializing per shape. Seen to burn 2h53m with 0 layers quantized on AWS iters=256 (ai_docs/... feedback_autoround_torch_compile_aws.md). Author retained on original PR. No co-author footer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1679.
Summary
compile_func_on_cuda_or_cpuinauto_round/utils/device.py:97callstorch.compile(func)with no shape-specialisation hint. Whenquant_tensor_symis compiled,torch._dynamotraces it for the concrete shape of thevtensor (the per-weight rounding perturbation, initialised to the weight's shape atwrapper.py:164). Different layers have different weight shapes, so dynamo recompiles the function for each new shape. After 8 recompilations it logs theconfig.recompile_limitwarning and falls back to eager mode. Passingdynamic=Truetotorch.compiletells dynamo to use symbolic shapes, producing a single shape-generic trace that never needs to recompile for size changes invor the weight tensor.Files changed
auto_round/utils/device.pyTest plan
compile_funcis called inwrapper.py:175,182,alg_ext.py:373,1042,1046, andcompressors/base.py:539. All of these wrap quantisation functions (quant_tensor_sym,quant_tensor_asym, andblock_forward) that receive tensors of varying shape across layers — sodynamic=Trueis the correct default for all of them.Contribution guide notes
Signed-off-by: Name <email>(DCO, per CONTRIBUTING.md).Authored via opensrcer agentic solve. Full exploration trace: dispatch
d_2026-04-15T06-29-56_e4a9bb.