Skip to content

Carriage 2: structural layout attrs at the StableHLO and .irpa boundary - #1183

Merged
michalharakal merged 3 commits into
developfrom
feature/1179-structural-attrs
Aug 26, 2026
Merged

michalharakal merged 3 commits into
developfrom
feature/1179-structural-attrs

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Closes #1179 (parent #1147, carriage slice 2 of 3). Stacked on #1182 — merge that first (tick "delete branch" and this retargets to develop).

The export boundary carries structure, not display names.

  • skainet.tensor_layouts module attribute — machine-readable per-tensor facts straight off the encoding objects' own constants: {kind = "Q4_K", block_elems = 256, block_bytes = 144, block_order = "INPUT_BLOCK_MAJOR"}. The headline repair: TurboQuantPolar(4b, 128) used to degrade to a name whose block size was unrecoverable; it is now two integers in the header.
  • The legacy skainet.tensor_encodings names dictionary is removed, not duplicated — an org-wide code search shows nothing outside this repo ever read it (its only consumers were the emitter and its own test), and kind carries the name. The no-encodings case still emits a bare module { header (test preserved).
  • Block order travels the whole distance as a stable string (never the storage-model enum — the no-import rule): captured at the tape from PackedBlockStorage into TensorRef.blockOrder, through every spec site slice 1 opened, into both the module attribute and ExternalParameterRef — so a kernel-feed-ordered weight can be blitted into the .irpa verbatim and declare its order to the consumer (the compiled-side half of the Packed storage that knows its own block order, so KERNEL_FEED can reach a kernel #1120 gap).
  • StructuralLayoutsModuleAttributeTest pins: Q4_K facts + order, TurboQuant bits + block, the absence of the removed dictionary, and the bare header for dense graphs.

This is the contract the conformity pipeline (SKaiNET-transformers side, post-release) will read. Slice 3 (#1180) puts the first decision pass on the production path.

Full pr-gate green.

🤖 Generated with Claude Code

Carriage slice 2 (#1147): the export boundary carries structure, not
display names. The module attribute 'skainet.tensor_layouts' is
machine-readable — block element counts, block bytes, bit widths, and
block order — straight off the encoding objects' own constants, so a
downstream consumer can size and address packed weights without a
lookup table. TurboQuantPolar(4b, 128) used to degrade to a name whose
block size was unrecoverable; now it is two integers in the header.

The former 'skainet.tensor_encodings' names dictionary is REMOVED, not
duplicated: an org-wide code search shows nothing outside this repo
ever read it (its only consumers were the emitter and its own test),
and 'kind' in the structural dictionary carries the name. The
no-encodings case still emits a bare 'module {' header (test kept).

Block order rides the whole way as a stable string (never the
storage-model enum — the no-import rule): TensorRef.blockOrder is
captured from PackedBlockStorage at the tape, flows through every spec
site slice 1 opened, and lands both in the module attribute and on
ExternalParameterRef, so a kernel-feed-ordered weight can be blitted
into the .irpa verbatim and say so.

StructuralLayoutsModuleAttributeTest pins the header facts for a
feed-ordered Q4_K (256/144 + order) and a TurboQuant weight (bits +
block), the absence of the removed dictionary, and the bare header.

Closes #1179.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Base automatically changed from feature/1178-tensorref-identity to develop August 26, 2026 18:39
…one decision

Carriage slice 3 (#1147): the optimizer pipeline joins the production
tape→HLO path, and the first real layout decision runs on it.

- HloGenerator.generate gains target: String? = null. Null — the
  default — runs no pipeline and emits byte-identically to before; a
  named target runs dagPipelineFor(target) with LayoutAssignmentPass
  as a core pass, plus whatever the target registered through
  TargetOptimizers. compile-hlo gains the compile-opt dependency this
  wiring always implied (opt depends on dag; no cycle).
- LayoutAssignmentPass, deliberately narrow: rank-2 block-quantized
  weights (the GGML block formats) get kernel-feed order
  (INPUT_BLOCK_MAJOR) for the target — mirroring the decision the
  eager form resolver makes at load (#1120) — and never overrides an
  order the tape already carried: the loader's fact outranks the
  pass's preference. Touched nodes are stamped with the backend
  assignment.
- The pre-built ResolvedComputeGraph seams stop returning hardcoded
  null: resolvedLayout derives BlockOrderLayout from the spec the
  passes (or the tape) stamped; backendAssignment reads the node
  metadata key, which lives on ResolvedComputeGraph so the pass
  imports it along the legal opt→dag direction.
- Tests: pass semantics (decides / never-overrides / leaves dense and
  rank-1 alone; seams surface exactly the decisions made) and the
  pipeline→emission composition (a decided order reaches the module
  header as block_order; with no pipeline, no order is invented).

Closes #1180.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…pass

Carriage 3: LayoutAssignmentPass on the production path — one target, one decision
@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-1183 artifact to view the complete documentation locally.

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

@michalharakal
michalharakal merged commit 6850252 into develop Aug 26, 2026
19 checks passed
@michalharakal
michalharakal deleted the feature/1179-structural-attrs branch August 26, 2026 19:29
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 2: structural layout/encoding attrs at the StableHLO and .irpa boundary

1 participant