feat(context): expose ExecutionContext.isRecording (eager-vs-trace routing)#757
Merged
Merged
Conversation
…uting) Add a default-false `isRecording` to the lang-core `ExecutionContext` interface; `GraphExecutionContext` overrides it (currentTape?.isRecording). This lets modules that keep an eager fast-path bypassing `ops.*` (e.g. RoPE's raw-array INTERLEAVED rotation) detect tracing and emit a graph-traceable `ctx.ops.*` path instead — so they export to StableHLO while keeping the fast path for eager inference — WITHOUT depending on the compile-dag module (transformer-core only sees lang-core). Backward-compatible: existing ExecutionContext implementations inherit the default. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
📖 Documentation Preview The documentation has been built successfully for this PR. Generated Files:
Artifacts:
This comment will be updated automatically when the PR is updated. |
This was referenced Jun 24, 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.
Why
Modules with an eager fast-path that bypasses
ops.*can't currently be traced to a graph. The canonical case is RoPE's INTERLEAVED rotation (transformer-core/.../RoPE.kt), which uses rawinput.data.copyToFloatArray()for stride-2 efficiency — it escapes the tape (traces to 0 nodes) and so can't export to StableHLO.transformer-coredepends only onlang-core, so it can't reachDefaultGraphExecutionContext.isRecordingto route.What
ExecutionContext(lang-core): addpublic val isRecording: Boolean get() = false.GraphExecutionContext(compile-dag):override val isRecording(already had it ascurrentTape?.isRecording).Now any module can do
if (ctx.isRecording) <ops.* graph path> else <eager fast path>using only lang-core.Backward-compatible (default false; existing impls inherit it). Compiles clean (lang-core + compile-dag).
Follow-up
The transformers consumer (graph-traceable INTERLEAVED RoPE routed on
ctx.isRecording) lands in a SKaiNET-transformers PR once this is released; downstreamskainet-iree-conformancealready validates SPLIT_HALF RoPE end-to-end.🤖 Generated with Claude Code