compute: std/tensor on the CPU #82

Open
opened 2026-10-05 21:07:18 +00:00 by orion · 5 comments
Collaborator

Context

An epic: std/tensor on the CPU, pure TorbScript on Buffer<Item> (layer 1 of the compute plan). It is not one PR. COMPUTE.md is a stub whose full design "comes before the first of these packages is built", so the first step is the design record, and the build follows its slices.

Source

  • COMPUTE.md sections 1 and 2
  • ROADMAP, "Computation and machine learning"
  • CONCURRENCY section 6 (windows and "the tensor loop"), COLLECTIONS gap 6, LINEAR gaps 8 and 9

Acceptance criteria

  • std/tensor exists as the design record of step 1 specifies it: Tensor<Scalar> over a Buffer<Scalar> with a run-time shape, broadcasting, slices, elementwise operations, reductions, dot and matmul, with tests in both back ends and the cost table of the record filled in.
  • Every step below is closed.

Steps

Each step is one PR of one or two Conventional Commits and is filed as its own issue only when it starts (just in time). The list follows section 11 of the record (docs/design/TENSOR.md); slice order and waits are there.

  • 1. Design record docs/design/TENSOR.md (#438)
  • 2. Slice 1: package std/tensor: Tensor<Scalar> over a Buffer, shape and strides, construction, indexing, Iterate, Show, Equals, tests, docs page (#691)
  • 3. Slice 2: elementwise with broadcasting: Add, Subtract, Multiply<Scalar>, Divide<Scalar>, Negate, scaled, divided, shifted, mapped, broadcast, shape errors
  • 4. Slice 3: views and writes: reshaped, flattened, transposed, permuted, expanded, squeezed, sliced, selected, Slice, MutableSlice, compacted, fill, map, combine, accumulate
  • 5. Slice 4: reductions: sum, product, minimum, maximum, mean and the axis forms
  • 6. Slice 5: dot, matmul, assignProduct
  • 7. Slice 6: uniform, normal for Float64 over std/random
  • 8. Slice 7: batched matmul (rank 3 and more)
  • 9. Slice 8: extend Float32 with Real (new natives, two-commit rule; the seed refresh is the owner's; any time)
  • 10. Slice 9: data-parallel loop over windows (waits for windows over Buffer, epic #55)

Design record point

COMPUTE.md section 2 ("the order": Buffer<Item>, then std/tensor on the CPU and Dual, which are pure TorbScript without foreign functions); COMPUTE.md section 1, layer 1.

Seed

Touches the seed: expected no. std/tensor is a new package of ordinary TorbScript: no syntax change, no native, no driver flag, no std name the compiler looks up by string. Step 1 (documentation) states it per slice; a slice that needs a native or a checker change falls under the two-commit rule of CLAUDE.md, with the seed refresh staying with the owner, and a checker gap found by the probe of step 1 (operators with a foreign Other and Output) becomes its own issue.

Dependencies

  • #54 (Buffer<Item>): merged. #299 and #300 (compiler natives, Buffer is a List, Bytes is Buffer<UInt8>): merged.
  • Step 6 waits for #55 (collections on Buffer; windows takes an ArrayList today).
  • Beside, not blocking: #83 (Dual, pure TorbScript, no dependency on this epic). Blocked by this epic: #85 (std/gpu, also needs #84) and through it #86 (reverse mode and std/learning).
  • Not related: #92 (ECS columns on Buffer) shares the in-place promise of #54 and the windows loop, but neither waits for the other.

Moved from the planning lists of the docs; the design record stays the specification.

## Context An epic: `std/tensor` on the CPU, pure TorbScript on `Buffer<Item>` (layer 1 of the compute plan). It is not one PR. [COMPUTE.md](https://git.torb.dev/torbscript/language/src/branch/main/docs/design/COMPUTE.md) is a stub whose full design "comes before the first of these packages is built", so the first step is the design record, and the build follows its slices. ## Source - [COMPUTE.md sections 1 and 2](https://git.torb.dev/torbscript/language/src/branch/main/docs/design/COMPUTE.md) - ROADMAP, "Computation and machine learning" - CONCURRENCY section 6 (`windows` and "the tensor loop"), COLLECTIONS gap 6, LINEAR gaps 8 and 9 ## Acceptance criteria - [ ] `std/tensor` exists as the design record of step 1 specifies it: `Tensor<Scalar>` over a `Buffer<Scalar>` with a run-time shape, broadcasting, slices, elementwise operations, reductions, `dot` and `matmul`, with tests in both back ends and the cost table of the record filled in. - [ ] Every step below is closed. ## Steps Each step is one PR of one or two Conventional Commits and is filed as its own issue only when it starts (just in time). The list follows section 11 of the record (`docs/design/TENSOR.md`); slice order and waits are there. - [x] 1. Design record `docs/design/TENSOR.md` (#438) - [ ] 2. Slice 1: package `std/tensor`: `Tensor<Scalar>` over a `Buffer`, shape and strides, construction, indexing, `Iterate`, `Show`, `Equals`, tests, docs page (#691) - [ ] 3. Slice 2: elementwise with broadcasting: `Add`, `Subtract`, `Multiply<Scalar>`, `Divide<Scalar>`, `Negate`, `scaled`, `divided`, `shifted`, `mapped`, `broadcast`, shape errors - [ ] 4. Slice 3: views and writes: `reshaped`, `flattened`, `transposed`, `permuted`, `expanded`, `squeezed`, `sliced`, `selected`, `Slice`, `MutableSlice`, `compacted`, `fill`, `map`, `combine`, `accumulate` - [ ] 5. Slice 4: reductions: `sum`, `product`, `minimum`, `maximum`, `mean` and the axis forms - [ ] 6. Slice 5: `dot`, `matmul`, `assignProduct` - [ ] 7. Slice 6: `uniform`, `normal` for `Float64` over `std/random` - [ ] 8. Slice 7: batched `matmul` (rank 3 and more) - [ ] 9. Slice 8: `extend Float32 with Real` (new natives, two-commit rule; the seed refresh is the owner's; any time) - [ ] 10. Slice 9: data-parallel loop over `windows` (waits for `windows` over `Buffer`, epic #55) ## Design record point COMPUTE.md section 2 ("the order": `Buffer<Item>`, then `std/tensor` on the CPU and `Dual`, which are pure TorbScript without foreign functions); COMPUTE.md section 1, layer 1. ## Seed Touches the seed: expected no. `std/tensor` is a new package of ordinary TorbScript: no syntax change, no native, no driver flag, no std name the compiler looks up by string. Step 1 (documentation) states it per slice; a slice that needs a native or a checker change falls under the two-commit rule of `CLAUDE.md`, with the seed refresh staying with the owner, and a checker gap found by the probe of step 1 (operators with a foreign `Other` and `Output`) becomes its own issue. ## Dependencies - #54 (`Buffer<Item>`): merged. #299 and #300 (compiler natives, `Buffer` is a `List`, `Bytes` is `Buffer<UInt8>`): merged. - Step 6 waits for #55 (collections on `Buffer`; `windows` takes an `ArrayList` today). - Beside, not blocking: #83 (`Dual`, pure TorbScript, no dependency on this epic). Blocked by this epic: #85 (`std/gpu`, also needs #84) and through it #86 (reverse mode and `std/learning`). - Not related: #92 (ECS columns on `Buffer`) shares the in-place promise of #54 and the `windows` loop, but neither waits for the other. _Moved from the planning lists of the docs; the design record stays the specification._
Author
Collaborator

[loop:torbscript] intake: in scope (author orion, label loop), source COMPUTE.md section 2, not a duplicate. Pure TorbScript on Buffer<Item>; depends on #54. next: waiting (dependency #54) until 2026-10-10T04:00:00Z

[loop:torbscript] intake: in scope (author orion, label loop), source COMPUTE.md section 2, not a duplicate. Pure TorbScript on `Buffer<Item>`; depends on #54. next: waiting (dependency #54) until 2026-10-10T04:00:00Z
Author
Collaborator

[loop:torbscript] claim refine by session:loop-torbscript-20261023 until 2026-10-23T18:08Z

[loop:torbscript] claim refine by session:loop-torbscript-20261023 until 2026-10-23T18:08Z
Author
Collaborator

[loop:torbscript] decided by the loop: #82 is an epic, not one PR, so it stays without ready and only its first step is filed: #438 (design record docs/design/TENSOR.md, documentation only, labelled loop and ready).
Why: COMPUTE.md is a stub that states its full design comes before the first of these packages is built; nothing fixes the Tensor<Scalar> layout, view against copy for slices, the broadcasting rule and error type, or whether Tensor * Scalar passes today's checker. The same shape as #55, whose step 1 was the design record #413. The body is rewritten as an epic with a checklist (steps 2 to 6 are the plan until the record replaces them; each is filed only when it starts), a seed statement (expected: does not touch the seed; pure TorbScript on Buffer) and dependencies.
Dependencies: #54 (with #299 and #300) is merged. Step 6 (data-parallel loops) waits for #55, because windows takes an ArrayList today. #83 (Dual) is independent. #85 and through it #86 are blocked by this epic; #92 shares the in-place promise but is not related. Duplicate search of open and closed issues for tensor, matrix, buffer and compute: no other issue covers this.
Stage refine: claim by session:loop-torbscript-20261023 released. Worker usage: about 90k tokens.
next: waiting (epic: step #438 is ready, the epic itself closes when its checklist is done)

[loop:torbscript] decided by the loop: #82 is an epic, not one PR, so it stays without `ready` and only its first step is filed: #438 (design record `docs/design/TENSOR.md`, documentation only, labelled `loop` and `ready`). Why: COMPUTE.md is a stub that states its full design comes before the first of these packages is built; nothing fixes the `Tensor<Scalar>` layout, view against copy for slices, the broadcasting rule and error type, or whether `Tensor * Scalar` passes today's checker. The same shape as #55, whose step 1 was the design record #413. The body is rewritten as an epic with a checklist (steps 2 to 6 are the plan until the record replaces them; each is filed only when it starts), a seed statement (expected: does not touch the seed; pure TorbScript on `Buffer`) and dependencies. Dependencies: #54 (with #299 and #300) is merged. Step 6 (data-parallel loops) waits for #55, because `windows` takes an `ArrayList` today. #83 (`Dual`) is independent. #85 and through it #86 are blocked by this epic; #92 shares the in-place promise but is not related. Duplicate search of open and closed issues for tensor, matrix, buffer and compute: no other issue covers this. Stage refine: claim by session:loop-torbscript-20261023 released. Worker usage: about 90k tokens. next: waiting (epic: step #438 is ready, the epic itself closes when its checklist is done)
Author
Collaborator

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

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

[loop:torbscript] refine: step 1 (#438) is done; the checklist now carries the nine slices of docs/design/TENSOR.md section 11 instead of the old steps 2 to 6.

decided by the loop: the first build slice is slice 1 of the record (package, Tensor, constructors, indexing, Iterate/Show/Equals, tests, docs page, tensor-zeros and tensor-index), filed as #691 (loop, ready). Reshape and transpose move to slice 3 as the record cuts it; operators wait for slice 2. A keyword search of open and closed issues found no duplicate. #440 and #441 are closed and, per the record, block no slice. Seed: not touched. Later slices are filed just in time.

released the claim of session:loop-torbscript-20261030
next: ready (#691)

[loop:torbscript] refine: step 1 (#438) is done; the checklist now carries the nine slices of `docs/design/TENSOR.md` section 11 instead of the old steps 2 to 6. decided by the loop: the first build slice is slice 1 of the record (package, `Tensor`, constructors, indexing, `Iterate`/`Show`/`Equals`, tests, docs page, `tensor-zeros` and `tensor-index`), filed as #691 (`loop`, `ready`). Reshape and transpose move to slice 3 as the record cuts it; operators wait for slice 2. A keyword search of open and closed issues found no duplicate. #440 and #441 are closed and, per the record, block no slice. Seed: not touched. Later slices are filed just in time. released the claim of session:loop-torbscript-20261030 next: ready (#691)
Sign in to join this conversation.
No labels
loop
ready
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#82
No description provided.