hls4ml

fastmachinelearningApache-2.0活跃维护

把 Keras、PyTorch、ONNX 训练好的神经网络模型自动转成 FPGA 可综合的 HLS 代码,方便在硬件上做低延迟推理。

Machine learning on FPGAs using HLS

v1.3.0发布于 2026-03-20 14:59 UTC2,201star616fork同步于 2026-11-10 05:44 UTC

怎么上手

由 README 提炼,执行前请确认
pip install hls4ml
pip install hls4ml[profiling]
硬件要求按 README 说明

README 未说明具体 FPGA 型号或资源要求;综合需本地安装 Xilinx Vivado HLS 或 Vitis HLS 等厂商工具,README 未提及 CPU/GPU 或显存要求。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

把 Keras 等框架的模型转成 HLS 固件,在 FPGA 上做超低延迟推理

把 Keras、PyTorch、ONNX 训练好的神经网络模型自动转成 FPGA 可综合的 HLS 代码,方便在硬件上做低延迟推理。

核心能力

  • 将开源 ML 框架模型转换为可配置的 HLS 工程
  • 支持 Vivado、Vitis、Intel HLS、Catapult 等多种后端
  • 提供示例模型下载与配置打印,快速上手转换
  • 支持 CNN、二值/三值网络、SNN 等模型类型
  • 可读取 Vivado 综合报告查看资源与时序

容易踩的坑

