Skip to content

Commit e90ed07

Browse files
hanwHan Wang
authored andcommitted
tinytpu: reserve BSV op 46 SXU_DISPATCH_MXU_VPU_EPILOGUE (slice 1)
Slice 1 of the generic-VPU MXU epilogue plan (sub-project 3 of the CODA-gap program). Reserves the opcode number end-to-end so later slices can plug in Controller + SXU dispatch without renumbering. - src/ScalarUnit.bsv: new SxuOpCode enum entry at ordinal 46. No dispatch case arm yet — encountering this opcode currently stalls the SXU rule (acceptable: no kernel emits it). - doc/plan-mxu-epilogue-generic-vpu.md: corrected op 44 -> 46 (op 44 was already taken by SET_REQUANT_CONFIG; 45 is DISPATCH_MXU_REQUANT; 46 is the next free slot). - tinygrad: submodule pointer bump for the matching Python ISA entry. Verification: 898/898 sim-backed backend tests pass.
1 parent dc8c0f9 commit e90ed07

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

‎doc/plan-mxu-epilogue-generic-vpu.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ single-bundle kernel becomes the default for every epilogue primitive
1010
(residual, RoPE, SwiGLU, partial-RMS, cross-entropy, …) instead of the
1111
multi-bundle GEMM→VMEM→VPU chain the runtime emits today.
1212

13-
**Architecture:** Add `SXU_DISPATCH_MXU_VPU_EPILOGUE` (op 44). The
13+
**Architecture:** Add `SXU_DISPATCH_MXU_VPU_EPILOGUE` (op 46). The
1414
Controller's drain stage embeds a VPU functional unit; on drain it
1515
applies the configured VPU op lane-wise between the drained accumulator
1616
matrix and a caller-supplied tile-shape src2. Result lands in
@@ -89,7 +89,7 @@ on `cfg[4]`. `cfg[5]` and `cfg[6]` are unused today.
8989

9090
## Target state
9191

92-
Add **`SXU_DISPATCH_MXU_VPU_EPILOGUE`** (op 44) with the same
92+
Add **`SXU_DISPATCH_MXU_VPU_EPILOGUE`** (op 46) with the same
9393
field overloading as op 42 except:
9494

9595
- `vpuOp` field carries the **actual `VpuOp`** (e.g. `VPU_PAIR_ROTATE`,
@@ -122,7 +122,7 @@ the meaningful microarchitectural delta.
122122

123123
---
124124

125-
## ISA encoding (op 44)
125+
## ISA encoding (op 46)
126126

127127
| Field | Meaning |
128128
|---|---|
@@ -154,8 +154,8 @@ the meaningful microarchitectural delta.
154154
### Slice 1: pure refactor, no behavior change
155155
- Add `SXU_DISPATCH_MXU_VPU_EPILOGUE = 44` to `SxuOpCode` enum.
156156
- Wire SXU rule that falls through to UNSUPPORTED (no behavior yet).
157-
- Add Python opcode 44 to `_SXU_OPS`.
158-
- Sanity: backend suite still passes (no kernel hits op 44 yet).
157+
- Add Python opcode 46 to `_SXU_OPS`.
158+
- Sanity: backend suite still passes (no kernel hits op 46 yet).
159159

160160
### Slice 2: Controller plumbing
161161
- Add `startGenericEpilogue(..., src2Tile, vpuOp, wbVmem)` method
@@ -177,7 +177,7 @@ the meaningful microarchitectural delta.
177177
- Writeback rule analogous to existing `do_mxu_epilogue_wb`.
178178

179179
### Slice 4: Assembler + Python bundle helper
180-
- `scripts/tasm.py`: encode/decode op 44 with the new field semantics.
180+
- `scripts/tasm.py`: encode/decode op 46 with the new field semantics.
181181
- New `_mxu_vpu_epilogue` helper alongside `_mxu_epilogue` in the
182182
tinygrad common bundle helpers.
183183
- Round-trip test in `tests/test_tasm.py`.
@@ -238,7 +238,7 @@ The same end-to-end RoPE test that today produces 5 VCDs produces
238238
**one** VCD, and the bundle dump shows a single SXU dispatch:
239239

240240
```
241-
2 44 <cfg> <dst> <src=cs_tile> 84(IPAIR_ROTATE) <wb_bit> <wbase> <abase> <tlen>
241+
2 46 <cfg> <dst> <src=cs_tile> 84(IPAIR_ROTATE) <wb_bit> <wbase> <abase> <tlen>
242242
2 7 HALT
243243
6 <out_addr>
244244
4

‎src/ScalarUnit.bsv‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,14 @@ typedef enum {
151151
SXU_LOAD_EPILOGUE_STAT,
152152
// SP3: drain-side requantization
153153
SXU_SET_REQUANT_CONFIG,
154-
SXU_DISPATCH_MXU_REQUANT
154+
SXU_DISPATCH_MXU_REQUANT,
155+
// Generic-VPU MXU epilogue: applies an arbitrary VpuOp lane-wise
156+
// between the drained accumulator and a tile-shape src2 (CODA-style
157+
// composable epilogue primitive). Stub only — execution is wired in
158+
// a later slice; this opcode currently falls through to a clean
159+
// UNSUPPORTED error so the encoding number is reserved.
160+
// Opcode 46 — must match assembler DISPATCH_MXU_VPU_EPILOGUE.
161+
SXU_DISPATCH_MXU_VPU_EPILOGUE
155162
} SxuOpCode deriving (Bits, Eq, FShow);
156163

157164
typedef struct {

‎tinygrad‎

0 commit comments

Comments
 (0)