Repository navigation
Conversation
….cp/tc.commit, tmem.ld/st, tmem.alloc/dealloc), with VX_CFG_TCU_WMMA_ENABLE; perf baselines re-recorded with pytest ci -m perf_gate --update-baselines, Beacon baselines with ci/logic_gate.py --update-baseline [--tool beacon_asic] --against-rev 1061088
jel221
force-pushed
the
feature/tmem-dataflow
branch
from
November 23, 2026 10:25
a6e49d3 to
92fe49b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN COMMENT:
To reiterate from the previous PR, to justify this design:
I want to decouple the accumulator from the whole pipeline (particularly, the issue stage) because 1. the uops take hostage of the issue pipeline and 2. the accumulators block those registers from being used in other useful computation because of the scoreboard and finally 3. the accumulator itself is limited by the register file size
To accomplish this you need a tensor accumulator that is tihgtly coupled to the tensor core itself and a uop sequencer that directly feeds into the tensor accumulator, and not the issue stage.
Some ISA differences:
tc.mma, tc.cp, tc.commit and tmem.alloc are issued by thread 0 (or in terms of software semantics, just needs the thread0 to be active and have the right register value), and tmem.alloc returns the column in thread 0's register, and software stores it to shared memory.
tc.commit waits for all of the CORE's earlier tc.mma / tc.cp, so if you commit then barrier the wait orders the MMAs against loads and stores which means you don't need the equivalent of a tcgen05.fence.
Your concerns from the previous PR:
I separated out the sparse full K and B prefetch, will make separate PRs for that later.
I added the write D -> read C hazard checker on the accumulator that you mentioned in the review on Wednesday. When a step fires, it puts its accumulator address in a tag FIFO, and when it writes back it gets cleared. Then when a new step fires, it checks its C address against the tags and delays if it maches.
I also addressed the area overhead. In the first iteration I moved the K iterations from software into a hardware job sequencer to see how much better it does. That ended up some ~10% speedup for a lot more area, so I removed the ISA but forgot to remove the block in the initial PR,so it's gone for good now. I also trimmed the TMEM unit itself, the report below will show you how many LUTs it ends up as on the FPGA. Mostly it is the decoder and selector into the actual accumulator array, which is pretty much unavoidable.
The flashattention row gives a 400x speedup, because from the work before there was no TFU and now it does, so it's not actually a real comparison, so I guess you can also see it as also the validity of the TFU work on the side. Ha
=========== AI-generated comment ===========
Tensor memory (TMEM) and the
tc.*MMA engineAdds Blackwell-style (
tcgen05) tensor memory to the TCU, behindVX_CFG_TCU_TMEM_ENABLE:NUM_TCU_BLOCKS × xtileMlanes byVX_CFG_TCU_TMEM_COLS32-bit columns, stored in block RAM, fragment-major.tc.mma: one K step per instruction. D is in TMEM; A comes from shared memory or TMEM; sparse metadata and MX scales come from TMEM.tc.cp: copies rows from shared memory to TMEM.tc.commit: completion arrives at a barrier.tmem.ld/tmem.stmove data between TMEM and registers, lane-per-thread or in fragment shape.tmem.alloc/tmem.deallocwork per CTA. The column is returned in thread 0, which stores it to shared memory astcgen05.allocdoes.VX_CFG_TCU_WMMA_ENABLE. TMEM builds can droptcu.wmma/tcu.ld, the landing queue and the metadata store.The full design is in
docs/designs/tensor_memory.md.Sparse on TMEM. With FEDP2K, a sparse
tc.mmastep fills the whole doubled-K FEDP with compressed A (2 × TC_Kwords), so one step covers twice the logical K of a dense step. The core's upper FEDP half selects its B values with the second half-K metadata row from TMEM (sp_sel_hi/sp_mux_hi). This full-K step is internal (TCU_SP_FULLK, defined when TMEM, sparse and FEDP2K are all on); there is no user option. WarpWGMMA_SPis unchanged from master.Why the full-K step:
It is what makes sparsity faster. Without it, a sparse step does the same K work as a dense step, so 2:4 sparsity saves storage but no time.
It matches NVIDIA. Every sparse MMA since Ampere covers twice the dense K per instruction: f16
mma.spm16n8k32 against m16n8k16,wgmma.spK=32 against 16,tcgen05.mma.spK=32 against 16. NVIDIA rates sparse throughput at 2× dense on A100, H100 and B200.It is the full 2× in practice (rtlsim,
sgemm_tcu_tmemsparse, fp16 → fp32, NT=8, 8 warps, issue width 4):tc.mmasteps.Area (Beacon,
tcuw, NT=32, sparse): the full-K step costs about 57.6K LUT (6.9%) in a TMEM build that keeps WMMA. That was measured by synthesizing with the step forced off.sp_mux_hi, 128 instances of 173 LUT).Not in this PR (separate PRs): sparse FULLK for warp WGMMA, and the dense K-major B next-block prefetch. (I'm interleaving a human comment here: so I left the sparse fullK option on WGMMA like you asked because it's hard to justify the speedup there, and also causes a software change which can be confusing I agree)
Builds without TMEM keep master's cycle counts (every non-TMEM perf gate is unchanged); their tile buffers are smaller (see Tests).
Performance (NT=8, 4 TCU blocks, 16 warps, FEDP2K, fp16 → fp32)
Against WGMMA. Both builds use the same configuration; the WGMMA build drops TMEM. Each WGMMA kernel is run with its fastest
WGMMA_NRC. Cycles are rtlsim (SimX).sgemm_tcu_wg_dxawith NRC=32. This is the kernelsgemm_tcu_tmemderives from, with the same DXA staging.sgemm_tcu_wg_sp.sgemm_tcu_tmemwithPIPE_N=2andTMEM_NCHUNK=4.tc.cp. Each step uses the full-K sparse path.flashattention4 -l64 -n32 -d32 -b4 -c4.flash_attn_tcu_wg, the only WGMMA flash-attention kernel, computes softmax with softwareexpf. On RV32 that means software double-precision calls.flashattention4uses the TFU for exp and runs softmax and MMA on separate warps.TMEM kernels:
-l64 -n32 -d64 -b4)-l64 -n32 -d32 -b4 -c4)tc.cpArea (Beacon,
tcuwDUT: 4 TCU blocks, 8 warps, issue width 4, FEDP2K, fp16, TMEM 512 columns)Each TMEM column is compared with the WGMMA-only build of the same formats.
tcu.wmma/tcu.ld, the landing queue and the metadata store. No Blackwell kernel mixesmma.syncwithtcgen05.sp_sel_hi/sp_mux_hi). WGMMA-only sparse shares one select row per FEDP row.tc.mmatakes its MX scales already placed in TMEM, so it needs no per-step scale-index arithmetic. The per-warptcu.wmmapath computes that index with a multiply and a divide (mx_scale_atinVX_tcu_core.sv). In an every-format TMEM build that keeps WMMA, this gives a 187-level path. Without WMMA the same build is 29 levels, and that is the configuration for MX on TMEM.Where the LUTs and FFs go, FP16 (TMEM minus WGMMA only):
VX_tcu_tmemtc.cpmaster)Inside
VX_tcu_tmem. FFs are exact register widths. LUTs are netlist LUTs by source line, scaled to Beacon's module total, so they are approximate.tc.cprow, store in either shape) and port controltmem.ld/tmem.sttransfer unitstc.cpsequencingThe area trims cut
VX_tcu_tmemat NT=32 from 23,331 to 12,225 LUT and from 6,034 to 2,061 FF:tmem.stwrites from the dispatch buffer, which holds the data until accepted, so the slot no longer keeps 1,024 bits of register data.tmem.allocreturns its result in thread 0 only.Tests
sgemm_tcu_tmem: dense, sparse,tc.cp, A from TMEM, MX, and NT=4/16/32.sgemm_tcu_tmem_mx.flashattention4.perf_gate-tmem).pytest ci -m perf_gate --update-baselines. Every non-TMEM perf gate keeps master's cycle and instruction counts; the newperf_gate-tmemis 42,569 cycles.ci/logic_gate.py --update-baseline [--tool beacon_asic] --against-rev 1061088aa. No unit is deeper in any FPGA or ASIC build. The tile buffers' row-merging write path also makes non-TMEM WGMMA builds smaller: thetcuDUT goes from 117,205 to 96,340 LUT andtensorfrom 259,758 to 217,719, with the same flip-flops.