compute: package std/tensor, Tensor<Scalar> over a Buffer (step 2 of #82) #691

Open
opened 2026-10-30 09:05:33 +00:00 by orion · 13 comments
Collaborator

Context

Slice 1 of docs/design/TENSOR.md section 11, step 2 of #82 (compute: std/tensor on the CPU). The record (#438) decides everything this slice builds; read its sections 3 (type and layout, decisions 1 to 6), 4 (scalars), 7 (Index, Iterate, Show, Equals) and 10 (cost).

Goal

A new package std/tensor with Tensor<Scalar: Numeric = Float>, dense and row-major, built on Buffer<Scalar> as decisions 1 to 6 specify.

Acceptance criteria

  • std/tensor/ exists (manifest, src/, tests/, registered like std/linear and std/gradient) with the type of decision 1: private shape, strides, offset, storage; the invariants I1 to I5 of decision 3 hold for every value (a negative extent panics with the message of decision 5).
  • Constructors: scalar, zeros, ones, filled, identity, of, over (no copy), with the zero-sized and rank 0 behaviour of decision 4.
  • Members: shape, rank, count, isDense, get (Option), Index and MutableIndex on List<Int> with the panic messages of decision 6, Iterate in row-major order, Show, hand-written Equals (layout-independent, decision 3).
  • Tests in std/tensor/tests/ on Float64, Int and Fixed, passing in the VM and natively (torb test, both back ends).
  • Docs page for the package, regenerated into skills/ (torb docs skill docs skills).
  • Benchmarks tensor-zeros and tensor-index in benchmarks/ plus tools/tensor-cost.sh in the pattern of tools/buffer-cost.sh; the PR records the numbers (a measurement, not a gate). If tensor-zeros exceeds the bound 1.10, record it in the PR; do not add a native here.
  • Gates green in both tiers.

Design record point

docs/design/TENSOR.md section 11, slice 1; decisions 1 to 6, 9 (test scalars), section 10.

Seed

Touches the seed: no. Ordinary TorbScript on Buffer: no syntax, no native, no driver flag, no std name the compiler looks up. If a checker or compiler gap shows up, file it as its own issue and do not fix it here.

Size

One PR, one Conventional Commit: feat(tensor): Tensor<Scalar> over a Buffer.

Out of scope

Elementwise operations, views, reshape and transpose (slices 2 and 3), reductions, matmul, uniform/normal, Float32, the parallel loop. #440 and #441 (closed) block none of this.

Dependencies

Part of #82. #54, #299, #300 merged; no open dependency.

## Context Slice 1 of `docs/design/TENSOR.md` section 11, step 2 of #82 (compute: `std/tensor` on the CPU). The record (#438) decides everything this slice builds; read its sections 3 (type and layout, decisions 1 to 6), 4 (scalars), 7 (`Index`, `Iterate`, `Show`, `Equals`) and 10 (cost). ## Goal A new package `std/tensor` with `Tensor<Scalar: Numeric = Float>`, dense and row-major, built on `Buffer<Scalar>` as decisions 1 to 6 specify. ## Acceptance criteria - [ ] `std/tensor/` exists (manifest, `src/`, `tests/`, registered like `std/linear` and `std/gradient`) with the type of decision 1: private `shape`, `strides`, `offset`, `storage`; the invariants I1 to I5 of decision 3 hold for every value (a negative extent panics with the message of decision 5). - [ ] Constructors: `scalar`, `zeros`, `ones`, `filled`, `identity`, `of`, `over` (no copy), with the zero-sized and rank 0 behaviour of decision 4. - [ ] Members: `shape`, `rank`, `count`, `isDense`, `get` (`Option`), `Index` and `MutableIndex` on `List<Int>` with the panic messages of decision 6, `Iterate` in row-major order, `Show`, hand-written `Equals` (layout-independent, decision 3). - [ ] Tests in `std/tensor/tests/` on `Float64`, `Int` and `Fixed`, passing in the VM and natively (`torb test`, both back ends). - [ ] Docs page for the package, regenerated into `skills/` (`torb docs skill docs skills`). - [ ] Benchmarks `tensor-zeros` and `tensor-index` in `benchmarks/` plus `tools/tensor-cost.sh` in the pattern of `tools/buffer-cost.sh`; the PR records the numbers (a measurement, not a gate). If `tensor-zeros` exceeds the bound 1.10, record it in the PR; do not add a native here. - [ ] Gates green in both tiers. ## Design record point `docs/design/TENSOR.md` section 11, slice 1; decisions 1 to 6, 9 (test scalars), section 10. ## Seed Touches the seed: no. Ordinary TorbScript on `Buffer`: no syntax, no native, no driver flag, no std name the compiler looks up. If a checker or compiler gap shows up, file it as its own issue and do not fix it here. ## Size One PR, one Conventional Commit: `feat(tensor): Tensor<Scalar> over a Buffer`. ## Out of scope Elementwise operations, views, reshape and transpose (slices 2 and 3), reductions, `matmul`, `uniform`/`normal`, `Float32`, the parallel loop. #440 and #441 (closed) block none of this. ## Dependencies Part of #82. #54, #299, #300 merged; no open dependency.
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261030 @anthropic:theorben until 2026-10-30T12:11Z

[loop:torbscript] claim implement by session:loop-torbscript-20261030 @anthropic:theorben until 2026-10-30T12:11Z
Author
Collaborator

[loop:torbscript] release implement by session:loop-torbscript-20261030: worker ended (gateway restart). Draft PR #695 (head 77c3776b) is pushed but not finished: CI tier B fails in the conformance suite, tests/conformance/collection-words.trb allocates 213 blocks, over its budget of 212 by 1 (338 of 339 programs pass); the rest of CI is pending. A fix worker either removes the extra allocation or, if the change explains it, raises that one budget with the reason in the PR, then un-drafts the PR and requests argus. No worker lane is free this tick.
next: waiting (worker lane for the CI fix on #695) until 2026-10-30T13:00:00Z

[loop:torbscript] release implement by session:loop-torbscript-20261030: worker ended (gateway restart). Draft PR #695 (head 77c3776b) is pushed but not finished: CI tier B fails in the conformance suite, tests/conformance/collection-words.trb allocates 213 blocks, over its budget of 212 by 1 (338 of 339 programs pass); the rest of CI is pending. A fix worker either removes the extra allocation or, if the change explains it, raises that one budget with the reason in the PR, then un-drafts the PR and requests argus. No worker lane is free this tick. next: waiting (worker lane for the CI fix on #695) until 2026-10-30T13:00:00Z
Author
Collaborator

[loop:torbscript] claim implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:theorben until 2026-10-30T14:18:27Z
Draft PR #695: tier B fails on tests/conformance/collection-words.trb (213 blocks, budget 212).
next: waiting (CI fix on #695)

[loop:torbscript] claim implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:theorben until 2026-10-30T14:18:27Z Draft PR #695: tier B fails on tests/conformance/collection-words.trb (213 blocks, budget 212). next: waiting (CI fix on #695)
Author
Collaborator

[loop:torbscript] claim implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-30T14:29:07Z
Respawn: the theorben spawn was refused (too many CLI live sessions), the retry was cut by a gateway restart. Draft PR #695: tier B fails on tests/conformance/collection-words.trb (213 allocations vs budget 212).

[loop:torbscript] claim implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-30T14:29:07Z Respawn: the theorben spawn was refused (too many CLI live sessions), the retry was cut by a gateway restart. Draft PR #695: tier B fails on tests/conformance/collection-words.trb (213 allocations vs budget 212).
Author
Collaborator

[loop:torbscript] release implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:tkoehn: worker interrupted by a gateway restart, no change on PR #695 (head 77c3776b).
[loop:torbscript] claim implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:theorben until 2026-10-30T14:43:55Z
next: waiting (CI fix on #695)

[loop:torbscript] release implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:tkoehn: worker interrupted by a gateway restart, no change on PR #695 (head 77c3776b). [loop:torbscript] claim implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:theorben until 2026-10-30T14:43:55Z next: waiting (CI fix on #695)
Author
Collaborator

[loop:torbscript] release implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:theorben: worker interrupted (failed worker, no change on PR #695, head dd7ca583). PR #695 is also not mergeable (conflict with main), so the fix worker rebases first.
next: waiting (worker lane for the CI fix on #695; #684 CI fix runs first) until 2026-10-30T15:30:00Z

[loop:torbscript] release implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:theorben: worker interrupted (failed worker, no change on PR #695, head dd7ca583). PR #695 is also not mergeable (conflict with main), so the fix worker rebases first. next: waiting (worker lane for the CI fix on #695; #684 CI fix runs first) until 2026-10-30T15:30:00Z
Author
Collaborator

[loop:torbscript] claim implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-30T18:24:00Z
Respawn after the interrupted theorben worker: PR #695 (head dd7ca583) is not mergeable (conflict with main) and tier B failed earlier on tests/conformance/collection-words.trb (213 allocations vs budget 212).

[loop:torbscript] claim implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-30T18:24:00Z Respawn after the interrupted theorben worker: PR #695 (head dd7ca583) is not mergeable (conflict with main) and tier B failed earlier on tests/conformance/collection-words.trb (213 allocations vs budget 212).
Author
Collaborator

[loop:torbscript] checkpoint implementation (CI fix): rebased loop/691-tensor-core on current main (clean, 3 commits, head 034a467c, force-with-lease). The collection-words budget bump (212 to 213, already on the branch) holds: tier B is green (36m56s). Tier A is running; gates, seed pack and archives wait on it. Next: un-draft #695 and request argus once CI is green.

[loop:torbscript] checkpoint implementation (CI fix): rebased loop/691-tensor-core on current main (clean, 3 commits, head 034a467c, force-with-lease). The collection-words budget bump (212 to 213, already on the branch) holds: tier B is green (36m56s). Tier A is running; gates, seed pack and archives wait on it. Next: un-draft #695 and request argus once CI is green.
Author
Collaborator

[loop:torbscript] release implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:tkoehn: worker interrupted by a gateway restart after its checkpoint. Left: PR #695 (head 034a467c, rebased) has tier B green; tier A, gates, seed pack and archives still pending; forge still reports it not mergeable (re-check). A fix worker reads the final CI, fixes what is red, removes the WIP prefix and requests argus.
next: implementation (CI fix on #695)

[loop:torbscript] release implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:tkoehn: worker interrupted by a gateway restart after its checkpoint. Left: PR #695 (head 034a467c, rebased) has tier B green; tier A, gates, seed pack and archives still pending; forge still reports it not mergeable (re-check). A fix worker reads the final CI, fixes what is red, removes the WIP prefix and requests argus. next: implementation (CI fix on #695)
Author
Collaborator

[loop:torbscript] claim implementation by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-30T22:32Z

[loop:torbscript] claim implementation by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-30T22:32Z
Author
Collaborator

[loop:torbscript] release implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:tkoehn: worker interrupted by a gateway restart. Left: PR #695 now at head 41dc1979; its CI is still pending and the forge reports it not mergeable (re-check after CI). A fix worker reads the final CI, fixes what is red, resolves the conflict, removes the WIP prefix and requests argus.
next: implementation (CI fix on #695)

[loop:torbscript] release implementation (CI fix) by session:loop-torbscript-20261030 @anthropic:tkoehn: worker interrupted by a gateway restart. Left: PR #695 now at head 41dc1979; its CI is still pending and the forge reports it not mergeable (re-check after CI). A fix worker reads the final CI, fixes what is red, resolves the conflict, removes the WIP prefix and requests argus. next: implementation (CI fix on #695)
Author
Collaborator

[loop:torbscript] claim implementation by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-31T02:20Z

[loop:torbscript] claim implementation by session:loop-torbscript-20261030 @anthropic:tkoehn until 2026-10-31T02:20Z
Author
Collaborator

[loop:torbscript] release implementation by session:loop-torbscript-20261030 @anthropic:tkoehn: worker interrupted by a gateway restart after finishing the rebase. PR #695 is at head 329ac411, mergeable, WIP prefix removed, argus requested; CI on that head is pending.
next: waiting (CI and review of PR #695)

[loop:torbscript] release implementation by session:loop-torbscript-20261030 @anthropic:tkoehn: worker interrupted by a gateway restart after finishing the rebase. PR #695 is at head 329ac411, mergeable, WIP prefix removed, argus requested; CI on that head is pending. next: waiting (CI and review of PR #695)
Sign in to join this conversation.
No labels
loop
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#691
No description provided.