NVFP4 Tensor Core on FPGARelease 1.0.0 · 8 October 2026

A bit-exact NVFP4 tensor core and transformer engine on a small FPGA

NVFP4 workspace, release 1.0.0. The text, figures and numbers describe the RTL and the board measurements of this release.

Abstract. NVIDIA's Blackwell GPUs multiply matrices of 4-bit NVFP4 numbers in dedicated tensor cores, but NVIDIA does not publish the exact arithmetic of these units. We measure that arithmetic on two GPUs and build an open tensor core on an AMD Artix-7 FPGA whose results equal the GPU's bit for bit. The tensor core does 512 multiply-accumulates per cycle at 50 MHz in a 2 × 64 × 4 grid, with four 4-bit products packed into each DSP slice. An eight-lane FP32 vector unit adds softmax, normalization, activations and NVFP4 quantization, and a small programmable engine sequences the units without the host. Together they run a complete transformer layer (RMSNorm, FlashAttention and SwiGLU, 16 tokens) on the board in 139,244 cycles (2.8 ms). On the board, 60,416 of 60,416 tensor-core outputs equal those of an RTX 5090.

1Introduction

Neural networks spend most of their arithmetic in matrix multiplication, and the cost of each multiplication falls with the number of bits per operand. Recent GPUs therefore multiply 4-bit numbers. NVIDIA's NVFP4 format stores each element in 4 bits and gives each group of 16 elements a shared 8-bit scale [3]. Its tensor cores multiply such matrices and add the products into 32-bit floating-point (FP32) accumulators.

NVIDIA documents the formats and the instructions, but not the order in which a tensor core adds the products or where it rounds. These details decide the last bits of every result. A hardware design, a simulator or a numerical study that ignores them gives results that differ from the GPU in ways that are hard to explain. We take the rounding behavior from silicon, write it down as a precise contract, and build hardware that follows it exactly.

The hardware runs on an inexpensive test board with an AMD Artix-7 FPGA. A host computer controls it through a serial link. This document describes the complete design, and it is written so that a reader from outside computer architecture can follow it. §2 explains the background: floating-point rounding, 4-bit block-scaled numbers, tensor cores and FPGAs. §3 gives the system organization. §4 defines the arithmetic that the tensor core must reproduce, and §5 describes the tensor core. §6 describes the vector unit, and §7 the programmable engine and the transformer layer that it runs. §8 gives the verification method, §9 the cost and speed, and §10 the limitations.

Contributions. (1) A contract for NVFP4 and MXFP4 matrix multiply-accumulate, calibrated on an RTX 5090 and a Jetson AGX Thor. The two GPUs agree on all 920,079 test vectors, and the contract matches them on 600,005 of 600,054 random vectors. (2) A tensor core that implements the contract with 512 multiply-accumulates per cycle. It packs four 4-bit products into each multiplier slice of the FPGA, which saves a third of its logic. (3) A vector unit and a programmable engine with which the whole transformer layer runs on the device, with results that match an independent reference model. (4) A verification chain from a numerical model to the board, in which every level is compared with GPU silicon.

2Background

This section is for readers outside computer architecture. A reader who knows floating point and FPGAs can go to §3.

2.1Matrix multiplication

The product C = AB of an M × K matrix A and a K × N matrix B has M × N entries. Each entry is a dot product of length K: Cij = Σk Aik Bkj. One multiplication and one addition form a multiply-accumulate (MAC), so the product takes M N K MACs. A 64 × 256 by 256 × 64 product, the largest tile of our tensor core, takes 1,048,576 MACs. Hardware for matrix multiplication is fast when it does many MACs in parallel and when it reuses each operand that it reads from memory for many MACs. In a transformer, the layer that we run in §7, the matrix products compute the queries, keys and values, the attention scores, and the feed-forward network.

2.2Floating-point numbers and rounding

A floating-point number stores a sign, an exponent and a significand: x = (−1)s × 1.f × 2e. FP32 [11] uses 1 sign bit, 8 exponent bits and 23 fraction bits, so neighboring FP32 numbers differ by about one part in 224 of their size. This spacing is one unit in the last place (ULP). The exact result of an operation is usually not an FP32 number, so the hardware rounds it. Round-to-nearest-even (RNE) picks the nearest FP32 number and breaks ties toward an even last bit. Round-toward-zero (RZ) cuts off the extra bits.

Because every operation rounds, the order of operations changes the result. In FP32, 224 + 1 lies exactly between 224 and 224 + 2, and RNE rounds it down to 224. Thus (224 + 1) + 1 gives 224, but 224 + (1 + 1) gives 224 + 2. Two designs that add the same 64 products in a different order, or round at different points, can therefore return different bits. “Bit-exact” in this document means that our hardware returns the same 32 bits as the GPU for every input. For that, it must reproduce the order and the rounding points of the GPU, not only the mathematical result.

2.3Four-bit numbers with block scales

A 4-bit E2M1 number has 1 sign bit, 2 exponent bits and 1 mantissa bit. Its 16 codes give only 15 values: 0, ±0.5, ±1, ±1.5, ±2, ±3, ±4 and ±6 (Figure 1a). To store real data in this set, we divide the data by a scale so that the largest magnitudes land near 6, and round each quotient to the nearest E2M1 value. One scale for a whole tensor fits its largest values but wastes the few available values on the small ones. Block scaling solves this. NVFP4 gives each block of 16 consecutive elements its own scale, stored as an 8-bit UE4M3 number (an unsigned float with 4 exponent and 3 mantissa bits, up to 448), and adds one FP32 scale for the whole tensor [3] (Figure 1b). An element then costs 4.5 bits on average. MXFP4, an open standard [2], is similar but uses one power-of-two (E8M0) scale per 32 elements.

The product of two NVFP4 elements is the product of the two E2M1 values times the two block scales. A 64-element dot product thus has four blocks of 16 products, and each block has its own pair of scales. The tensor scales are applied once, after the matrix product.

aE2M1 element: 1 sign bit, 2 exponent bits, 1 mantissa bit −6 −4 −3 −2 −1.5 −1 −0.5 0 0.5 1 1.5 2 3 4 6 0000 0001 0010 0011 0100 0101 0110 0111 codes 1000 to 1111: the same values, negative bOne NVFP4 block: 16 elements share one scale 1.5 −0.5 6 0 2 −3 1 0.5 −1 4 0 −2 3 1.5 −6 1 16 elements × 4 bits = 8 bytes × 0.5 block scale UE4M3, 1 byte × 1 tensor scale FP32, one per tensor value = element × block scale × tensor scale, for example 1.5 × 0.5 × 1 = 0.75
Figure 1. The NVFP4 format. (a) The 15 values of an E2M1 element, to scale, with the codes of the positive half; a set sign bit makes the value negative. The spacing doubles at each power of two. (b) One block: 16 elements share one UE4M3 scale. One FP32 tensor scale serves the whole tensor. The example block holds the values 0.75, −0.25, 3, … of real data whose largest magnitude is 3.

2.4Tensor cores

A GPU tensor core is a unit that executes one small matrix multiply-accumulate per instruction. On the RTX 5090, the instruction mma.sync…m16n8k64 multiplies a 16 × 64 NVFP4 matrix by a 64 × 8 one and adds the result to a 16 × 8 FP32 accumulator [1]. A longer product, for example with K = 256, chains four such instructions: each takes the result of the previous one as its accumulator. The Jetson AGX Thor uses a different instruction family, tcgen05.mma, with the same formats. NVIDIA does not document how these instructions round. A public simulator, MMA-Sim [5], models them, but our measurements found cases in which it disagrees with silicon (§4).

2.5FPGAs

