Repolode
fastmachinelearning

fastmachinelearning/hls4ml

A Python package that converts Keras, PyTorch and ONNX neural networks into HLS code for running ML inference on FPGAs.

Stars
2,201
Forks
615
Open issues
62
Last commit
3 days ago

What is it?

hls4ml creates FPGA firmware for machine learning models by translating them into high-level synthesis (HLS) code. Users start from a trained model in a common framework, generate an HLS project with a configuration file, and then build it with a supported vendor toolchain to produce hardware.

The project is aimed at ultra-low-latency inference. Its roots are in high-energy physics, including L1 trigger systems at the Large Hadron Collider, and it is also used in areas such as quantum computing control, fusion feedback loops, satellite environmental monitoring and biomedical signal processing.

Besides Vivado HLS, the package supports Vitis HLS, Intel HLS, Catapult HLS and Altera HLS IP Gen as build backends. It can be installed from PyPI or conda-forge, with an optional extra for profiling.

Key features

  • 01Converts Keras, PyTorch and ONNX models into HLS projects.
  • 02Supports multiple HLS backends including Vivado, Vitis, Intel, Catapult and Altera.
  • 03Lets users configure the generated design through a configuration file.
  • 04Provides a build step that synthesizes the project and a report reader for results.
  • 05Installable via pip or conda-forge.

Use cases

  • Deploying a neural network for real-time trigger decisions on FPGA hardware.
  • Running low-latency control or signal-processing models on embedded FPGA boards.
  • Evaluating how a trained model maps onto FPGA resources before committing to a design.

Quick start

  1. 1

    Install hls4ml from PyPI

    pip install hls4ml
  2. 2

    Fetch an example Keras model and its configuration

    import hls4ml
  3. 3

    Convert the model into an HLS project

    hls_model = hls4ml.converters.keras_v2_to_hls(config)
  4. 4

    Build the project with Vivado HLS or another supported HLS tool

    hls_model.build()

Things to know

  • Building the generated firmware requires a separate HLS toolchain such as Vivado HLS, Vitis HLS, or Intel HLS.
  • Targets FPGA inference only, not general-purpose model training or execution.

Topics

FAQ

What is hls4ml?
A Python package that converts Keras, PyTorch and ONNX neural networks into HLS code for running ML inference on FPGAs. hls4ml creates FPGA firmware for machine learning models by translating them into high-level synthesis (HLS) code. Users start from a trained model in a common framework, generate an HLS project with a configuration file, and then build it with a supported vendor toolchain to produce hardware.
Is hls4ml free to use? What license does it have?
hls4ml is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is hls4ml still maintained?
Actively maintained. The last commit to hls4ml was on Nov 4, 2026.
What can I use hls4ml for?
Deploying a neural network for real-time trigger decisions on FPGA hardware. Running low-latency control or signal-processing models on embedded FPGA boards. Evaluating how a trained model maps onto FPGA resources before committing to a design.
How do I install hls4ml?
Install hls4ml from PyPI: pip install hls4ml Fetch an example Keras model and its configuration: import hls4ml Convert the model into an HLS project: hls_model = hls4ml.converters.keras_v2_to_hls(config) Build the project with Vivado HLS or another supported HLS tool: hls_model.build()
Where can I get hls4ml?
The source code and installation instructions are on GitHub: https://github.com/fastmachinelearning/hls4ml

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects