[fix] compile state with instance-level forward wrapping#12
Merged
cennn merged 1 commit intoSandAI-org:mainfrom Mar 31, 2026
Merged
[fix] compile state with instance-level forward wrapping#12cennn merged 1 commit intoSandAI-org:mainfrom
cennn merged 1 commit intoSandAI-org:mainfrom
Conversation
Collaborator
|
Great catch! — clean fix for the instance-level compilation bypass. On our end, we'll be adding perf regression tests for all compile entry points, and exploring whether instance-level dispatch can avoid touching |
cennn
approved these changes
Mar 31, 2026
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.
🗂️ PR Category
📝 Description
Align MagiCompileState with instance-level wrapping semantics
nn.Moduleinstances, prefer_magi_original_forward(if present) as the target callable, ensuring the compiled graph reflects the original, pre-wrappedforward.forwardto the class-levelforwardbound method while swapping bytecode, then restore the original binding after execution, so hooks/FSDP logic still flow through__call__while keeping instance-level overrides consistent.Refine instance-level compile orchestration path
_magi_compile_instance, storemodule._magi_original_forwardand change the orchestration entry from calling the unboundforwarddirectly to going throughmodule.__class__.__call__, preserving module__call__behavior and hooks for instance-compiled models.Add CUDA timing sanity test for multiple Magi entrypoints
@magi_compileentrypoints on the sameSimpleModel, asserting their compiled timings stay within a small factor of each other to catch regressions or inconsistent fast-path behavior.