Requirements
hls4ml requires Python 3.10 or later and is compatible with Linux and macOS.Windows is not officially supported, but may work using WSL (Windows Subsystem for Linux).
Basic Installation
The simplest way to install hls4ml is using pip:h5py- HDF5 file format supportnumpy- Numerical computingpyyaml- YAML configuration filespydigitalwavetools- Waveform handlingquantizers- Quantization utilities
Development Version
hls4ml evolves rapidly with new features and bug fixes on the development branch:The development version may have experimental features that are not yet stable. Use for testing new functionality or bug fixes not yet in a release.
Optional Dependencies
hls4ml uses optional dependency groups for specific features. Install only what you need:Profiling & Visualization
Profiling & Visualization
Tools for analyzing model weights, activations, and finding optimal precisions:Includes:
matplotlib, pandas, seabornUse case: Generate distribution plots for weights and activations to optimize bit widthsKeras v3 Frontend
Keras v3 Frontend
Support for Keras 3.x (multi-backend Keras):Includes:
keras>=3.10Use case: Convert models trained with Keras 3.x (TensorFlow, JAX, or PyTorch backend)QKeras Quantization
QKeras Quantization
Quantization-aware training with QKeras (Keras v2):Includes:
qkeras, tensorflow>=2.8,<=2.14.1, tensorflow-model-optimization<=0.7.5Use case: Train quantized models with QKeras for better FPGA resource efficiencyHGQ Quantization
HGQ Quantization
Heterogeneous Quantization with gradient-based bit-width optimization:HGQ (Keras v2):Includes: Includes:
hgq>=0.2.3HGQ2 (Keras v3):hgq2>=0.0.1ONNX Frontend
ONNX Frontend
Support for ONNX model format:Includes:
onnx>=1.4Use case: Convert models from PyTorch, TensorFlow, or any framework supporting ONNX exportModel Optimization
Model Optimization
DSP-aware pruning and hyperparameter optimization:Includes:
keras-tuner==1.1.3, ortools==9.4.1874, packagingUse case: Automatically find optimal precision and reuse factor configurationsDistributed Arithmetic
Distributed Arithmetic
Enable distributed arithmetic for efficient computation:Includes:
da4ml>=0.5.2,<0.6Use case: Alternative computation method that can reduce DSP usageSymbolic Regression
Symbolic Regression
Symbolic regression for activation function approximation:Includes:
sympy>=1.13.1Use case: Find mathematical expressions to approximate complex activation functionsQuartus Report Parsing
Quartus Report Parsing
Parse Intel Quartus synthesis reports:Includes:
calmjs-parse, tabulateUse case: Extract resource usage from Quartus reports when using Intel FPGAsInstalling Multiple Options
You can install multiple optional dependencies at once:HLS Tool Installation
To synthesize FPGA designs (not just C simulation), you need vendor HLS tools:- Xilinx/AMD FPGAs
- Intel/Altera FPGAs
- ASICs & Universal
C/C++ Compiler Requirements
For C simulation (runninghls_model.compile() and hls_model.predict()), you need:
Linux
macOS
oneAPI Backend
For oneAPI backend, C/SYCL simulation requires:Verification
Verify your installation:Python Version Support
hls4ml officially supports:- Python 3.10
- Python 3.11
- Python 3.12
- Python 3.13
- Python 3.14
Older Python versions (3.9 and below) are not supported as of hls4ml 1.1.0+.
Virtual Environments
We strongly recommend using virtual environments:Troubleshooting
ImportError: No module named 'tensorflow'
ImportError: No module named 'tensorflow'
TensorFlow is optional - only install if using Keras v2:
ModuleNotFoundError: No module named 'torch'
ModuleNotFoundError: No module named 'torch'
PyTorch is optional - only install if converting PyTorch models:
Version conflicts between Keras v2 and v3
Version conflicts between Keras v2 and v3
Cannot have both installed. Create separate environments:
HLS tools not found during build()
HLS tools not found during build()
Ensure HLS tools are in your PATH:
Compilation errors with ap_types.h on macOS
Compilation errors with ap_types.h on macOS
The system clang may not work with Xilinx headers. Install GCC:
Uninstalling
To remove hls4ml:Next Steps
Quickstart
Build your first FPGA inference model
Tutorials
Hands-on Jupyter notebooks
