Outcome and ownership
A bounded implementation issue under #663 (tensor/operation semantics), coordinated with #665 (checked graph lowering), #664 (gradient consumers), #602 (traffic ledger), #603 (arithmetic fusion) and #644 (residency). Reuse the existing compiler/backend/session owners and CUDApp #35/#16. This is not another backend, scheduler, generic fusion roadmap or claim about the live serving model.
Implement and qualify the seeded handwritten .om replacement of this specific matmul realization path. Preserve the exact existing profile first. A Tensor Core/FMA profile is a separate numerical contract, not a shortcut to bit-exact parity.
Source evidence, pinned 2026-10-24
Default main was 046cc9d2369951f484930be7a28f35fa9ab3b20b.
- Semantic matmul gathers broadcast A and transposed B; for each output it copies a length-K row and column into
pa/pb(995–996), materializes every rounded product through elementwise FMUL (998), then invokesreduce_rows(999–1002). The fixed product block is 2^20 elements (930–931). This is not a call to the existing resident GEMM API. - GB10 reduction realization copies the product array into
cur, copies/pads each tree level intolvl, returnsresto host and gathers every warp's lane-zero partial on host. The elementwise adapter chunks at 65,536 elements. - Every successful E1 numeric invocation opens a native context/channel, allocates execution/operand buffers and copies input; 329–331 copies output back and closes it. This is specific to the semantic E1 path: the separate serving matmul already has a shared session, resident weights and cached kernels.
- The path is actually called by GB10 tensor cases, and autodiff forward / backward. The existing GB10 shape corpus includes 129×3×257, 2×K×3 around tree boundaries, broadcast and transpose cases. Large square cases below are proposed scaling controls, not evidence of a deployed serving bottleneck.
Mathematical model — software counts, not measured memory traffic
Let b be the resulting broadcast-batch count, A have M×K elements per logical batch, and B have K×N.
paandpbdestination writes alone: Q_pack = 8 b M N K bytes (two FP32 vectors per output).- The logical dense A+B+C footprint is F = 4 b (MK+KN+MN) bytes. This is a footprint comparator, not an attainable DRAM bound; broadcast physical input footprints may be smaller.
- For a square, unbatched n×n matmul, Q_pack/F = 2n/3.
- This excludes source reads, initial gathers, product writes, padding, reduction temporaries, backend staging, cache effects and allocation. It must not be presented as DRAM transactions or a speedup.
For each product block with c outputs, let l_0=K and l_(j+1)=ceil(l_j/32). Run at least one reduction level, stopping after a level produces length one. The successful baseline's numeric-call count is:
sum_blocks [ceil(c*K/65536) + sum_levels ceil(c*32*ceil(l_j/32)/65536)],
where the output block capacity is min(b*M*N, max(1,floor(2^20/K))).
Checked with Wolfram Language from this control-flow model:
| b,M,K,N | pa/pb destination writes | logical A+B+C footprint | E1 numeric invocations/context opens |
|---|---|---|---|
| 1,64,64,64 | 2 MiB | 48 KiB | 10 |
| 1,512,512,512 | 1 GiB | 3 MiB | 4,224 |
| 1,1024,1024,1024 | 8 GiB | 12 MiB | 33,792 |
These are analytical successful-path counts; confirm with counters before treating them as measured. Numeric invocations are not a claim about the number of physical QMD/kernel launches.
Bounded implementation
- Add/use a checked operation-level matmul realization seam carrying original input descriptors, shape/stride/broadcast information, numeric profile and storage generations. Do not force original tensors through an expanded
[b*M*N,K]product representation. - Implement one bounded exact .om CPU/device schedule which computes FMUL leaves and the prescribed 32-way reduction tree without round-tripping every tree level to host. Keep only necessary partials; document per-CTA/register/shared-memory capacity and synchronization. Tile input reuse where it is legal and beneficial; do not assume aggregate chip SRAM is one addressable pool.
- Amortize code/context/allocation using the existing native session/backend lifecycle. A resident allocation is not automatically on-chip residency. Preserve cancellation, uncertain-completion latching, quarantine/retirement, visibility and generation checks.
- Separate attribution arms: baseline; session amortization with unchanged arithmetic/data layout; then exact resident product/reduction lowering. If tiling is a further change, measure it separately. Do not hide input layout/packing, cold preparation, output materialization or validation cost.
- Reconcile existing .om branches before editing; consume metadata admission rather than duplicating it. Missing native language/device facilities are concrete compiler-owner blockers.
Required semantics
The frozen profile is FMUL_RNE per product, no FMA, then recursive tile-32 pairwise sums with lane deltas 16,8,4,2,1 and identity padding, including at least one level. Preserve all established nonfinite/subnormal/signed-zero behavior and refusal categories. A faster reassociated/tensor-core answer must carry a separately qualified bounded profile.
Do not silently change public storage semantics: releasing an owning tensor currently invalidates its views. A retained buffer must not make a revoked generation observable. Copies may only disappear where ownership/lifetimes and all readers permit it.
Acceptance
- Compile and run native .om descriptor/shape tests and exact arithmetic goldens; independently compare forward results and applicable backward gradients. Cover K=1,31,32,33,63,64,65,1023,1024,1025, ragged M/N, noncontiguous/transposed inputs, broadcast batches, nonfinite values, signed zero, subnormals, shape overflow/OOM and stale generations.
- Reuse the existing wrong-reduction-order and FFMA mutants; add omitted-tail, wrong-broadcast-stride, early-free and missing-dependency mutants. A build error, crash or timeout is INVALID, not a caught semantic mutant.
- Counters reconcile copy-destination bytes, allocated/peak bytes, host/device materializations, numeric calls, actual launches, context opens and waits for all arms. Show
pa/pbexpansion and host tree-level round-trips disappear in the qualified arm. Label cache/DRAM/C2C counters MEASURED, ANALYTICALLY_ESTIMATED or UNKNOWN; never infer physical traffic frommemcpylengths. - Quiet reserved Spark/GB10 A/B runs report cold and warm end-to-end p50/p95, device timestamps separately from host time, scratch, registers/shared memory/spills and variation. Test below/above on-chip capacity and small shapes where the optimized schedule may lose. Include complete setup, transfer, synchronization, validation and teardown cost.
- Pin the beneficial regime or publish NO-GO/INCONCLUSIVE. Keep unqualified variants out of serving. Hardware and production gates remain NOT_RUN until actually exercised; this source audit ran no repository code and no GPU job.
- Qualify the .om consumer cutover, then delete the superseded first-party implementation/dependencies from the active delivery tree. Historical pinned source and immutable evidence remain in Git; no permanent C wrapper/fallback or duplicate production engine.
Dedup / branch status
As inspected 2026-10-24:
- #663 already owns tensor semantics; this issue is its concrete data-movement/lowering experiment, not a replacement.
- PR #674, head
8975287573f284dd2140b2f2b169619d3e145cf1, implements integer metadata/lifetime admission only, not allocation or arithmetic. Reuse it. Author aien-spark; no assignee/reviewer recorded at inspection. - PR #615, head
e9246850dc0b1bbc15886ba909c134308728d081, and #616, head8018d70cfd2af6e65e5657a993f950268f8d5ca7, add GEMM/reduction/scan kernels but their changed-file sets do not integrate this tensor realization seam. Reconcile CUDApp ownership and exact numeric profiles before reusing them. - #602/#603 already own general locality/fusion; #569 owns lifetime arena reuse; #604 persistent tile experiments; #473 resident training matmul. None should be re-opened as a new generic plan. This issue's distinguishing acceptance is elimination of the actual semantic tensor path's per-output product expansion and per-level host reduction materialization.