A field-programmable gate array (FPGA) is a chip whose circuit is defined after manufacture, by loading a configuration file called a bitstream. Our design is written in SystemVerilog, a hardware description language, and the vendor tool Vivado translates it into a bitstream. The chip provides four kinds of resources (Table 1). Look-up tables (LUTs) implement any logic function of up to six inputs. Flip-flops (FFs) store single bits. Block RAMs store data, 36 Kbit each. DSP slices are fixed multiplier-adder circuits. Our Artix-7 xc7a100t has 63,400 LUTs, 126,800 flip-flops, 135 block RAMs and 240 DSP slices [10]. These numbers are the budget of the whole design.

The circuit runs from a clock at 50 MHz. At each clock edge, every register (a group of flip-flops) takes a new value, and the logic between registers must settle within one period of 20 ns. The tool reports the worst negative slack (WNS): the margin of the slowest path. A positive WNS means that the design meets the clock. To keep paths short, a long computation is split into stages with registers between them. This is a pipeline: like an assembly line, it starts a new operation every cycle while earlier operations move through the later stages. Its latency is the number of cycles from input to result, and its throughput is the number of operations it starts per cycle.

2.6Memory-mapped devices

The units of our design communicate by reads and writes to addresses, as a processor talks to its peripherals. Each unit, called a device, owns a range of addresses. Some addresses are memory: a write stores data and a read returns it. Others are registers with an effect: a write to a control register starts an operation, and a read of a status register shows whether the operation is done. This method is memory-mapped I/O (MMIO). A bus carries the reads and writes. Our bus follows TileLink-UL [8]: a request (Get to read, PutFullData to write) travels to a device, and the device sends back one response. The data that the bus moves at one time is a beat. The host reaches the bus through a serial link that carries the Tethered Serial Interface (TSI) protocol [6], which packs reads and writes into bytes.

Table 1. Terms used in this document.
TermMeaning
MACmultiply-accumulate: c ← c + a b
FP32IEEE 754 binary32: 1 sign, 8 exponent, 23 fraction bits
E2M1, UE4M3, E8M04-bit element; unsigned 8-bit scale with 4 exponent and 3 mantissa bits; 8-bit power-of-two scale
RNE, RZround to nearest, ties to even; round toward zero (truncate)
ULPunit in the last place: the gap between neighboring floating-point numbers
Bit-exactthe same output bits as the reference for every input
M, N, Krows of A and C; columns of B and C; the length of each dot product
LUT, FF6-input logic function; 1-bit storage element
Block RAMon-chip memory block: RAMB36 (36 Kbit), or one half of it, RAMB18
DSP sliceDSP48E1: a 25 × 18-bit multiplier with a pre-adder and a 48-bit adder
Pipeline, latencya computation split into clocked stages; cycles from input to output
WNSworst negative slack: timing margin of the slowest path; positive means the clock is met
MMIOmemory-mapped I/O: devices controlled by reads and writes to addresses
TSI, TL-ULserial protocol of the host link; the bus protocol
Beatthe data a bus moves at once: 32 bytes (eight 32-bit words) on our device bus

3System organization

A host computer talks to five devices over one bus. The tensor core multiplies matrices, the vector unit does the other arithmetic, the kernel engine moves data and starts the units, and the scratch memory holds the working data.

The device runs on a test board with an AMD Artix-7 FPGA (xc7a100tfgg484-1) at 50 MHz. A host PC drives it with PyUARTSI [6] through the board's USB–UART bridge at 921,600 Bd (Figure 2). The uart_tsi target decodes each TSI command into one TileLink-UL [8] request per 32-bit word. The device bus is wider: it moves 32-byte beats, eight words at a time. tl_widen places each host word in its lane of a beat, at the position given by its address.

An arbiter merges the host's requests with those of a second bus master, the kernel engine (§7.1). When both request, the master that did not go last wins. A crossbar routes each request to one of five devices by its address (Appendix Table A1). The bus has one transaction in flight, and a master keeps the bus until its response is accepted. The crossbar denies an address that no device owns: it drops a write and returns zero for a read.

The devices take beats in two ways. The scratch memory and the tile memory of the tensor core accept any words of a beat in one request, so a copy between them moves eight words per bus transaction. The register devices (the system registers, the vector unit and the kernel engine) take the words of a beat one at a time, through tl_narrow, at about two cycles per word. The vector unit has a second, private port to the scratch memory. Through it, the vector unit reads its operands and writes its results at one beat per cycle, and this traffic does not use the bus.

A host session. To multiply two matrices with the tensor core alone, the host writes A, B and their scales into the tile memory, writes the dimensions and a start bit, polls a status register, and reads C. The serial link is the slow part: loading a full 64 × 64 × 256 tile and reading the result takes about 0.6 s, against 51.2 µs of computation. For this reason, the complete transformer layer of §7 runs on the device. The host uploads the inputs, the weights and one program, and then reads back only the results.

FPGA: Artix-7 xc7a100t, 50 MHz Host PC PyUARTSI USB–UART bridge 921,600 Bd RXD TXD uart_tsi TSI decoder 1 word → 1 request tl_widen word → beat tl_arbiter tl_xbar 32-byte beats unmapped: denied tl_narrow sys_regs 0x0000_0000 · 4 KiB nvfp4_tc 0x1000_0000 · 64 KiB tl_narrow flash_vector 0x1001_0000 · 64 KiB tl_narrow kernel_engine 0x1002_0000 · 128 KiB scratch_memory 0x2000_0000 · 128 KiB vector port DMA master of kernel_engine
Figure 2. System organization. Thin lines carry 32-bit words and thick lines 32-byte beats. The kernel engine is a second bus master (dashed). The register devices take one word at a time through tl_narrow. The vector unit reads and writes the scratch memory through its own port (green). Highlighted: the tensor core.

4Target arithmetic

This section states exactly which 32 bits the tensor core must return for each input. We took this contract from GPU silicon, because NVIDIA does not publish it.

Formats. An NVFP4 tensor stores elements in E2M1, one UE4M3 scale for each block of 16 consecutive elements along K, and one FP32 scale for the whole tensor (§2.3). MXFP4 [2] instead uses one E8M0 power-of-two scale per 32 elements. Blackwell tensor cores also accept E8M0 per 16 elements. The core supports these three formats and unscaled FP4 (Table 2).

Table 2. Element formats of the core and the GPU instructions used as their reference. All use E2M1 elements and the mma.sync…m16n8k64 shape on sm_120a [1].
ModeFormatBlock scaleBlockSilicon reference
0NVFP4UE4M316kind::mxf4nvf4, scale_vec::4X, ue4m3
1MXFP4E8M032kind::mxf4nvf4, scale_vec::2X, ue8m0
2FP4none–mode 3 with every scale equal to 20
3MXFP4-16E8M016kind::mxf4nvf4, scale_vec::4X, ue8m0

Unit contract. One processing element (PE) computes d = c + Σk<64 ak bk sA(k) sB(k). The sum runs over 64 elements in four 16-element blocks, sA(k) and sB(k) are the block scales of element k, and the accumulator c is FP32. The contract below is rule rtx5090 of our calibrated model (tcgen05/nvfp4_tcgen05_check.py). The model started from MMA-Sim [5], and we corrected it wherever an RTX 5090 (mma.sync, sm_120a) disagreed. A Jetson AGX Thor (tcgen05.mma, sm_110a) and the RTX 5090 returned the same bits on all 920,079 of our test vectors, so one contract covers both GPUs. Each block sum is exact:

σg=∑i=015a16g+ib16g+i,g∈{0,1,2,3}. (1)

Products of E2M1 values are multiples of 1/4 and |σg| ≤ 576, so σg fits a short fixed-point word. We normalize each scale code to s = (S/8)·2e with a 4-bit integer S. For a UE4M3 code with exponent field E and mantissa m, or an E8M0 code x:

