Repository navigation
fix(profiling): replay extern ops with compiled regions forced eager - #119
Merged
Merged
Conversation
added 2 commits
November 27, 2026 17:20
…n has no os.memfd_create A Python built against a glibc older than 2.27, as conda builds on its 2.17 sysroot, leaves out os.memfd_create even though the running glibc and kernel provide it; per-host weight sharing then failed on its first region.
dynamo.disable alone lets a torch.compiled region inside the replayed op compile, and that compile resets the chromium event log on exit, clearing the enclosing Inductor compile pt2 events; _compile_fx_inner then fails with inductor_compile not logged to pt2_compile_events.
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
The runtime estimator times an extern kernel by replaying its op in the middle of the Inductor compile. When the op's implementation contains a
torch.compiled region, for example a custom attention op that runstorch.compile(flex_attention)on first use (the documented way to useflex_attention), that replay fails the whole piecewise compile:torch._dynamo.disableon the replay keeps Dynamo from tracing the replay frame, not from compiling atorch.compiled region called inside it. The replay therefore starts a new top-level Dynamo compile nested in the Inductor compile, and the exit of that compile resets the chromium event log, clearing the enclosing compile's pt2 compile events;_compile_fx_innerthen fails when it logsinductor_compile. The replay itself returns normally, so the estimator's fallback on replay errors never sees it. A log that hits this also carries manyStart event not in stack, ignoringwarnings.torch.compiler.set_stance("force_eager"), so compiled regions inside the op run eagerly and the enclosing compile's events stay intact. The estimator is after eager kernel times anyway.flex_attentionmaterializes the full score matrix, which does not fit at long sequence lengths), the replay error is caught as before and the op keeps its analytical cost. Ops without a compiled region replay exactly as before.test_replay_runs_compiled_regions_eagerly_inside_the_enclosing_compilereplays atorch.compiled op inside a pt2 compile event and checks that the event survives; it fails without this change, with the event stack empty.