Skip to content

feat(context): expose ExecutionContext.isRecording (eager-vs-trace routing)#757

Merged
michalharakal merged 1 commit into
developfrom
feat/execution-context-isrecording
Jun 24, 2026
Merged

feat(context): expose ExecutionContext.isRecording (eager-vs-trace routing)#757
michalharakal merged 1 commit into
developfrom
feat/execution-context-isrecording

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

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 raw input.data.copyToFloatArray() for stride-2 efficiency — it escapes the tape (traces to 0 nodes) and so can't export to StableHLO. transformer-core depends only on lang-core, so it can't reach DefaultGraphExecutionContext.isRecording to route.

What

  • ExecutionContext (lang-core): add public val isRecording: Boolean get() = false.
  • GraphExecutionContext (compile-dag): override val isRecording (already had it as currentTape?.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; downstream skainet-iree-conformance already validates SPLIT_HALF RoPE end-to-end.

🤖 Generated with Claude Code

…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>
@github-actions

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-757 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

@michalharakal michalharakal merged commit 755fead into develop Jun 24, 2026
9 checks passed
@michalharakal michalharakal deleted the feat/execution-context-isrecording branch June 24, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant