LLM Inference on FPGA with High-Level Synthesis

LLM Inference on FPGA with High-Level Synthesis

FPGA LLM inference requires algorithm/hardware co-design across quantization, memory bandwidth, pipelining, on-chip buffers and KV cache.

Moving a Transformer to an FPGA is not equivalent to translating a CUDA kernel into HDL. Model representation, memory traffic and pipeline structure all affect the synthesized hardware.

The bottleneck is not always MAC count

Transformer layers contain large matrix multiplications, but inference can be memory-bandwidth bound. If weights are fetched repeatedly from external memory, additional multipliers may remain idle.

Arithmetic intensity relates useful computation to bytes transferred across the chosen memory boundary. Keeping a tile on chip can reduce repeated external reads, but the tile competes with activations, accumulators and control structures for local storage. A compute-only estimate omits stalls caused by bandwidth, bank conflicts and data movement.

What HLS contributes

High-Level Synthesis speeds up architectural exploration by translating C/C++-like descriptions into RTL. It does not remove hardware design: loop structure, pipelining, array partitioning and memory interfaces still determine performance and resource use.

Quantization changes the architecture

Lower precision changes DSP use, bandwidth, buffer capacity, accumulator width and achievable parallelism. Quantization is therefore part of hardware architecture, not merely a model-compression switch.

Weight precision, activation precision and accumulator width are separate choices. Overflow, clipping and rounding rules must be evaluated against the numerical reference. Lower bit width can improve packing while changing model quality; hardware savings are meaningful only when the deployed representation meets the task's acceptance criteria.

Latency and throughput are different

A deep pipeline can have significant first-result latency while accepting new work at a high rate:

latency ≠ throughput

The correct optimization depends on whether the workload is streaming, batch or interactive.

Prefill and autoregressive decoding impose different workload shapes. Time to first token, time per subsequent token, total completion time and batch throughput should be measured separately. A design optimized for a long prompt may not provide the same advantage in single-token decoding.

KV cache is another memory problem

Autoregressive inference keeps previous key/value state. As context grows, KV cache can dominate capacity and traffic. The design must decide what stays on-chip and what moves through external memory.

Deterministic hardware has value

A synthesized pipeline can provide predictable timing and resource ownership, although host scheduling, PCIe and external DRAM still contribute to end-to-end variation.

HLS is a design-space problem

Unroll factor, initiation interval, quantization width and memory partitioning interact. More parallelism can exceed DSP or routing capacity; more buffering can reduce DRAM traffic while consuming BRAM/URAM.

A requested initiation interval is a scheduling goal, not proof of achieved board-level throughput. Dependencies and memory ports can prevent the compiler from reaching it. Post-synthesis resource estimates must be followed by implementation and timing results; routing congestion and clock frequency can change the tradeoff.

FPGA versus GPU

FPGA is not a universal GPU replacement. It is attractive when customized dataflow, unusual precision, energy constraints or deterministic pipelines justify the engineering cost.

Recent work such as HLSTransform reinforces the same direction: efficient FPGA inference increasingly depends on algorithm/hardware co-design.

A fair comparison fixes model quality, context length, batch size, input/output boundary and power-measurement scope. Host preprocessing, transfers and output handling belong in an end-to-end comparison. Kernel-only numbers and board-level energy should not be mixed with complete-system figures. Published experimental results remain specific to their model, hardware and measurement conditions.

References

Inference Engineering Context

A successful FPGA deployment is not defined only by producing a synthesizable HLS design. Inference engineering treats the path from preprocessing to final output as one system; data movement, pipeline occupancy, quantization, memory bandwidth and the real request distribution all contribute to latency.

Kernel throughput or single-sample latency alone is therefore incomplete. Hardware gain, model accuracy and system capacity need to be evaluated within the same measurement boundary.

QR code for this page