Skip to content

feat(memory): Layout + TensorView — zero-copy views over Storage, decoding get(), materialize() as the only copy point (SKEEP-003 P2, S1.3) - #1066

Merged
michalharakal merged 1 commit into
developfrom
feature/1022-layout-tensorview
Aug 23, 2026
Merged

michalharakal merged 1 commit into
developfrom
feature/1022-layout-tensorview

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Summary

SKEEP-003 slice S1.3 (milestone M1 #1002, PRD M1-F6): Layout + TensorView — the type a kernel actually receives (§4.2, rules 4–6). A view never owns bytes; every slice / transpose / unsqueeze is another view over the same Storage; materialize() is the only copy point.

Test plan

Full local gate (scripts/pr-gate.sh, JDK 25) — all legs passed; results in the first comment.

Closes #1022

🤖 Generated with Claude Code

…oding get(), materialize() as the only copy point (SKEEP-003 P2)

Milestone M1 (#1002), PRD M1-F6. SKEEP-003 §4.2, rules 4–6: the view is
the only thing a kernel receives, it never owns bytes, and every slice /
transpose / unsqueeze is another view over the same Storage.

- sk.ainet.lang.memory.Layout: strides (in elements, or in *blocks* for a
  packed format), offsetElements/offsetBytes, isRowMajor, isContiguous
  (unit extents ignored), indexOf/byteOffsetOf, and the metadata-only
  narrow / transpose / unsqueeze / squeeze; Layout.rowMajor(shape, format)
  and Layout.blocked(shape, blockSize, bytesPerBlock) — the latter is what
  makes a packed weight sliceable and transposable without touching bytes.
- sk.ainet.lang.memory.TensorView(shape, format, layout, storage, id):
  narrow/transpose/unsqueeze/squeeze return views over the same storage
  (ids derive as `w[1..3)`), get() returns the decoded logical value for
  packed encodings and never a raw byte (rule 4), set() is refused on a
  packed or read-only view, toFloatArray() is the reference
  materialization, materialize(format, scope) is the single copy point
  (rule 6) and allocates in the target scope. Narrowing the block axis of
  a packed view must align to whole blocks.
- BlockDecoder + PackedBlockDecoder: the bridge from today's
  PackedBlockStorage implementations (Q4_0…Q8_0, Q4_K/Q5_K/Q6_K, ternary)
  to TensorView; M2's Encoding descriptors will implement the same
  interface.
- LayoutTest and TensorViewTest (dense read/write, shared-storage views,
  packed decode vs PackedBlockStorage.toFloatArray, whole-block slicing,
  materialize as a copy, views over closed storage). JVM 67/67, linuxX64
  58/58 memory tests. BCV: lang-core jvm dump regenerated.

Closes #1022

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

Copy link
Copy Markdown
Contributor Author

Local gate scripts/pr-gate.sh (JDK 25) on 9a2e694:

=== pr-gate: JVM tests ===                                      BUILD SUCCESSFUL
=== pr-gate: apiCheck ===                                       BUILD SUCCESSFUL
=== pr-gate: verifyNpmPins jsTest wasmJsTest wasmWasiTest ===   BUILD SUCCESSFUL in 2m 47s
=== pr-gate: linuxX64Test ===                                   BUILD SUCCESSFUL in 1m 21s
=== pr-gate: assemble ===                                       BUILD SUCCESSFUL in 2m 9s
=== pr-gate: :skainet-test:skainet-test-java:test ===           BUILD SUCCESSFUL in 21s
pr-gate: all legs passed.

Targeted: JVM 67/67 and linuxX64 58/58 sk.ainet.lang.memory.* tests.

@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-1066 artifact to view the complete documentation locally.

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

@michalharakal
michalharakal merged commit 6e1d1e7 into develop Aug 23, 2026
17 checks passed
@michalharakal
michalharakal deleted the feature/1022-layout-tensorview branch August 23, 2026 14:00
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.

[S1.3] P2: Layout + new TensorView (view(), materialize(format, scope), decoding get()) — the only thing kernels receive

1 participant