AI and machine learning on FPGA
How neural networks run on FPGAs, the difference between dataflow and overlay accelerators, the main vendor and open-source flows, and when an FPGA beats a GPU or NPU.
Overview
An FPGA runs a neural network the same way it runs anything else: as fixed arithmetic fed by a fixed memory schedule. That makes it a poor fit for training, where the workload changes every few weeks, and a good fit for inference at the edge, where one model runs for years, the input is a sensor stream, and latency, power or determinism matter more than peak throughput. This hub is for engineers deciding whether a model belongs on an FPGA at all, and if so which of the two very different ways of building the accelerator to use.
The honest summary at the time of writing: for large language models and anything else dominated by dense matrix multiplication at batch size, GPUs and dedicated NPUs win on throughput per watt and on software maturity. FPGAs win on small, latency-bound models with odd data types, on models fused directly into a sensor or network pipeline, and on anything that must run on a device already chosen for other reasons.
Key ideas
Quantisation is the whole game
Floating point costs an FPGA dearly. A 32-bit multiply-add needs a DSP slice plus a lot of logic, while an 8-bit multiply can be packed two per DSP on most families and a 2-bit or binary network needs no DSP at all, only LUTs. Quantisation is therefore the first design step, not an optimisation. INT8 with per-channel scaling loses under one percent accuracy on most convolutional networks. Below 8 bits you need quantisation-aware training, which the FINN and hls4ml flows support through Brevitas and QKeras. The reward is proportional: halving the bit width roughly doubles the compute you can fit and halves the memory bandwidth, which is usually the real limit.
Dataflow versus overlay
There are two architectures, and they suit different problems.
A dataflow accelerator compiles the network into hardware. Every layer becomes its own block, sized to the layer’s compute, connected by FIFOs, all layers running at once. hls4ml and FINN build these. Latency is microseconds or below, throughput is fixed at design time, and the whole model’s weights usually live on chip. The cost is that one bitstream serves one model, and the model has to fit. This is the right shape for trigger-level physics, anomaly detection on a link, keyword spotting and small classifiers.
An overlay accelerator is a fixed processor-like engine (a systolic array or vector unit with its own instruction stream) that the tools program per model. AMD’s DPU under Vitis AI, the Altera FPGA AI Suite, Microchip VectorBlox and the Lattice sensAI CNN accelerator are all overlays. Any supported model runs without rebuilding the bitstream, weights stream from DDR, and the compiler handles scheduling. The cost is a fixed architecture that cannot exploit sparsity or unusual layer types and spends energy moving data through a general datapath. This is the right shape for camera analytics, where models change and resolution is high.
When the FPGA wins, and when it does not
An FPGA is the better choice when the model is small enough for dataflow and latency is the specification, when the network sits inside a data path that is already in the FPGA (a radar receiver, a camera ISP, a packet classifier), when the data type is unusual (4-bit, ternary, custom activations) or when the product needs a 10 to 15 year supply life. It is the wrong choice when the model is a transformer with billions of parameters, when the team has no hardware engineers, when the model will change monthly, or when a 10 USD NPU-equipped microcontroller meets the target. Power comparisons are often quoted at the vendor’s favourite operating point, so measure your own model on a development board before committing.
Where to start
The arithmetic underneath every accelerator is a multiply-accumulate in a pipeline, so start with /learn/beginner/03-combinational-logic-and-luts/ and /learn/beginner/04-registers-clocks-and-state/, then /learn/beginner/09-memories-block-ram-and-fifos/ for the weight and activation storage. The /topics/dsp/ hub covers fixed-point arithmetic, which is the same skill. For a first accelerator, run the hls4ml tutorial on a small Keras model and look at the generated HLS, or run a Vitis AI example on a Kria KV260. An intermediate track on HLS and accelerators is coming.
Tools and vendors
| Flow | Type | Owner | Targets | Notes |
|---|---|---|---|---|
| hls4ml | Dataflow, HLS | Fast Machine Learning community (open source) | AMD, Altera, Catapult | Keras, PyTorch, ONNX in. Best for small MLPs and CNNs |
| FINN | Dataflow, RTL/HLS | AMD research (open source) | AMD | Brevitas quantised models, down to 1 bit |
| Vitis AI with DPU | Overlay | AMD | Zynq UltraScale+, Versal, Alveo | Largest model zoo, INT8 |
| FPGA AI Suite | Overlay | Altera | Agilex, Arria 10, Cyclone 10 GX | OpenVINO front end |
| VectorBlox | Overlay | Microchip | PolarFire, PolarFire SoC | Open SDK, aimed at low power |
| sensAI | Overlay and compiled | Lattice | iCE40 UltraPlus, CrossLink-NX, Certus-NX | Milliwatt-class always-on tasks |
| Efinity with TinyML | Compiled, RISC-V plus accelerators | Efinix | Trion, Titanium | TensorFlow Lite micro based |
Achronix sells Speedster7t parts with machine-learning processor blocks aimed at the data centre, covered on /topics/data-centre-and-acceleration/.
Common mistakes
- Starting from a floating-point model and hoping the tools will sort out precision. Quantise first, then measure accuracy, then build.
- Comparing TOPS figures. Vendor peak TOPS assume every MAC busy every cycle, which no real model achieves. Compare measured frames per second at your resolution.
- Putting a dataflow design on a device without checking that the weights fit on chip.
- Ignoring the pre- and post-processing. Resizing, normalisation and non-maximum suppression often take longer than the network when left on a soft processor.
- Treating the accelerator as the product. Software integration, model updates and tooling licences dominate the lifetime cost.
Going deeper
- hls4ml documentation, including the tutorial repository.
- FINN documentation and the original paper, Umuroglu et al., FINN: A Framework for Fast, Scalable Binarized Neural Network Inference, 2016.
- Duarte et al., Fast inference of deep neural networks in FPGAs for particle physics, 2018, the paper behind hls4ml.
- Vitis AI on GitHub, with the model zoo and DPU documentation.
- VectorBlox SDK on GitHub.
- Lattice sensAI, the landing page for the low-power stack.