Skip to content

Carriage 1: TensorRef carries identity and encoding to the graph - #1182

Merged
michalharakal merged 1 commit into
developfrom
feature/1178-tensorref-identity
Aug 26, 2026
Merged

michalharakal merged 1 commit into
developfrom
feature/1178-tensorref-identity

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Closes #1178 (parent #1147, carriage slice 1 of 3). Capture, don't decide.

The tape is the only stage that can see the live tensor — its module-path identity and its storage encoding — and everything it saw used to die at the trace→graph handoff: a packed weight reached downstream stages as a display name, a parameter as t7.

  • TensorRef gains tensorId/encoding (nullable, default null — every existing construction compiles unchanged). TraceSession.refOf captures the encoding object (block size intact, unlike the name strings downstream stages were left with); identity comes from the new TraceSession.identify(tensor, id) hook — a tensor does not know which parameter it is, so whoever does registers it: HloGenerator walks trainableParameters() before recording. Refs are immutable and cached — identify before first refOf, no retrofit (pinned by test).
  • Four spec-construction sites now carry both through TensorSpec.metadata (two more than expected — the graph-level test caught DefaultExecutionTape's own paths): TraceToGraphBuilder's input/output specs and synthetic weight nodes, and the tape's recordOperation + legacy addTrace bridge. TensorSpecIdentity.kt adds the typed accessors following the TensorSpecEncoding precedent — untyped map entries, no storage-model import into skainet-compile (the standing rule).
  • Tests: TraceSessionIdentityTest (capture semantics incl. the no-retrofit rule) and TraceIdentityToGraphTest (a Q8_0 weight's TensorId and encoding object survive tape → ComputeGraph).

Per the #1148 reframing, the conformity pipeline (via SKaiNET-transformers, post-release) is the eventual consumer; until then these tests are the metadata's reader. Slice 2 (#1179) serializes it structurally at the StableHLO/.irpa boundary.

Full pr-gate green.

🤖 Generated with Claude Code

Carriage slice 1 (#1147): capture, don't decide. The tape is the only
stage that can see the live tensor, and everything it saw used to die
at the trace→graph handoff — a packed weight reached downstream stages
as a display name, a parameter as 't7'.

- TensorRef gains tensorId/encoding (nullable, default null — every
  existing construction compiles unchanged). TraceSession.refOf
  captures the encoding *object* (block size intact) from the data;
  identity comes from the new TraceSession.identify(tensor, id) hook —
  a tensor does not know which parameter it is, so whoever does (the
  HLO generator walking trainableParameters() before recording)
  registers it. Refs are immutable and cached: identify before first
  refOf, no retrofit (pinned by test).
- Every spec-construction site that starts from a ref carries both
  through TensorSpec.metadata: TraceToGraphBuilder's input/output
  specs and synthetic weight nodes, and DefaultExecutionTape's
  recordOperation + legacy addTrace bridge. TensorSpecIdentity.kt adds
  the typed accessors following the TensorSpecEncoding precedent —
  untyped map entries, no storage-model import into skainet-compile.
- Tests: TraceSessionIdentityTest (capture semantics incl. the
  no-retrofit rule) and TraceIdentityToGraphTest (a Q8_0 weight's
  TensorId and encoding object survive tape → ComputeGraph).

Closes #1178.

Co-Authored-By: Claude Fable 5 <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-1182 artifact to view the complete documentation locally.

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

@michalharakal
michalharakal merged commit 8c4d563 into develop Aug 26, 2026
19 checks passed
@michalharakal
michalharakal deleted the feature/1178-tensorref-identity branch August 26, 2026 18:39
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.

Carriage 1: TensorRef carries identity and encoding to the graph

1 participant