build 前需自行下载安装 Vivado HLS 等厂商综合工具,否则无法综合;示例模型通过 fetch_example_model 联网下载到当前工作目录;综合可能耗时数分钟,需耐心等待。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.3.0
  1. v1.3.0iris 1.3.0最新正式版2026-03-20 · 2026-03-20 14:59 UTC

    The major changes compared to v1.2.0 are:

    The full list of changes is:

  2. v1.2.0hyacinth 1.2.02025-11-03 · 2025-11-03 20:19 UTC
    查看更新说明

    The major changes compared to v1.1.0 are:

    The full list of changes is:

  3. v1.1.0gladiolus 1.1.02025-03-17 · 2025-03-17 16:51 UTC
    查看更新说明

    What's Changed

    The major changes compared to v1.0.0 are:

    The full list of changes is:

  4. v1.0.0foxglove 1.0.02024-12-09 · 2024-12-09 22:47 UTC
    查看更新说明

    What's Changed

    hls4ml v1.0.0 "foxglove" introduces several significant improvements:

    The full list of other improvements and fixes is:

  5. v0.8.1edelweiss 0.8.12023-12-19 · 2023-12-19 21:00 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/fastmachinelearning/hls4ml/compare/v0.8.0...v0.8.1

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    DOI License Documentation Status PyPI version Downloads

    A package for machine learning inference in FPGAs. We create firmware implementations of machine learning algorithms using high-level synthesis (HLS). We translate traditional open-source machine learning package models into HLS that can be configured for your use-case!

    hls4ml is designed for ultra-low-latency inference on FPGAs. While it has strong roots in high-energy physics applications (e.g., L1 trigger systems at the CERN Large Hadron Collider), it has also been adopted across diverse scientific and industrial domains. Example use cases include control systems for quantum computing, feedback loops in nuclear fusion, low-power environmental monitoring on satellites, and biomedical signal processing (e.g., arrhythmia classification).

    If you have any questions, comments, or ideas regarding hls4ml or just want to show us how you use hls4ml, don't hesitate to reach out to us through the discussions tab.

    Documentation & Tutorial

    For more information visit the webpage: https://fastmachinelearning.org/hls4ml/.

    For introductory material on FPGAs, HLS and ML inferences using hls4ml, check out the video.

    Detailed tutorials on how to use hls4ml's various functionalities can be found here.

    Installation

    pip install hls4ml
    

    To install the extra dependencies for profiling:

    pip install hls4ml[profiling]
    

    Getting Started

    Creating an HLS project

    import hls4ml
    
    # Fetch a keras model from our example repository
    # This will download our example model to your working directory and return an example configuration file
    config = hls4ml.utils.fetch_example_model('KERAS_3layer.json')
    
    # You can print the configuration to see some default parameters
    print(config)
    
    # Convert it to an HLS project
    hls_model = hls4ml.converters.keras_v2_to_hls(config)
    
    # Print full list of example models if you want to explore more
    hls4ml.utils.fetch_example_list()
    

    Building a project

    We will build the project using Xilinx Vivado HLS, which can be downloaded and installed from here. Alongside Vivado HLS, hls4ml also supports Vitis HLS, Intel HLS, Catapult HLS and Altera HLS IP Gen. The target backend can be changed using the backend argument when building the model.

    # Use Vivado HLS to synthesize the model
    # This might take several minutes
    hls_model.build()
    
    # Print out the report if you want
    hls4ml.report.read_vivado_report('my-hls-test')
    

    FAQ

    The list of frequently asked questions and common HLS synthesis issues can be found here.

    Citation

    If you use this software in a publication, please cite the software

    @software{fastml_hls4ml,
      author       = {{FastML Team}},
      title        = {fastmachinelearning/hls4ml},
      year         = 2026,
      publisher    = {Zenodo},
      version      = {v1.3.0},
      doi          = {10.5281/zenodo.1201549},
      url          = {https://github.com/fastmachinelearning/hls4ml}
    }
    

    the first publication:

    @article{Duarte:2018ite,
        author = "Duarte, Javier and others",
        title = "{Fast inference of deep neural networks in FPGAs for particle physics}",
        eprint = "1804.06913",
        archivePrefix = "arXiv",
        primaryClass = "physics.ins-det",
        reportNumber = "FERMILAB-PUB-18-089-E",
        doi = "10.1088/1748-0221/13/07/P07027",
        journal = "JINST",
        volume = "13",
        number = "07",
        pages = "P07027",
        year = "2018"
    }
    

    and the latest overview paper:

    @article{Schulte:2025mai,
        author = "Schulte, Jan-Frederik and others",
        title = "{hls4ml: A Flexible, Open-Source Platform for Deep Learning Acceleration on Reconfigurable Hardware}",
        eprint = "2512.01463",
        archivePrefix = "arXiv",
        primaryClass = "cs.AR",
        reportNumber = "FERMILAB-PUB-25-0890-CSAID-ETD-PPD",
        year = "2026",
        doi = "10.1145/3801979",
        journal = "ACM Trans. Reconfigurable Technol. Syst.",
        volume = "19",
        pages = "19",
    }
    
    
    

    Additionally, if you use specific features developed in later papers, please cite those as well. For example, CNNs:

    @article{Aarrestad:2021zos,
        author = "Aarrestad, Thea and others",
        title = "{Fast convolutional neural networks on FPGAs with hls4ml}",
        eprint = "2101.05108",
        archivePrefix = "arXiv",
        primaryClass = "cs.LG",
        reportNumber = "FERMILAB-PUB-21-130-SCD",
        doi = "10.1088/2632-2153/ac0ea1",
        journal = "Mach. Learn. Sci. Tech.",
        volume = "2",
        number = "4",
        pages = "045015",
        year = "2021"
    }
    @article{Ghielmetti:2022ndm,
        author = "Ghielmetti, Nicol\`{o} and others",
        title = "{Real-time semantic segmentation on FPGAs for autonomous vehicles with hls4ml}",
        eprint = "2205.07690",
        archivePrefix = "arXiv",
        primaryClass = "cs.CV",
        reportNumber = "FERMILAB-PUB-22-435-PPD",
        doi = "10.1088/2632-2153/ac9cb5",
        journal ="Mach. Learn. Sci. Tech.",
        year = "2022"
    }
    

    Distributed arithmetic:

    @misc{Sun:2025,
          title={da4ml: Distributed Arithmetic for Real-time Neural Networks on FPGAs},
          author={Chang Sun and others},
          year={2025},
          eprint={2507.04535},
          archivePrefix={arXiv},
          primaryClass={cs.AR},
          url={https://arxiv.org/abs/2507.04535},
    }
    

    binary/ternary networks:

    @article{Loncar:2020hqp,
        author = "Ngadiuba, Jennifer and others",
        title = "{Compressing deep neural networks on FPGAs to binary and ternary precision with HLS4ML}",
        eprint = "2003.06308",
        archivePrefix = "arXiv",
        primaryClass = "cs.LG",
        reportNumber = "FERMILAB-PUB-20-167-PPD-SCD",
        doi = "10.1088/2632-2153/aba042",
        journal = "Mach. Learn. Sci. Tech.",
        volume = "2",
        pages = "015001",
        year = "2021"
    }
    

    Spiking Neural Networks (SNNs):

    @misc{dillon2026spikingneuralnetworkinference,
          title={Spiking Neural Network inference on FPGAs with hls4ml},
          author={Barry M. Dillon},
          year={2026},
          eprint={2606.10008},
          archivePrefix={arXiv},
          primaryClass={cs.NE},
          url={https://arxiv.org/abs/2606.10008},
    }
    

    Acknowledgments

    If you benefited from participating in our community, we ask that you please acknowledge the Fast Machine Learning collaboration and particular individuals who helped you in any publications. Please use the following text for this acknowledgment:

    We acknowledge the Fast Machine Learning collective as an open community of multi-domain experts and collaborators. This community and <names of individuals>, in particular, were important for the development of this project.

    Funding

    We gratefully acknowledge previous and current support from the U.S. National Science Foundation (NSF) Harnessing the Data Revolution (HDR) Institute for Accelerating AI Algorithms for Data Driven Discovery (A3D3) under Cooperative Agreement No. PHY-2117997, U.S. Department of Energy (DOE) Office of Science, Office of Advanced Scientific Computing Research under the Real‐time Data Reduction Codesign at the Extreme Edge for Science (XDR) Project (DE-FOA-0002501), DOE Office of Science, Office of High Energy Physics Early Career Research Program (DE-SC0021187, DE-0000247070), the European Research Council (ERC) under the European Union's Horizon 2020 research and innovation program (Grant No. 772369 and 966696), and the Eric & Wendy Schmidt Fund for Strategic Innovation through the CERN Next Generation Triggers project under grant agreement number SIF-2023-004.