Inferensys

Glossary

hls4ml

An open-source Python package that translates traditional machine learning models into High-Level Synthesis (HLS) projects for ultra-low latency FPGA inference, commonly used in particle physics and real-time RF applications.
ML engineer managing model training cluster on laptop, GPU utilization visible, technical deep learning setup.
HIGH-LEVEL SYNTHESIS FOR MACHINE LEARNING

What is hls4ml?

An open-source Python package that translates traditional machine learning models into High-Level Synthesis (HLS) projects for ultra-low latency FPGA inference, commonly used in particle physics and real-time RF applications.

hls4ml is an open-source compiler framework that converts pre-trained neural networks from standard libraries like Keras, PyTorch, and ONNX directly into High-Level Synthesis (HLS) firmware descriptions. By generating C++ code optimized for parallel execution, it enables the deployment of complex deep learning models onto Field-Programmable Gate Arrays (FPGAs) with deterministic, microsecond-scale latency, bypassing the overhead of traditional CPU or GPU inference.

The framework applies aggressive model compression techniques, including quantization-aware training and configurable weight pruning, to map floating-point networks onto fixed-point digital logic. It produces a fully self-contained HLS project with AXI-streaming interfaces, enabling seamless integration into larger signal processing pipelines for applications like real-time automatic modulation classification and particle collision triggering.

HARDWARE-AWARE MODEL COMPILATION

Key Features of hls4ml

An open-source Python package that translates traditional machine learning models into High-Level Synthesis (HLS) projects for ultra-low latency FPGA inference, commonly used in particle physics and real-time RF applications.

01

Automated HLS Translation

Converts trained Keras, TensorFlow, PyTorch, and ONNX models directly into synthesizable C++ HLS code. The framework parses the model graph, maps layers to optimized HLS templates, and generates a complete Vivado HLS or Vitis HLS project. This eliminates manual RTL design, reducing FPGA deployment time from months to hours for signal processing engineers.

Months → Hours
Deployment Time Reduction
02

Configurable Precision via Quantization

Supports arbitrary fixed-point precision through ap_fixed types, allowing per-layer bit-width configuration for weights, biases, and activations. Users can specify integer and fractional bits independently, enabling aggressive quantization down to 2-4 bits for modulation classifiers while preserving accuracy. Integrates with Quantization-Aware Training (QAT) workflows to compensate for precision loss.

2-4 bits
Minimum Precision
03

Streaming Dataflow Architecture

Generates deeply pipelined, fully streaming architectures where data flows continuously through the network without off-chip memory access for intermediate activations. Each layer processes samples as they arrive, achieving sub-microsecond latency per inference. This is critical for real-time RF applications like dynamic spectrum awareness and modulation classification on FPGAs.

< 1 µs
Inference Latency
04

Reuse Factor for Resource Scaling

Provides a reuse parameter that controls the trade-off between throughput and resource utilization. A reuse factor of 1 implements fully parallel hardware, maximizing throughput at the cost of DSP slices and LUTs. Higher reuse factors serialize computation, sharing a single multiplier across multiple operations to fit larger models onto smaller FPGA fabrics.

1-1024
Reuse Factor Range
05

Vivado and Vitis Backend Support

Targets both Xilinx Vivado HLS (legacy) and Vitis HLS (modern) toolchains. The generated C++ is synthesizable directly into FPGA bitstreams for Zynq, Kintex, Virtex, and Alveo platforms. Includes integration with the PYNQ framework for rapid prototyping on Python-enabled SoCs, enabling over-the-air testing of compressed modulation classifiers.

Zynq, Kintex, Virtex, Alveo
Supported Platforms
06

Layer-Specific Optimization Templates

Implements hand-optimized HLS templates for common neural network layers:

  • Convolutional: Im2col with line-buffer caching for spatial locality
  • Fully Connected: Tiled matrix-vector multiplication with weight streaming
  • Batch Normalization: Mathematically folded into preceding layers
  • Activation: Piecewise linear approximations for tanh, sigmoid, and ReLU variants These templates exploit FPGA parallelism efficiently.
HLS4ML FOR RF INFERENCE

Frequently Asked Questions

Addressing the most common technical questions about translating machine learning models for automatic modulation classification into high-performance FPGA firmware using the hls4ml workflow.

hls4ml is an open-source Python package that translates pre-trained machine learning models directly into High-Level Synthesis (HLS) projects, generating register-transfer level (RTL) code for ultra-low latency FPGA inference. For automatic modulation classification, it converts a TensorFlow or PyTorch classifier into a fully pipelined hardware dataflow, bypassing the need for manual VHDL or Verilog coding. The workflow parses the model graph, applies hardware-aware optimizations like operator fusion and batch normalization folding, and generates C++ synthesis directives. This allows an IQ sample stream to be classified with deterministic, single-digit microsecond latency, making it ideal for real-time spectrum awareness and cognitive radio front-ends where GPU batching is infeasible.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.