brevitas

Xilinx活跃维护

基于 PyTorch 的神经网络量化库,支持训练后量化和量化感知训练,方便把模型部署到 FPGA 等硬件上做加速。

Brevitas: neural network quantization in PyTorch

v0.13.3发布于 2026-09-18 14:41 UTC1,594star +1 / 7 天259fork同步于 2026-11-10 17:49 UTC

怎么上手

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

README 未说明显存要求;GPU 训练加速为可选但推荐;支持 Windows、Linux、macOS。

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

项目说明

由 README 自动翻译提炼

Xilinx 出的 PyTorch 量化库,支持 PTQ 和 QAT,可直接替换常用层做低比特量化

基于 PyTorch 的神经网络量化库,支持训练后量化和量化感知训练,方便把模型部署到 FPGA 等硬件上做加速。

核心能力

  • 提供 QuantConv、QuantLSTM 等量化层,可直接替换原层
  • 支持训练后量化 PTQ 与量化感知训练 QAT 两条路线
  • 输入、权重、偏置、输出等张量可分别配置量化参数
  • 附带 ImageNet 分类模型的 PTQ 示例流程

容易踩的坑

PyTorch 需 >= 1.13 且 <= 2.15,更新版本未测试;Python 需 >= 3.10;README 注明这是研究项目,并非 Xilinx 官方产品。

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

最近发版

