compute: design record for std/tensor on the CPU (step 1 of #82) #438
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Step 1 of #82 (compute:
std/tensoron the CPU; ROADMAP "Computation and machine learning", COMPUTE.md sections 1 and 2).Buffer<Item>is built (#54, #299, #300), butstd/tensoris not one PR: COMPUTE.md is a stub that says its own full design "comes before the first of these packages is built". Nothing yet fixes the type (Tensor<Scalar>and what its shape and strides are), the scalar bounds (Numeric,Real,Plain), whether a slice is a copy or a view, the broadcasting rule and how a shape mismatch is reported, which operators exist and whether the checker accepts operator traits with a foreignOtherandOutput(a tensor times a scalar), how a result is written in place, and what the first parallel loop needs (windowsstill takes anArrayList, not aBuffer). That has to be decided in writing before any code. This step is documentation only.Goal
A design record
docs/design/TENSOR.mdthat specifiesstd/tensoron the CPU as pure TorbScript onBuffer<Item>and cuts the build into slices, each one PR.Acceptance criteria
docs/design/TENSOR.mdexists, headed and indexed like the other records (status line "designed, not built", an entry indocs/design/index.md); COMPUTE.md section 1 (layer 1) and section 2 and the ROADMAP point "Computation and machine learning" link it;docs/regeneratesskills/(torb docs skill docs skills, a tier A gate).Tensor<Scalar>(shape and strides as run-timeInts over aBuffer<Scalar>, offset, row-major order), the invariants a value keeps, how a zero-sized dimension and a rank 0 tensor behave, and the construction functions of the first slice (zeros,ones,filled, from a flat list plus a shape, fromstd/random). Each is a numbered decision with its reason.Numeric,squareRoot/exp-like members underReal,Plainwhere a window is handed to a worker) and whatFloat32lacks (extend Float32 with Real, LINEAR gap 8) andFloat16/BFloat16(not built, out of scope). Says whether aFloat32Realis a prerequisite slice, and which scalar the first slices test on (Float64,Int,Fixed).tensor[a..b, c], in light ofBuffer.slicecopying (#54) andWindow(CONCURRENCY section 6) being a borrow for one call; the value-semantics consequence is written out with an example.Result) following PANICS.md and the conventions ofstd/linear.add/subtract/multiply/divideas methods and operators, scalar operands,reshape,transpose, reductions (sum,min,max,mean, optionally along an axis),dotandmatmul. For the operators the record runs a scratchtorb checkprobe (shown in the record) forTensor * ScalarandScalar * Tensorunder today's checker (COMPUTE.md section 3, "operator traits with a foreignOtherandOutput") and records the result; a checker gap becomes its own issue, named in the record, never part of astd/tensorslice.var fn, a pre-sized resultBuffer, theBufferpromise of #54), and how this meetswindows/Window(today overArrayList, to move toBufferwith #55) for the data-parallel loop; the first slices are serial, and the record names the slice that adds the parallel loop and what it waits for.Dual(#83),std/gpu(#85) and reverse mode (#86) need from a tensor (storage access, shape type, how a kernel receives a tensor), stated as constraints, without designing those packages.Buffer: elementwise add of 1 000 000Float64, a 256 x 256matmul, a fullsum, the pattern oftools/buffer-cost.sh(fastest of nine runs on the forge CI runner, a measurement and not a gate). The first implementing slice records the numbers.Buffer, no new native and no syntax: expected none; a slice that needs one falls under the two-commit rule, the seed refresh itself stays with the owner). A slice is filed as its own issue only when it starts.Design record point
COMPUTE.md sections 1 (layers 0 and 1), 2 and 3; COLLECTIONS gap 6 and the
Bufferrow of its table; CONCURRENCY section 6 (windows, "the tensor loop"); ECS "What the design needs fromBuffer<Item>" (the in-place promise); LINEAR gaps 8 and 9; RANDOM.md; PERFORMANCE.md for the way a cost is measured.Seed impact
None for this step (documentation only; no
std/,runtime/orcompiler/file changes, no native, no syntax, no name the compiler looks up). The later slices are expected to be pure TorbScript; the record states for each whether it touches the seed.Size
One PR, one Conventional Commit (
docs(compute): design record for std/tensor on the CPU).Out of scope
Any change to
std/,runtime/orcompiler/;Float16/BFloat16;Dual,std/gpu,std/gradient,std/learning(their own issues, only the interface constraints are recorded); running the benchmarks; the seed.Dependencies
None hard: #54, #299 and #300 are merged. Read #55 (collections on
Buffer, open) for thewindows-over-Bufferquestion and #84 (foreign functions, open) only to note thatstd/tensoron the CPU needs neither. Part of #82.std/tensoron the CPU #82std/tensoron the CPU #82[loop:torbscript] decided by the loop: filed as step 1 of epic #82 after a keyword search of open and closed issues (tensor, matrix, buffer, compute, simd: no duplicate). One PR, one commit (
docs(compute): design record for std/tensor on the CPU), documentation only, so the seed is not touched. Naming follows the existing records (TENSOR.mdbesideCOMPUTE.md,COLLECTION-STORAGE.md). All design questions listed are technical and are decided by the record itself; no owner question. No unmerged hard dependency (#54, #299, #300 are merged).next: ready
[loop:torbscript] claim implement by session:loop-torbscript-20261023 until 2026-10-23T22:21Z
scalar * valuewith a userMultiplyon the number type lowers as the builtin product #440Multiply<Scalar>andMultiplyon one generic type are refused as overlapping #441[loop:torbscript] implement: PR #442 opens
docs/design/TENSOR.md(designed, not built), indexed and linked from COMPUTE.md and the ROADMAP. Forge CI is green (gates, tier A, bootstrap, pdisc, commit messages). What remains: review and merge by Argus. The probe forTensor * Scalaris recorded; the checker gaps are filed as #440 (scalar * tensorlowers as the builtin product) and #441 (Multiply<Scalar>andMultiplyoverlap on one generic type). The build slices (section 11) are filed just in time by the loop.scalar * valuewith a userMultiplyon the number type lowers as the builtin product #440Dualnumbers (forward mode) #83std/tensor,Tensor<Scalar>over aBuffer(step 2 of #82) #691std/tensoron the CPU #82