Summary
Root cause:
aot_stage2_compile()mutatedAOTState.aot_configin place to inject stage-2 compilers and partitioners, and that made it hard to reason about whetheraot_configrepresented the original compile request or a later stage-local override.- Freezing
AOTConfigalso exposed a few other in-place updates (decompositions,cache_info) that needed to become whole-object replacements or local copies.
Proposed fix:
- Mark
AOTConfigas frozen. - Replace the remaining setup/cache-time config writes with whole-object replacement or stage-local copies.
- Thread the stage-2
partition_fn,fw_compiler,inference_compiler, and lazy-backwardbw_compilerexplicitly through the stage-2 helpers and runtime wrappers instead of stashing them onaot_config. - Add regression coverage for both lazy backward and inference so stage 2 leaves the config untouched.
Why this is the right long term fix:
- It gives
AOTConfiga single stable meaning again, keeps stage-specific compiler choices local to the code that consumes them, and preserves existing lazy-backward/inference behavior without hidden mutable state.
Drafted via Codex, published after manual review by @bobrenjc93
Pull Request resolved: #184070
Approved by: https://github.com/ezyang
SOCIAL SHARE CARD GENERATOR