5 个版本v0.13.3
  1. v0.13.3Release v0.13.3最新正式版2026-09-18 · 2026-09-18 14:41 UTC

    What's Changed

    New Contributors

    Full Changelog: https://github.com/Xilinx/brevitas/compare/v0.13.2...v0.13.3

  2. v0.13.2Release v0.13.22026-08-28 · 2026-08-28 15:38 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/Xilinx/brevitas/compare/v0.13.1...v0.13.2

  3. v0.13.1Release v0.13.12026-08-25 · 2026-08-25 09:50 UTC
    查看更新说明

    Changelog

    Highlights

    The most important changes since v0.13.0:

    • PyTorch compatibility updates - Brevitas now requires PyTorch 1.13 or later, with fixes for PyTorch 2.8 Dynamo export, PyTorch 2.13+ named-tensor removal, and the FX version guard through PyTorch 2.14. (#1556, #1559, #1565, #1572)
    • QSDPA stability - QuantScaledDotProductAttention now returns finite zero outputs and gradients for fully masked attention rows instead of propagating NaNs. (#1591)
    • Configurable zero-point scaling - ParameterFromStatsFromParameterZeroPoint now accepts scale_shift_zero_point_impl. (#1585)
    • Quantized tensor efficiency and correctness - groupwise quantization metadata is no longer expanded when unused, and quantized-weight merging now matches pointers correctly. (#1590, #1560)
    • Broader dependency compatibility - removed the ONNX Runtime upper bound, restored the filelock test extra, updated CI dependency constraints for PyTorch 2.13, and pinned xxhash for Lighteval. (#1563, #1564, #1571, #1578)
    • Improved CI coverage and maintenance - GitHub Actions are regenerated when workflow sources change; restored or adjusted tests cover example accuracy, asymmetric ONNX Runtime export, Windows CPU precision support, and incompatible torch.compile configurations. (#1557, #1558, #1562, #1575, #1576)

    Breaking Changes

    • PyTorch 1.13 is now the minimum supported version. Support for earlier PyTorch versions and their compatibility guards has been removed. (#1556)

    All Commits

    Features

    • Feat (actions): Regenerate GitHub Actions when workflow sources change (#1558)
    • Feat (core): Add scale_shift_zero_point_impl to ParameterFromStatsFromParameterZeroPoint (#1585)

    Fixes

    • Fix (brevitas_examples/custom_trainer): Restore TensorBoard compatibility (#1555)
    • Fix (tests/ort): Fix Dynamo export with PyTorch 2.8 (#1559)
    • Fix (papers/axe): Match the new benchmark structure (#1561)
    • Fix (test): Use a lower default opset version with PyTorch < 2 (#1566)
    • Fix (ex/benchmark): Eliminate folder-creation race conditions (#1567)
    • Fix (fx): Extend the FX version guard through PyTorch 2.14 (#1572)
    • Fix (nn/utils): Correct pointer matching while merging quantized weights (#1560)
    • Fix (nn/graph/test): Avoid unsupported tensor renaming on PyTorch >= 2.13 (#1565)
    • Fix (quant_tensor): Avoid unnecessary groupwise metadata expansion and correct device checks (#1590)
    • Fix (nn): Prevent NaN forward outputs and gradients in QSDPA for fully masked attention rows (#1591)

    Setup & Dependencies

    • Setup: Raise the minimum supported PyTorch version to 1.13 and refresh supported PyTorch and Python test matrices (#1556)
    • Fix (deps/test): Add filelock to the test extra (#1571)
    • Fix (ci/deps): Support torch==2.13 in CI and allow setuptools<81 (#1563)
    • Fix (deps): Remove the maximum ONNX Runtime version constraint (#1564)
    • Setup: Pin xxhash for Lighteval compatibility (#1578)

    Tests & CI

    • Test (brevitas_examples): Restore the skipped example accuracy test (#1557)
    • Fix (ci): Exclude Python 3.13 with PyTorch 2.5.1 (#1570)
    • Fix (ci): Skip FP16/BF16 CPU tests on Windows CPU runners (#1575)
    • Fix (test/ort): Re-enable asymmetric ONNX Runtime tests (#1576)
    • Fix (tests): Skip incompatible torch.compile tests (#1562)

    Documentation

    • Docs: Add v0.13.0 to the documentation version selector (#1553)
    • Docs: Prepare release documentation (#1586)
    • Docs: Correct the Learned Round documentation section (#1588)
    • Docs: Regenerate documentation (#1589)

    Full Changelog: https://github.com/Xilinx/brevitas/compare/v0.13.0...v0.13.1

  4. v0.13.0Release v0.13.02026-07-14 · 2026-07-14 16:36 UTC
    查看更新说明

    Highlights

    The most important changes in this release cycle:

    • (MX)FP quantizers moved out of experimental — floating-point / MX quantizers are now first-class, supported quantizers. (#1488)
    • Experimental vLLM export support — new export path targeting vLLM. (#1444)
    • Learned Round refactor + documentation — reworked learned round in the common examples with dedicated docs. (#1323, #1485)
    • LLM customization plugins — custom trainer support and a custom quantizer plugin to modify the quantized model, plus the ability to pass custom quantizers via the common quantizer API. (#1474, #1508, #1456)
    • GGUF improvements — quantize high-impact layers to high precision and attach metadata to GGUF exports. (#1532, #1527)
    • PeRQ (formerly MixQuant) — initial MixQuant support added, then renamed to PeRQ throughout the codebase and docs. (#1448, #1521, #1525)
    • Python 3.13 support. (#1451)
    • Utility to replace weights with quantized ones. (#1505)
    • Signed scaling — signed scaling stats in core and signed scales in the LLM entry point. (#1393, #1449)
    • Blockwise / block rotations — support for blockwise rotations and the option to disable fused block rotations. (#1434, #1438)
    • New search algorithms for LLM experiments (#1357)

    Breaking Changes

    • LLM: load as much data as needed — data loading behavior changed in the LLM examples. (#1514)
    • Removed Python 3.9 support. (#1481)
    • Deprecated old Python and Torch versions. (#1392)
    • numpy is now an optional extra — installs no longer pull in numpy by default. (#1403)
    • Minimum transformers version now enforced. (#1510)
    • CLI rename: block_rotation_dim → rotation_block_size. (#1464)
    • Deprecated unused MLIR export in the LLM examples. (#1467)

    All Commits

    Features

    • Feat (benchmark): Allow easy specification of different search algorithms within benchmark scripts (#1357)
    • Feat (brevitas_examples/llm): custom trainer support (#1474)
    • Feat (ex/axe): improved implementation with extended support/testing (#1181)
    • Feat (gguf): enabling quantization of high-impact layers to high precision (#1532)
    • Feat (utils): utils to replace weights with quantized ones (#1505)
    • Feat (utils): reducing variance on power_iteration func (#1519)
    • Feat (ex/llm): custom quantizer plugin allows to modify quant model (#1508)
    • Feat (quant/float): move (MX)FP quantizers out of experimental (#1488)
    • Feat (brevitas_examples/llm)!: load as much data as needed (#1514)
    • Feat (llm): enabling narrow_range for inputs in LLM entry point (#1524)
    • Feat (benchmark): Minor tweaks to run_args_bucket_process (#1523)
    • Feat (loss): support for high precision loss (#1496)
    • Feat (docs): Documentation for Learned Round (#1485)
    • Feat (vLLM): experimental support for vLLM export (#1444)
    • Feat (ex/common): learned round refactor (#1323)
    • Feat (brevitas_examples/llm): better dataset handling (#1461)
    • Feat (brevitas_examples/llm): Use dataloader in AWQ (#1489)
    • Feat (ex/llm): Signed scales in LLM entrypoint (#1449)
    • Feat (brevitas_examples/llm): deprecate unused MLIR export (#1467)
    • Feat (cli): rename block_rotation_dim to rotation_block_size (#1464)
    • Feat (brevitas_examples/llm): fineweb support (#1459)
    • Feat (bit_width): generalize restrict_impl with clamping (#1457)
    • Feat (equalize): adding initial support for MixQuant (#1448)
    • Feat (common/quantizer): Enable passing custom quantizers (#1456)
    • Feat (brevitas_examples/llm): compute perplexity at float32 (#1458)
    • Feat (equalize): option to disable fused block rotations (#1438)
    • Feat (optim): decoupling dtype of CayleySGD from params (#1443)
    • Feat (brevitas_examples/llm): Support for batched inputs in GPXQ/Qronos (#1427)
    • Feat (brevitas_examples/llm): better RMSNorm replacement (#1436)
    • Feat (brevitas_examples/common): mse scale for weights with float quant (#1433)
    • Feat (brevitas_examples/llm): sup
  5. v0.12.1Release v0.12.12025-08-28 · 2025-08-28 17:01 UTC
    查看更新说明

    Highlights

    What's Changed

用户点评

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

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

    README 原文

    未翻译

    Brevitas

    Downloads Pytest Examples Pytest DOI

    Brevitas is a PyTorch library for neural network quantization, with support for both post-training quantization (PTQ) and quantization-aware training (QAT).

    Please note that Brevitas is a research project and not an official Xilinx product.

    If you like this project please consider ⭐ this repo, as it is the simplest and best way to support it.

    Requirements

    • Python >= 3.10
    • Pytorch >= 1.13, <= 2.15 (more recent versions would be untested).
    • Windows, Linux or macOS.
    • GPU training-time acceleration (Optional but recommended).

    Installation

    You can install the latest release from PyPI:

    pip install brevitas
    

    Getting Started

    Brevitas currently offers quantized implementations of the most common PyTorch layers used in DNN under brevitas.nn, such as QuantConv1d, QuantConv2d, QuantConvTranspose1d, QuantConvTranspose2d, QuantMultiheadAttention, QuantRNN, QuantLSTM etc., for adoption within PTQ and/or QAT. For each one of these layers, quantization of different tensors (inputs, weights, bias, outputs, etc) can be individually tuned according to a wide range of quantization settings.

    As a reference for PTQ, Brevitas provides an example user flow for ImageNet classification models under brevitas_examples.imagenet_classification.ptq that quantizes an input torchvision model using PTQ under different quantization configurations (e.g. bit-width, granularity of scale, etc).

    For more info, checkout our documentation.

    Cite as

    If you adopt Brevitas in your work, please cite it as:

    @software{brevitas,
      author       = {Franco, Giuseppe and Monteagudo-Lago, Pablo and Colbert, Ian and Pappalardo, Alessandro and Fraser, Nicholas J},
      title        = {Xilinx/brevitas},
      year         = {2026},
      publisher    = {Zenodo},
      doi          = {10.5281/zenodo.3333552},
      url          = {https://doi.org/10.5281/zenodo.3333552}
    }
    

    History

    • 2026/09/23 - Release version 0.13.4, see the release notes.
    • 2026/09/18 - Release version 0.13.3, see the release notes.
    • 2026/08/28 - Release version 0.13.2, see the release notes.
    • 2026/08/25 - Release version 0.13.1, see the release notes.
    • 2026/07/14 - Release version 0.13.0, see the release notes.
    • 2025/08/28 - Release version 0.12.1, see the release notes.
    • 2025/05/09 - Release version 0.12.0, see the release notes.
    • 2024/10/10 - Release version 0.11.0, see the release notes.
    • 2024/07/23 - Minor release version 0.10.3, see the release notes.
    • 2024/02/19 - Minor release version 0.10.2, see the release notes.
    • 2024/02/15 - Minor release version 0.10.1, see the release notes.
    • 2023/12/08 - Release version 0.10.0, see the release notes.
    • 2023/04/28 - Minor release version 0.9.1, see the release notes.
    • 2023/04/21 - Release version 0.9.0, see the release notes.
    • 2023/01/10 - Release version 0.8.0, see the release notes.
    • 2021/12/13 - Release version 0.7.1, fix a bunch of issues. Added TVMCon 2021 tutorial notebook.
    • 2021/11/03 - Re-release version 0.7.0 (build 1) on PyPI to fix a packaging issue.
    • 2021/10/29 - Release version 0.7.0, see the release notes.
    • 2021/06/04 - Release version 0.6.0, see the release notes.
    • 2021/05/24 - Release version 0.5.1, fix a bunch of minor issues. See release notes.
    • 2021/05/06 - Release version 0.5.0, see the release notes.
    • 2021/03/15 - Release version 0.4.0, add support for __torch_function__ to QuantTensor.
    • 2021/03/04 - Release version 0.3.1, fix bug w/ act initialization from statistics w/ IGNORE_MISSING_KEYS=1.
    • 2021/03/01 - Release version 0.3.0, implements enum and shape solvers within extended dependency injectors. This allows declarative quantizers to be self-contained.
    • 2021/02/04 - Release version 0.2.1, includes various bugfixes of QuantTensor w/ zero-point.
    • 2021/01/30 - First release version 0.2.0 on PyPI.