(S,e)={ (8+m,E−7)UE4M3, E>0 (m,−6)UE4M3, E=0,m>0 (0,−126)UE4M3, E=m=0 (8,x−127)E8M0, 0<x<255 (4,−126)E8M0, x=0 (2)

UE4M3 code 0x7F and E8M0 code 0xFF are NaN, and bit 7 of a UE4M3 code is ignored. Block g contributes γg = σg sA,g sB,g at exponent Xg = eA,g + eB,g. The accumulator c has exponent Xc = max(Ec − 127, −126), where Ec is its biased exponent. With emax = max(Xc, X0, …, X3), the result is

d=RZ32(2emax−35∑t∈{c,γ0,…,γ3}sgn(t)⌊|t|⋅235−emax⌋), (3)

where RZ32 truncates a real number to binary32. On overflow it returns ±∞ rather than the largest finite value, as the silicon does. In words: the hardware lines up the five terms (the four block sums and c) at the exponent of the largest one, cuts every term off 35 bits below that exponent, adds the five exactly, and cuts the sum to FP32.

Departures from exact arithmetic. Three properties of Eq. (3) separate it from a correctly rounded dot product, and a bit-exact implementation must keep all three. First, every term, c included, is truncated to 35 fractional bits below emax before the sum, so a small c can vanish. Second, a block takes its exponent Xg from its scales even when σg = 0. A zero block with a large scale therefore still moves the truncation point. Third, the final conversion truncates instead of rounding to nearest.

Special cases. These override Eq. (3) in the order given. A NaN in a used scale, or a NaN c, gives 0x7FFF_FFFF. An infinite c passes through. If all 64 products are zero, d = c, with −0 replaced by +0. MMA-Sim lacks this last rule, and 816 vectors of our first GPU run depended on it.

Model accuracy. The contract still differs from silicon on 49 of 600,054 random vectors (0.008%). In 15 of them, a zero block with a large scale sets the alignment point by a rule we have not yet identified. The other 34 are 28 subnormal and 6 normal outputs that differ by one unit in the last place. The hardware implements the contract, so it inherits these differences.

Tensor scales. The FP32 per-tensor scales are not part of the MMA. NVIDIA GEMMs apply them after the product as the epilogue factor α. Likewise, our kernel multiplies C by sAsB on the vector unit (§7.2).

5Tensor core

The tensor core is a grid of eight processing elements. Each one computes a 64-element dot product by the contract of §4, and the grid starts eight of them every cycle: 512 multiply-accumulates.

The tensor core, nvfp4_tc, owns 64 KiB at 0x1000_0000. This space holds its registers and the block RAMs for the operand tiles A and B and the accumulator tile C (Appendix Table A2). A tile is up to 64 × 64 × 256 (M × N × K). This section describes the processing element (§5.1), the grid and its memory (§5.2), the mapping of the products onto DSP slices (§5.3), and the schedule (§5.4).

5.1Processing element

The PE, fp4_fedp, evaluates Eq. (3) in a five-stage pipeline. It accepts one operation per cycle, and each result is ready five cycles after its operands (Figure 3). The block sums reuse the exact datapath of nvfp4-dotprod-formal-dv [4]: mul_lane_nvfp4, align_nvfp4 and exact_acc_tree, which upstream verified with formal and UVM testbenches. On our board, that datapath alone matched its exact golden model on 1.1 M vectors and the RTX 5090 on 100,008. We designed the fused accumulation that follows the block sums.

Stage 1 forms the 16 products of each block and sums them exactly. It also decodes the eight scale bytes by Eq. (2), forms SA,gSB,g and Xg, and evaluates the special-case conditions. Stage 2 multiplies each block sum by SA,gSB,g in a DSP slice. The result is an integer Tg = 4σg SA,gSB,g with |Tg| ≤ 2304 · 225 < 219, and γg = Tg · 2Xg − 8. In the same stage, the five exponents reduce to emax. Stage 3 expresses each magnitude in units of 2emax − 35 and shifts it right by emax − X. The shift implements the floor of Eq. (3) (Figure 4). The aligned block terms are 48 bits wide and the aligned c is 37 bits. Stage 4 adds the five signed terms exactly in 51 bits. Stage 5 finds the leading one, truncates to binary32, handles overflow and subnormal results, and applies the special cases.

Integer arithmetic makes the PE exact by construction: no step between the inputs and the final cut rounds, except the deliberate truncation of stage 3. Out of context, one PE uses 4,084 LUTs, 548 flip-flops and 4 DSP slices, and it meets 50 MHz with 7.8 ns of slack. Its 64 products take 1,280 of these LUTs; §5.3 moves them into DSP slices.

Stage 1 Stage 2 Stage 3 Stage 4 Stage 5 a, b 2 × 256 b sfa, sfb 2 × 32 b mode c FP32 block g, ×4 16 × mul_lane align exact adder tree σg scale decode, ×8 (S, e) by Eq. (2) SASB and Xg = eA + eB special cases NaN · c = ±∞ · all products 0 DSP multiply, ×4 Tg = 4σg · SASB |Tg| < 219 exponent max emax = max(Xc, X0 … X3) shift amounts emax − X c decode Sc (24 b), Xc align, ×5 shift right by emax − X; drop bits below 2emax−35 blocks: 48 b c: 37 b Σ 5 terms 51 b, exact normalize leading one cut to FP32 overflow → ±∞ subnormals special-case override d special-case flags
Figure 3. Pipeline of the processing element. Grey bars are pipeline registers. The four block datapaths are identical, and only one is drawn. The special-case flags (from the scales, c and the 64 products) bypass the arithmetic and select the output in stage 5.
γ₁at emax γ₀at emax − 6 γ₂at emax − 20 γ₃at emax − 30 cat emax − 15 cut at 2emax−35 8 0 −8 −16 −24 −32 −40 bit p, weight 2emax+p dropped: each term is cut toward zero kept, then summed exactly in stage 4
Figure 4. Alignment of the five terms of Eq. (3), schematic. Each bar spans the significant bits of one term: 19 bits for a block term (|Tg| < 219, least significant bit at 2Xg − 8) and 24 bits for c. Bits below 2emax − 35 are dropped, which truncates each magnitude toward zero before the sum. The exponents shown are an example.

5.2Grid and on-chip memory

Eight PEs form a 2 × 4 grid (Figure 5). Each cycle, the grid receives one 64-element K chunk of two rows of A and four columns of B. Every row of A feeds four PEs and every column of B feeds two, so the grid updates a 2 × 4 block of C with 512 MACs from 6 operand reads. In our microbenchmark, one RTX 5090 streaming multiprocessor sustains 2,048 NVFP4 MACs per cycle with four tensor cores, so each GPU tensor core has the same 512-MAC rate. In the default build, the eight PEs compute their products together in DSP slices (§5.3), and each PE keeps its own stages 2–5.

The PE width equals the K of the m16n8k64 instruction. With this width, the roundings of a K chain fall where the GPU puts them: an output with K = 256 is rounded four times on both. A 2 × 8 grid of 32-element units has the same MAC rate, but it rounds at twice as many points, so it cannot reproduce the GPU.

Memory. All tile storage is simple dual-port block RAM with one write port and one read port, in one RAMB18 each. The RAMs are banked so that one read of each delivers a full chunk to the grid (Table 3). Row i of A is in bank i mod 2 and column j of B in bank j mod 4. C[i][j] is in lane (i mod 2, j mod 4) at entry (⌊i/2⌋, ⌊j/4⌋). Each bank splits a 64-element chunk across eight 32-bit word lanes and keeps the chunk's four scale bytes in one more lane. The eight word lanes match the eight words of a bus beat, so one bus request reads or writes a whole chunk of a row in one cycle. The host and the sequencer share the RAM ports. The bus uses them while the core is idle. While the core runs, it serves only register reads, and other accesses wait.

B bank 0 j mod 4 = 0 B bank 1 j mod 4 = 1 B bank 2 j mod 4 = 2 B bank 3 j mod 4 = 3 A bank 0 i mod 2 = 0 A bank 1 i mod 2 = 1 PE 0,0 PE 0,1 PE 0,2 PE 0,3 PE 1,0 PE 1,1 PE 1,2 PE 1,3 A row 0 256 + 32 b A row 1 256 + 32 b 256 + 32 b C RAM: 8 lanes, lane (r, s) for PE r,s entry (⌊i/2⌋, ⌊j/4⌋), 512 entries per lane c, read at issue d, written 6 cycles later sequencer LOAD · ISSUE · DRAIN write-back FIFO, 16 entries address address
Figure 5. The 2 × 4 PE grid and its tile memories. Bank r of A feeds row r of the grid and bank s of B feeds column s. Per operand, a chunk is 256 bits of elements and 32 bits of scales. PE (r, s) reads and writes C lane (r, s). The sequencer also addresses the B banks (not drawn).
Table 3. Organization of the tile memories. kc is the 64-element K chunk (0–3). The tensor core uses 62 RAMB18 in total.
MemoryOrganizationRAMsEntriesLocation
A elements2 banks × 8 word lanes16128row i: bank i mod 2, entry (⌊i/2⌋, kc)
A scales2 banks × 1 lane2128as the elements
B elements4 banks × 8 word lanes3264column j: bank j mod 4, entry (⌊j/4⌋, kc)
B scales4 banks × 1 lane464as the elements
C8 lanes8512C[i][j]: lane (i mod 2, j mod 4), entry (⌊i/2⌋, ⌊j/4⌋)

5.3Products in DSP slices

Out of context, the 64 E2M1 products of one PE take 1,280 LUTs, and its four adder trees take 452. A signed product depends on all eight bits of its two codes, more than one 6-input LUT takes, so each product costs about 20 LUTs. In the 2 × 4 grid, the products alone take about 10,000 LUTs, a third of the tensor core. The Artix-7 has 240 DSP48E1 slices, and the rest of the design uses 36 of them, for the nine FP32 multipliers of the vector unit. A slice has a 25-bit pre-adder, a 25 × 18-bit signed multiplier and a 48-bit post-adder [10]. With packed operands, one multiply gives four products.

Packing. Let x̂ = 2x denote an E2M1 value as an integer, x̂ ∈ {0, ±1, ±2, ±3, ±4, ±6, ±8, ±12}, so that |â b̂| ≤ 144. Let â0 and â1 be element k of rows 0 and 1 of A, and b̂0 and b̂1 element k of columns 2p and 2p + 1 of B. One slice computes

(b^1⋅220+b^0)(a^1⋅210+a^0)=a^1b^1⋅230+a^0b^1⋅220+a^1b^0⋅210+a^0b^0, (4)

the 2 × 2 block of products of element k, in four 10-bit fields (Figure 6). This is the long multiplication of school arithmetic: the two factors are short numbers placed far apart in one wide word, so the partial products do not overlap. The pre-adder forms the first factor from ports D and A. LUTs form the second factor from the two rows of A; it enters port B, and both column pairs share it. Two slices add elements 2i and 2i + 1 and a bias β:

Pi=M2i+M2i+1+β,β=512(1+210+220+230). (5)

A sum of two products lies in [−288, 288], so each field of Pi holds a pair sum plus 512, in [224, 800]. No field is negative, so no field borrows from the one above it, and Pi is four unsigned 10-bit fields side by side. For one output and one block, eight fields add to 4σg + 4096, which lies in [0, 8192). Inverting bit 12 of this sum gives 4σg in two's complement. The tree of unsigned fields costs 55 LUTs per block sum; a tree of signed fields, with a carry-in to correct each borrow, costs 74.

Slice pair. Figure 7 shows a slice pair as Vivado maps it. The first slice multiplies element 2i + 1, and the fabric routes its product to the C port of the second slice. The second slice multiplies element 2i and adds the two products. A carry chain in the fabric adds β, and 40 flip-flops hold the result. Without β, Vivado places this adder and register in the second slice; with the constant β, it keeps both in the fabric. No slice register is used, so the products stay in stage 1 and the PE latency stays five cycles. The block-sum trees move to the start of stage 2, before the multiply by SASB.

Grid. The grid has two column pairs and 32 element pairs per chunk, so 2 × 32 × 2 = 128 slices compute its 512 products per cycle (Figure 8). Each output needs 16 slices for its products and 4 for its block terms (Table 4). A power-of-two grid larger than 2 × 4 therefore does not fit in DSP slices; the parameter DSP = 0 of nvfp4_tc restores the LUT products for such grids. Both builds give the same outputs. In two builds with the same bus, the DSP products cut the tensor core from 31,496 to 21,312 LUTs (32%).

port Dcolumn 2p + 1 b̂₁ 0 port Acolumn 2p sign of b̂₀ b̂₀ port Brows 0, 1 (LUTs) â₁ â₀ β512 per field 1 1 1 1 Pi2 elements + β 0 Σ â₁b̂₁ + 512→ d₁,₂ₚ₊₁ Σ â₀b̂₁ + 512→ d₀,₂ₚ₊₁ Σ â₁b̂₀ + 512→ d₁,₂ₚ Σ â₀b̂₀ + 512→ d₀,₂ₚ 0 10 20 30 40 47 bit
Figure 6. Operand packing for element k and the column pair (2p, 2p + 1), to bit scale. The pre-adder forms b̂1·220 + b̂0 from ports D and A. Port B carries â1·210 + â0; when â0 < 0, its upper field holds â1 − 1, as in any two's-complement sum. Bottom: the sum Pi of Eq. (5). The field of row r and column 2p + t lies at bit 10(r + 2t) and feeds output dr, 2p+t.
DSP48E1 · element 2i + 1 AREG = BREG = MREG = PREG = 0 b̂₁ · 2²⁰ D b̂₀ A â₁ · 2¹⁰ + â₀ B D + A pre-adder 25 b × 25 × 18 + Z = 0 M2i+1, 43 b fabric DSP48E1 · element 2i AREG = BREG = MREG = PREG = 0 b̂₁ · 2²⁰ D b̂₀ A â₁ · 2¹⁰ + â₀ B D + A pre-adder 25 b × 25 × 18 + Z = C C fabric + β carry chain 40 FFs 9–0: â₀b̂₀ → d₀,₂ₚ 19–10: â₁b̂₀ → d₁,₂ₚ 29–20: â₀b̂₁ → d₀,₂ₚ₊₁ 39–30: â₁b̂₁ → d₁,₂ₚ₊₁ to the block-sum trees
Figure 7. One slice pair in the routed design. Purple: B operands; blue: the packed A operand. The internal registers of both slices are unused, so the decode LUTs, both slices and the β adder form one combinational path from the RAM outputs to the 40-bit stage-1 register. This path is the critical path of the release build (§9).
Stage 1 Stages 2–5 B bank 0 B bank 1 decode E2M1 → b̂, 5 b 2 columns × 64 column pair 0 columns 0 and 1 32 slice pairs 64 DSP48E1 32 × 40-bit field words block-sum trees 4 outputs × 4 blocks 8 fields each → 4σg, bit 12 inverted fp4_fedp_acc × 4 scales, align, Σ, cut to FP32 d₀,₀ d₁,₀ d₀,₁ d₁,₁ to C B bank 2 B bank 3 decode E2M1 → b̂, 5 b 2 columns × 64 column pair 1 columns 2 and 3 32 slice pairs 64 DSP48E1 32 × 40-bit field words block-sum trees 4 outputs × 4 blocks 8 fields each → 4σg, bit 12 inverted fp4_fedp_acc × 4 scales, align, Σ, cut to FP32 d₀,₂ d₁,₂ d₀,₃ d₁,₃ to C sfa, sfb, c sfa, sfb, c A bank 0 A bank 1 pack â₁ · 2¹⁰ + â₀ 64 words, 18 b 128 DSP48E1 for the products 32 DSP48E1 for the block terms
Figure 8. The 2 × 4 grid with the products in DSP slices (fp4_fedp_dsp). The packed A operand is formed once and feeds both column pairs. The grey bar is the stage-1 register of Figure 3. Stages 2–5 are those of Figure 3, one copy per output, with the tree replacing the stage-1 block sum. Not drawn: the all-zero check per output, which reads the element codes directly.
Table 4. Use of the 240 DSP48E1 slices of the xc7a100t.
FunctionOperandsPer outputSlices
E2M1 products, Eqs. (4)–(5)25 × 18 b, pre-adder16128
Block terms Tg = 4σg·SASB13 × 9 b432
Vector unit: nine FP32 ALUs, one 32 × 32-bit multiplier each32 × 32 b–36
Total196 (82%)

5.4Dataflow and scheduling

The sequencer runs the weight-stationary loop nest of Algorithm 1. "Weight-stationary" means that the operand B, which holds the weights of a neural-network layer, stays in place while the rows of A stream past it. For each block of four columns of B and each K chunk, the sequencer reads that chunk of B once and holds it in the RAM output registers. It then issues one block of two rows of A per cycle against the held weights. An issue reads A and C at cycle t. The PEs receive the operands at t + 1, and the sequencer writes the result to C at t + 6 (Figure 9, top). A 16-entry write-back FIFO carries the C address of each operation in flight.

Algorithm 1. Weight-stationary schedule of one START. Comments give the cost in cycles.
  1. input: dimensions (M, N, K), mode, OVERWRITE
  2. for jb ← 0 to N/4 − 1 do ▷ column block of B and C
  3. for kc ← 0 to ⌈K/64⌉ − 1 do ▷ K chunk
  4. LOAD B[jb, kc] into the B RAM output registers ▷ 1
  5. mask ← (K mod 64 = 32) ∧ (kc = ⌈K/64⌉ − 1) ▷ K tail
  6. for ib ← 0 to M/2 − 1 do ▷ 1 each
  7. ISSUE: read A[ib, kc] and C[ib, jb]; push (ib, jb) to the write-back FIFO
  8. c ← 0 if OVERWRITE ∧ kc = 0 else C[ib, jb]
  9. C[ib, jb] ← PE(A[ib, kc], B[jb, kc], c, mask) on all 2 × 4 PEs ▷ written at issue + 6
  10. DRAIN until no operation is in flight ▷ 7

Hazards. The next K chunk reads the C entries that the current chunk writes. The sequencer does not forward results. Instead, it drains the pipeline before it advances K. The drain costs seven cycles per group and keeps the core correct for every M, including M = 2, where the same C entry is read and written in consecutive groups. A run takes

Trun=N4⋅⌈K64⌉⋅(M2+8)cycles. (6)

A full 64 × 64 × 256 tile takes 2,560 cycles (51.2 µs), of which 2,048 are issue cycles (Figure 9, bottom). Small tiles pay the load and drain cost per group: a run with M = 2 issues in one cycle of every nine.

K tails. The memory layout fixes the chunk at 64 elements, but K may be any multiple of 32. When K = 64n + 32, the sequencer marks the last chunk (line 5 of Algorithm 1). The grid then zeroes the elements of A past K and the scales of A and B past K. In MXFP4 with 32-element blocks, only scale byte 0 is kept. The zero elements make the padding products zero. The zero scales give the padding blocks exponent −252. This is below Xc ≥ −126, so the padding cannot move emax in Eq. (3). The result equals an m16n8k64 MMA on operands zero-padded with zero scales. The transformer layer depends on this case, because its products have K = 32.

One operation t t + 1 t + 2 t + 3 t + 4 t + 5 t + 6 issue, RAM read PE pipeline, stages 1–5 write C One column block of a full tile, to scale K chunk 0 K chunk 1 K chunk 2 K chunk 3 load B drain 0 40 80 120 160 cycles
Figure 9. Timing. Top: one operation. Bottom: one block of four columns of a full tile, to scale. Each K chunk loads B for 1 cycle, issues 32 row blocks, and drains for 7 cycles. A full tile repeats this for 16 column blocks, which gives 2,560 cycles.

6Vector unit

The vector unit does every operation of the transformer layer that is not a matrix product: additions and scaling, the softmax of attention, normalization, activation functions, and the conversion of FP32 data to NVFP4.

6.1FP32 lanes

The vector unit, flash_vector at 0x1001_0000, has eight lanes (Figure 10). Each lane has its own FP32 arithmetic unit (ALU), fp32_alu, which adds, subtracts, multiplies, takes the maximum, and computes 2x (EXP2) and 1/x (RECIP). The ALU works on one operation at a time over several cycles, and it registers every intermediate step, so its paths stay short. One 32 × 32-bit integer multiplier, four DSP slices, serves multiplication, EXP2 and RECIP. All arithmetic rounds to nearest even. Subnormal inputs and results become zero with their sign kept, as with the .ftz instructions of a GPU, and every NaN result is 0x7FFF_FFFF.

A GPU computes 2x and 1/x approximately, in special function units. The PTX specification bounds their error at 2 and 1 ULP [1], but it does not publish the method. Our ALU uses its own approximations. EXP2 looks up 2f in a 64-entry table and corrects the remainder with a cubic polynomial. RECIP starts from a 128-entry table and refines the estimate with two Newton steps. Against the RTX 5090's ex2.approx.ftz and rcp.approx.ftz, the results are within 2 and 1 ULP. The lanes build further operations from these steps (Table 5). AXPY multiplies and then adds, with two roundings. RSQRT brings the mantissa into [1, 4), runs four Newton steps and applies the exponent. SILU computes x · 1/(1 + 2−x log2 e).

A ninth ALU runs the steps that combine lanes, in lane order 0 to 7: the MAX and SUM reductions, the row maximum, α and the probability sum of SOFTMAX, and the reciprocal of NORMALIZE. Because these steps always run in lane order, every result equals a serial evaluation in lane order. The unit is deterministic, and a model of it does not depend on the number of lanes.

Table 5. Operations of the vector unit, per lane. x and y are FP32 operands, σ is the command's FP32 SCALAR, and masked lanes give 0.
OpNameResult
0–2ADD, SUB, MULx + y, x − y, x · y
3SCALEx · σ
4AXPYRNE(RNE(x · σ) + y)
5, 6MAX, SUMx; the reduction over the masked lanes goes to a register
7, 8EXP2, RECIP2x, 1/x, approximate
9SOFTMAXpj of Eq. (7); m, l and α go to registers
10NORMALIZEx · (1/σ), or 0 if σ = 0
11–13RSQRT, SILU, ABS1/√x, x / (1 + e−x), |x|
14QUANTrows of NVFP4 blocks, Eq. (8) (§6.4)

6.2Streaming commands

One command processes a whole vector. The host or the kernel engine writes the command as one 32-byte beat to offsets 0x20–0x3C: the scratch addresses X, Y and D, the number of 8-element groups and a lane mask, the scalar, the running softmax state, and the opcode. The last word starts the command (Appendix Table A3). The unit then streams: group g reads its operands from X + 32g (and Y + 32g), and its eight results go to D + 32g. While the lanes work on one group, the port fetches the next one. For MAX and SUM, the combining ALU folds the group reductions left to right into the REDUCTION register. The unit rejects a command with a misaligned or out-of-range address, zero groups, or SOFTMAX on more than one group, and sets a status bit. A 1,024-element SiLU, for example, is one command of 128 groups.

scratch memory vector port 1 beat per cycle X, Y operands of group g x₀ y₀ x₁ y₁ x₂ y₂ x₃ y₃ x₄ y₄ x₅ y₅ x₆ y₆ x₇ y₇ lane 0ALU lane 1ALU lane 2ALU lane 3ALU lane 4ALU lane 5ALU lane 6ALU lane 7ALU r₀ r₁ r₂ r₃ r₄ r₅ r₆ r₇ D + 32g combining ALU, lanes 0 → 7 reductions · softmax m, α, l · 1 / scalar result registers REDUCTION MAX SUM ALPHA command beat X, Y, D addresses GROUPS, MASK SCALAR OLD_MAX, OLD_SUM CTRL: opcode, start 0x20–0x3C QUANT max |x| scan, 16 cycles UE4M3 scale, thresholds E2M1 codes, 8 per cycle codes → D + 128r + 8b, scales → Y + 16r (tensor-core layout)
Figure 10. The vector unit. Each group of 8 FP32 elements arrives from the scratch memory in one beat, passes through the eight lanes, and returns in one beat. The command sets the operation, the scalar and the mask of all lanes. The combining ALU reads the lane results in order. Dashed: values that it returns to the lanes (the new row maximum for SOFTMAX, the reciprocal for NORMALIZE). QUANT reads the lane results of a block and writes codes and scales in the layout of the tensor core.

6.3Online softmax

Attention gives each query a weighted average of the value vectors Vj. The weights are the softmax of the scores sj: pj = exp(sj − m) / Σk exp(sk − m), where subtracting the maximum score m keeps the exponentials from overflowing. FlashAttention [9] computes this one block of keys at a time, so the full matrix of scores never exists in memory. It keeps three running values per query row: the maximum m, the sum l and the unnormalized output O. When a later block raises the maximum, a factor α corrects the earlier sum and output [14]. With λ = log2(e)/√d for heads of width d, one key block updates a row as

mnew=max(mold,maxjsj), α=2(mold−mnew)λ,pj=2(sj−mnew)λ, lnew=αlold+∑jpj,Onew=αOold+∑jpjVj, (7)

and the output is O/l after the last block. Masked keys, used for causal attention, get pj = 0; α = 0 while lold = 0. A SOFTMAX command computes mnew, α, pj and lnew for one row of eight scores, and the tensor core computes ΣpjVj. AXPY then updates O, and NORMALIZE divides by l at the end. The state stays in FP32 between blocks. Against an ordered CUDA reference on the RTX 5090, tiled attention on the vector unit differs by at most 2.4 × 10−7.

6.4NVFP4 quantization

Before each matrix product, the activations, which the vector unit holds in FP32, must become NVFP4. QUANT does this on the device. For each block of 16 elements xi and the inverse tensor scale v, it computes the block scale s and the element codes qi as

s=RNEUE4M3(RNE(RNE(maxi|xi|⋅v)⋅RNE(1/6))), qi=RNEE2M1(RNE(xi⋅v)/s), (8)

where RNEE2M1 saturates at ±6. Dividing by 6 maps the largest element of a block to the largest E2M1 value. Algorithm 2 gives the steps. The lanes compute every scaled element RNE(xi · v) in two passes of eight. Meanwhile, a scan finds the element of largest magnitude. Rounding is symmetric and never reverses an order, so the scaled value of that element already equals RNE(max |xi| · v), and the scale needs no extra multiply. The codes of a row go to D + 128r + 8b, and its scale bytes to Y + 16r. These are the row layouts of the tensor core's tile memory (Appendix Table A2), so one COPY moves the result into the tensor core. A block takes about 38 cycles. QUANT rejects a block with a NaN or infinite element, or one whose scaled maximum overflows.

Algorithm 2. QUANT of block b of row r. Comments give the hardware that does each step.
  1. input: x0 … x15 from X; the inverse tensor scale v = SCALAR
  2. for i ← 0 to 15 do pi ← RNE(xi · v) ▷ 8 lanes, 2 passes
  3. k ← index of the largest |xi|; subnormal xi count as 0 ▷ 16-cycle scan, during line 2
  4. if some xi is not finite, or pk = ±∞ then reject ▷ status bit
  5. s ← RNEUE4M3(RNE(|pk| · RNE(1/6))) ▷ 1 lane pass, scale encoder
  6. t0 … t6 ← s × the midpoints between E2M1 magnitudes ▷ exact, 1 cycle
  7. for i ← 0 to 15 do qi ← code of |pi| against t, ties to even, with the sign of pi ▷ 8 per cycle
  8. write q to D + 128r + 8b and s to byte b of Y + 16r ▷ vector port

7Kernel engine and transformer layer

The kernel engine is a small processor that sequences the other devices. With it, a whole transformer layer runs on the FPGA from one uploaded program, and the host only loads the inputs and reads the results.

7.1Kernel engine

The kernel engine, kernel_engine at 0x1002_0000, executes a program of up to 8,192 64-bit instructions with 16 integer registers (Appendix Table A4). It fetches and executes an instruction in two cycles, plus the bus time of the instruction. Most instructions are ordinary integer arithmetic and branches. Four of them use the bus, on which the engine is a second master next to the host. LOAD and STORE move one word. COPY moves n words: each step reads up to eight words in one beat and writes them in one beat, and it rotates the words when the source and destination have different offsets within a beat. WAIT reads a status word until its busy bits clear, and it stops the program with a fault if an error bit is set.

A program starts a vector command with one COPY of the command beat from scratch memory to the vector unit, and then WAITs for it. The compiler prepares every command beat in scratch memory in advance. When a word of the command depends on an earlier result, such as the normalization factor of RMSNorm or the running softmax state, a one-word COPY patches that word first. A program starts the tensor core in the same way: COPYs move the operand rows into the tile memory, register writes set the format and the dimensions and start it, a WAIT polls its status, and a loop of COPYs moves C out.

7.2The transformer layer

The layer is a pre-norm transformer block [15]: h = x + Attention(RMSNorm(x)) and y = h + FFN(RMSNorm(h)). RMSNorm [12] divides each row by the root of its mean square and multiplies it by a learned γ. The feed-forward network is SwiGLU [13]: FFN(n) = Wdown(SiLU(Wgaten) ⊙ Wupn). The shape is fixed: 16 tokens, width 32, one attention head of width 32, and a feed-forward width of 64. Attention is causal or dense. Figure 11 shows the dataflow.

The host quantizes the weights to NVFP4 once. The device quantizes every activation with QUANT before it enters a matrix product. Activations and weights use the tensor scale 1/64, and softmax probabilities use 1/2688. These are fixed calibration constants, not values measured at run time. After each product, a SCALE command multiplies C by the product of the two tensor scales. Attention processes the queries in pairs, the 2 rows of the grid, and the keys in tiles of 8. For each pair and tile, the tensor core computes the scores S = Q KT (2 × 8 × 32), SOFTMAX updates the state of both rows, QUANT converts the probabilities, and the tensor core computes P V with K = 32. V is transposed and padded so that its 8 keys form the first 8 elements of each column.

The compiler, host/transformer.py, unrolls all loops over rows and query pairs, so every address and every causal mask is a constant. The program has 4,071 instructions and uses 108,896 bytes of scratch memory for inputs, weights, intermediate results and 371 command beats. It runs 39 matrix products and 371 vector commands, of which 24 are QUANT. An independent model in Python, host/transformer_model.py, computes the same layer with the same quantization and the same FP32 operation order.

tensor core vector unit Every arrow passes through scratch memory. The kernel engine copies the operands and starts each unit. input x16 × 32 FP32 RMSNorm16 rows QUANT16 rows × 2 blocks Q, K, V3 × (16 × 32 × 32) QUANT Q, K, VᵀVᵀ per key tile attention: for each of 8 query-row pairs, for each of 2 key tiles of 8 keys S = Q Kᵀ2 × 8 × 32 SOFTMAXonline m, l, α QUANT P2 rows P V2 × 32 × 32 O ← αO + P VAXPY O ← O / lafter the last tile next key tile QUANTattention output output proj.16 × 32 × 32 h = x + …residual RMSNorm16 rows QUANT16 rows × 2 blocks gate, up2 × (16 × 64 × 32) SiLU(gate) · up16 × 64 QUANT16 rows × 4 blocks down16 × 32 × 64 h + …residual output16 × 32 FP32
Figure 11. Dataflow of the transformer layer. Green: matrix products on the tensor core, with their size M × N × K. Grey: vector-unit commands. The attention loop (frame) runs 16 times. Each matrix product is followed by a SCALE command that applies the tensor scales (not drawn).

7.3Results and where the time goes

The layer runs on the board with the outputs that the reference predicts (Table 6). The final outputs equal the reference bit for bit on both inputs. The intermediate RMSNorm results differ from the reference by at most 4.8 × 10−7, and those of attention and SwiGLU by at most 6.0 × 10−8, because the reference rounds 2x, 1/√x and SiLU to nearest, while the device approximates them. The final quantization absorbs these small differences on both inputs. This is an observation, not a guarantee for every input.

Table 6. The transformer layer on the board at 50 MHz. Times exclude the upload of the program and inputs and the readback of the results.
InputAttentionCyclesTimeFinal max. error
seed 3causal139,2442.785 ms0
seed 11dense140,9242.818 ms0

The tensor core computes for only 2,592 of these cycles (Figure 12). The layer is small: its 39 matrix products are short, and most of them have M = 2 or K = 32, which pay the load and drain cost of Eq. (6) for few issue cycles. The time goes to the vector unit (45%), to the copies of operands and results between scratch memory and the tile memory (23%), to instruction issue (9%), and to other bus transfers and waits (23%). The kernel engine waits for each command before it issues the next, so the units do not overlap. §10 discusses this.

Layer, seed 3, causal: 139,368 cycles in UART RTL simulation 45% 23% 9% 23% waiting for the vector unit: 63,162 of which QUANT: 15,951 copies to and from the tensor core: 31,882 instruction fetch and execute: 11,992 other bus transfers and tensor-core waits: 32,332 tensor core computing: 2,592 cycles (1.9%) 0 20,000 40,000 60,000 80,000 100,000 120,000 140,000 cycles
Figure 12. Where the cycles of the layer go, to scale, counted per instruction in a cycle-accurate simulation of the SoC with its UART link (139,368 cycles; 139,244 on the board). Hatched: the part of the vector-unit time spent in QUANT.

8Verification methodology

Every level of the design, from the numerical model to the programmed board, is compared with GPU silicon or with a model that silicon has confirmed.

Reference chain. Silicon is the reference, and two models stand in for it where silicon cannot be run. The silicon harness places each 64-element test vector in every row of A and every column of B of one block-scaled mma.sync…m16n8k64 on the RTX 5090, and all 128 outputs must agree. The fragment layout follows CUTLASS 4.6.1 [7] (MMA_Traits<SM120_16x8x64_TN_VS>), and 4,228 probes confirmed it before any test vector ran. For K > 64, we compare an output with a chain of MMAs, each of which takes the previous GPU result as c. The two models are rule rtx5090 of §4, written in floating-point Python, and nvfp4_model, an independent integer model of Eqs. (1)–(3) that the grid and system tests use.

Stimuli. PE vectors include uniform codes, runs of ±6 that cancel, zero and constant vectors, and every finite scale code. The scale codes include subnormals and 0x79–0x7E, which are finite on silicon but NaN in one public reference model. They also include NaN scales. The accumulator c is drawn from zeros of both signs, uniform values, exponents from 2−30 to 230, and special values. System runs mix full and partial tiles, all formats, overwrite, accumulation, and continuation from the previous C. The DSP grid is tested as a 2 × 2 block whose rows are (a, b) and columns (b, a) of each vector, so its four fields carry a·b, a·a, b·b and b·a. Vectors with all elements +6 against all −6 drive the fields to both ends of [224, 800].

Vector unit and layer. A CUDA program runs the same FP32 operations on the RTX 5090 with the .ftz PTX instructions and with fused multiply-add disabled. Exact operations must agree bit for bit, and approximate ones within fixed ULP bounds. QUANT is compared with the GPU's native conversions to E4M3 and E2M1, and with the Python quantizer for whole rows. The kernel engine has directed tests for every instruction, for COPY between all word offsets, and for each fault. The layer runs on the cycle-accurate simulation of the SoC and on the board, and is compared with the independent reference of §7.2.

Levels. Table 7 lists the levels from the arithmetic model to the board. Three of the 420,025 PE vectors differ from silicon, and all three are instances of the model gaps of §4. For comparison, the open-source Allegro unit [5] differed from the RTX 5090 on 651 of 100,009 NVFP4 vectors (0.65%). Most of those differences came from all-zero products and a small c.

Table 7. Verification levels and results. “Model” is nvfp4_model unless stated otherwise. A count is the number of outputs that agree bit for bit; NaNs compare equal regardless of payload.
LevelDevice under testReferenceAgree / total
Modelrule rtx5090RTX 5090 and Jetson Thor, random vectors600,005 / 600,054
Modelnvfp4_modelrule rtx5090420,025 / 420,025
PEfp4_fedp, Verilatorrule rtx5090420,025 / 420,025
PEfp4_fedp, VerilatorRTX 5090: NVFP4; MXFP4-16; MXFP4 vectors300,025 / 300,025; 13,359 / 13,359; 6,640 / 6,641
PEfp4_fedp, VerilatorRTX 5090, new random vectors, 4 modes99,998 / 100,000
PEfp4_fedp_dsp 2 × 2, Verilatorrule rtx5090, 4 outputs per vector1,680,136 / 1,680,136
PEfp4_fedp_dsp 2 × 2, VerilatorRTX 5090, output a·b, stored and random vectors420,022 / 420,025
Gridnvfp4_tc, direct MMIO, 18 runsmodel6,016 / 6,016
SystemSoC through PyUARTSI, Verilatormodel18,824 / 18,824
SystemSoC through PyUARTSI, VerilatorRTX 5090 MMA chains14,880 / 14,880
VectorFP32 ALU primitivesRTX 5090 PTX, 20,416 recordsADD, MUL, MAX exact; EXP2 ≤ 2, RECIP ≤ 1 ULP
VectorRSQRT, SILU commandsRTX 5090 PTX≤ 2 ULP, ≤ 3 ULP
Vectortiled attention, dense and causalordered CUDA referencemax. error 2.4 × 10−7
VectorQUANTRTX 5090 E4M3 and E2M1 conversion205 / 205 blocks
BoardFPGA, 30 runs, 12.6 M MACsmodel and RTX 5090 MMA chains60,416 / 60,416
Boardtransformer layer, 2 inputsquantized reference, §7.2final error 0

9Implementation

We implement the design with Vivado 2024.2 at 50 MHz (Table 8). The SoC uses 88% of the LUTs, 60% of the block RAM and 82% of the DSP slices, and it meets timing with 1.390 ns of slack. The vector unit is the largest block: its nine FP32 ALUs, the QUANT encoders and the staging registers take 25,803 LUTs. The tensor core takes 21,909 LUTs and 160 DSP slices. Most of its logic is in stages 2–5 of the PEs, about 2,400 LUTs per output: alignment takes about 1,100 of them and the cut to FP32 about 700. The field registers of §5.3 add 2,560 flip-flops.

The critical path, 18.5 ns over 11 logic levels, runs from a B RAM output through the operand decode and a slice pair to the field register (Figure 7). QUANT's path from a lane result through the scale encoder has 1.46 ns of slack. With the products in LUTs, the tensor core used 31,496 LUTs, and its worst path, through the products and the adder tree, had 0.3 ns of slack. The serial link dominates end-to-end time: loading A and B and reading C for a full tile takes about 0.6 s, against 51.2 µs of compute.

Table 8. Resources and timing on the Artix-7 xc7a100t at 50 MHz. The first group is out of context. The second is the release build, by unit. The last row is the tensor core with LUT products (DSP = 0), from a build with a 32-bit bus.
ComponentLUTFFBlock RAMDSPWNS (ns)
One PE, LUT products (fp4_fedp)4,08454804+7.846
2 × 4 PEs, DSP products (fp4_fedp_dsp)21,6256,9170160+7.846
Tensor core (nvfp4_tc)21,9097,69262 RAMB18160–
Vector unit (flash_vector)25,8039,2601 RAMB36 + 9 RAMB1836–
Kernel engine5,5141,15613 RAMB360–
Scratch memory4332 RAMB360–
Bus, UART TSI, system registers, clock2,4942,21400–
SoC, all units55,724 (88%)20,325 (16%)46 RAMB36 + 71 RAMB18 (60%)196 (82%)+1.390
Tensor core, LUT products31,4964,61062 RAMB1832–

10Limitations

Scope. The transformer layer has a fixed shape, one attention head, and tensor scales that are fixed constants rather than measured at run time. It has no positional encoding, no key-value cache and no backward pass. The compiler can add these without a change to the hardware or to the upload protocol.

Arithmetic. Only the matrix products are bit-exact with the GPU. The vector unit's EXP2, RECIP, RSQRT and SILU are within a few ULP of the GPU's instructions, but not bit-equal to them, and production attention kernels may also use fused multiply-add and other reduction orders. The contract of §4 still misses 49 of 600,054 random vectors, and the hardware inherits these differences. We compared the contract with an RTX 5090 and a Jetson AGX Thor; B200 and B300 silicon is untested.

Speed. The kernel engine waits for each command to finish before it issues the next one, so the tensor core, the vector unit and the copies never overlap. Because the vector unit has its own scratch port, a compiler could run vector commands during the tensor-core copies, which together take 68% of the layer. The host link runs at 921,600 Bd and limits every transfer between the host and the board. The FPGA is 88% full, so a larger tensor core needs a larger device.

References

  1. NVIDIA. Parallel Thread Execution ISA: warp-level mma with block scaling; ex2.approx and rcp.approx. docs.nvidia.com/cuda/parallel-thread-execution
  2. Open Compute Project. OCP Microscaling Formats (MX) Specification, version 1.0, 2023. opencompute.org
  3. NVIDIA. Transformer Engine documentation: NVFP4. docs.nvidia.com/deeplearning/transformer-engine
  4. sashakatne. nvfp4-dotprod-formal-dv, commit 125db59. github.com/sashakatne/nvfp4-dotprod-formal-dv
  5. roundandr. Allegro, commit ac5b2a4, with its MMA-Sim reference model. github.com/roundandr/Allegro
  6. UC Berkeley Architecture Research. PyUARTSI and the UART TSI specification. github.com/ucb-bar/pyuartsi
  7. NVIDIA. CUTLASS 4.6.1, MMA_Traits<SM120_16x8x64_TN_VS>. github.com/NVIDIA/cutlass
  8. SiFive. TileLink Specification, TL-UL conformance level.
  9. T. Dao. FlashAttention-2: faster attention with better parallelism and work partitioning. 2023. arXiv:2307.08691
  10. AMD. 7 Series DSP48E1 Slice User Guide (UG479) and 7 Series FPGAs Data Sheet: Overview (DS180).
  11. IEEE. IEEE Standard for Floating-Point Arithmetic, IEEE 754-2019.
  12. B. Zhang and R. Sennrich. Root mean square layer normalization. NeurIPS 2019. arXiv:1910.07467
  13. N. Shazeer. GLU variants improve Transformer. 2020. arXiv:2002.05202
  14. M. Milakov and N. Gimelshein. Online normalizer calculation for softmax. 2018. arXiv:1805.02867
  15. A. Vaswani et al. Attention is all you need. NeurIPS 2017. arXiv:1706.03762

ARegister and memory maps

All devices take whole 32-bit words and deny a partial write. Addresses of words are multiples of 4.

Table A1. Memory map of the SoC.
BaseSizeDeviceBus port
0x0000_00004 KiBsys_regs: link identification and statuswords
0x1000_000064 KiBnvfp4_tc: tensor core and its tile memory (Table A2)beats
0x1001_000064 KiBflash_vector: vector unit (Table A3)words, and its own scratch port
0x1002_0000128 KiBkernel_engine: kernel engine (Table A4)words; also a bus master
0x2000_0000128 KiBscratch_memorybeats

In the tensor core, offsets are relative to 0x1000_0000. In A and B, element k of a row or column is nibble k, low nibble first.

Table A2. Registers and memory regions of the tensor core, nvfp4_tc.
OffsetNameAccessContents
0x0000IDRO0x4E56_5443 ("NVTC")
0x0004TILEROmaximum tile {M[31:24], N[23:16], K[15:0]} = 0x4040_0100
0x0008ARRAYRO{PM, PN} = 0x0204
0x000CCTRLWObit 0 START: C = A × B + C; with bit 1 OVERWRITE: C = A × B
0x0010STATUSRObit 0 busy; bit 1 the last START was rejected
0x0014MODERWTable 2
0x0018DIMSRW{M, N, K} of the next START: M a multiple of 2, N of 4, K of 32
0x001COPSROcompleted STARTs
0x0020CYCLESROcycles of the last START, Eq. (6)
0x0024PKROelements per PE, 64
0x2000ARW64 rows × 128 B
0x4000SFARW64 rows × 16 B; byte g scales elements 16g to 16g + 15
0x6000BRW64 columns × 128 B
0x8000SFBRW64 columns × 16 B
0xC000CRW64 × 64 FP32, row-major; C[i][j] at 0xC000 + 256i + 4j
Table A3. Registers of the vector unit, flash_vector, relative to 0x1001_0000. Offsets 0x20–0x3C are one 32-byte command beat; the write of CTRL with bit 0 set starts the command. Writes wait while a command runs; reads do not.
OffsetNameAccessContents
0x00IDRO0x4656_4543 ("FVEC")
0x04LANESRO8
0x08STATUSRObit 0 busy; bit 1 the last command was rejected
0x10–0x1CREDUCTION, MAX, SUM, ALPHAROreduction over all groups; m, l and α of the last group
0x20–0x28X, Y, DRWscratch addresses, 32-byte aligned
0x2CGROUPSRWgroups [15:0], MASK [23:16]; QUANT: rows, blocks per row
0x30SCALARRWFP32 σ; QUANT: inverse tensor scale v
0x34, 0x38OLD_MAX, OLD_SUMRWsoftmax state mold, lold
0x3CCTRLRWbit 0 start; opcode [7:4] (Table 5)
Table A4. Registers and instructions of the kernel engine, relative to 0x1002_0000. An instruction is opcode [63:56], rd [55:52], rs1 [51:48], rs2 [47:44] and a 32-bit immediate [31:0]. Register and program writes are denied while a program runs.
Offset or opcodeNameContents or operation
0x00, 0x04ID, CAPACITY0x4B45_524E ("KERN"); 8,192 instructions
0x08STATUSbit 0 busy, bit 1 fault, bit 2 halted
0x0C, 0x10, 0x14START, ENTRY, LENGTHbit 0 starts the program; first instruction; program length
0x18, 0x1C, 0x20CYCLES, PC, FAULTcycles of the last run; program counter; fault code: 1 unknown opcode, 2 PC outside the program, 3 denied access, 4 WAIT error
0x100, 0x1000REGS, PROGRAM16 integer registers; 8,192 64-bit instructions, write only
0, 1, 2, 3HALT, MOVI, ADDI, ADDstop; rd ← imm; rd ← rs1 + imm; rd ← rs1 + rs2
4, 5LOAD, STORErd ← word at rs1 + imm; word at rs1 + imm ← rs2
6, 7JMP, JNZpc ← imm; pc ← imm if rs1 ≠ 0
8, 9COPY, FILLcopy imm words from rs1 to rs2; write imm words of value rs2 from rs1. Up to 8 words per step
10WAITread the word at rs1 until (word & imm[15:0]) = 0; fault if (word & imm[31:16]) ≠ 0
11, 12, 13SHL, SHR, ANDrd ← rs1 << imm[4:0]; rd ← rs1 >> imm[4:0]; rd ← rs1 & imm
14, 15SHL_REG, SLTUrd ← rs1 << rs2[4:0]; rd ← 1 if rs1 < rs2 (unsigned), else 0