Conversation
When MAGI_COMPILE_AOT=1, models using SimpleFSDP/DTensor may fail AOT compilation (e.g. "Attempted to read undefined local variable"). Instead of crashing, catch the exception and fall back to the JIT bytecode capture path. This allows AOT to be enabled globally while FSDP models auto-degrade to JIT + inductor cache hits.
This branch has not been deployed
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.
Problem
When
MAGI_COMPILE_AOT=1is set globally, models using SimpleFSDP/DTensor fail AOT compilation with:This crashes the entire warmup process, preventing AOT from being used even for compatible models (e.g., VAE which has no FSDP).
Solution
Catch exceptions in the AOT compile path and gracefully fall back to the JIT bytecode capture path. This allows
MAGI_COMPILE_AOT=1to be set globally:Key implementation details:
state.aot_compile()compile_config.aot = Falseto prevent further AOT attempts for this statecompiled_entryand calltorch._dynamo.reset()to clear AOT-onlyguard_filter_fn_ensure_compiled()for JIT mode and proceed with bytecode captureContext
Part of CI cold-start optimization effort (athena PR #1112). AOT serializes Dynamo FX graphs so verify can skip Dynamo tracing + RestartAnalysis entirely (~42s savings for compatible models).