PyTorch 需 >= 1.13 且 <= 2.15,更新版本未测试;Python 需 >= 3.10;README 注明这是研究项目,并非 Xilinx 官方产品。
brevitas
Xilinx活跃维护基于 PyTorch 的神经网络量化库,支持训练后量化和量化感知训练,方便把模型部署到 FPGA 等硬件上做加速。
Brevitas: neural network quantization in PyTorch
pip install brevitasREADME 未说明显存要求;GPU 训练加速为可选但推荐;支持 Windows、Linux、macOS。
Xilinx 出的 PyTorch 量化库,支持 PTQ 和 QAT,可直接替换常用层做低比特量化
基于 PyTorch 的神经网络量化库,支持训练后量化和量化感知训练,方便把模型部署到 FPGA 等硬件上做加速。
核心能力
- 提供 QuantConv、QuantLSTM 等量化层,可直接替换原层
- 支持训练后量化 PTQ 与量化感知训练 QAT 两条路线
- 输入、权重、偏置、输出等张量可分别配置量化参数
- 附带 ImageNet 分类模型的 PTQ 示例流程
容易踩的坑
- v0.13.3Release v0.13.3最新正式版2026-09-18 · 2026-09-18 14:41 UTC
What's Changed
- Docs: fix spelling mistakes in documentation by @loris307 in https://github.com/Xilinx/brevitas/pull/1600
- Fix (docs): Make docs generation more easily reproducible by @nickfraser in https://github.com/Xilinx/brevitas/pull/1602
- Setup: unpin transformers by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1534
- Fix (brevitas_examples/llm): remove deprecated flag by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1606
- Feat (utils): compile-friendly utils by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1592
- Fix (notebooks): fix typos by @averosim in https://github.com/Xilinx/brevitas/pull/1615
- Feat (fx): always import backport fx by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1613
- This ensures better forward compatibility with future pytorch versions
- Fix (notebooks): deprecated brevitas.quant.experimental imports by @averosim in https://github.com/Xilinx/brevitas/pull/1614
- Setup: prepare 0.13.3 release by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1618
New Contributors
- @loris307 made their first contribution in https://github.com/Xilinx/brevitas/pull/1600
- @averosim made their first contribution in https://github.com/Xilinx/brevitas/pull/1615
Full Changelog: https://github.com/Xilinx/brevitas/compare/v0.13.2...v0.13.3
- v0.13.2Release v0.13.22026-08-28 · 2026-08-28 15:38 UTC
查看更新说明
What's Changed
- Fix (generative/quant): test and fix preset quantizers by @pablomlago in https://github.com/Xilinx/brevitas/pull/1595
Full Changelog: https://github.com/Xilinx/brevitas/compare/v0.13.1...v0.13.2
- 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 -
QuantScaledDotProductAttentionnow returns finite zero outputs and gradients for fully masked attention rows instead of propagating NaNs. (#1591) - Configurable zero-point scaling -
ParameterFromStatsFromParameterZeroPointnow acceptsscale_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
filelocktest extra, updated CI dependency constraints for PyTorch 2.13, and pinnedxxhashfor 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.compileconfigurations. (#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_impltoParameterFromStatsFromParameterZeroPoint(#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
filelockto thetestextra (#1571) - Fix (ci/deps): Support
torch==2.13in CI and allowsetuptools<81(#1563) - Fix (deps): Remove the maximum ONNX Runtime version constraint (#1564)
- Setup: Pin
xxhashfor 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.compiletests (#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
- 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
transformersversion 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
- v0.12.1Release v0.12.12025-08-28 · 2025-08-28 17:01 UTC
查看更新说明
Highlights
- New / Updated PTQ Algorithms:
- Qronos support https://github.com/Xilinx/brevitas/pull/1311
- Fixes / improvements to rotation equalization https://github.com/Xilinx/brevitas/pull/1310, https://github.com/Xilinx/brevitas/pull/1312
- DDP-like bias correction for SDXL (experimental) https://github.com/Xilinx/brevitas/pull/1342
- Improved layer support:
- Quantization of SDPA without FX https://github.com/Xilinx/brevitas/pull/1299
- New export flows:
- Initial SHARK Export support: https://github.com/Xilinx/brevitas/pull/1300
- Initial GGUF Export: https://github.com/Xilinx/brevitas/pull/1291
- Improved examples:
- Qronos examples (paper) https://github.com/Xilinx/brevitas/pull/1326
- "Benchmark" experiments for stable diffusion, imagenet https://github.com/Xilinx/brevitas/pull/1281
- Post-training model expansion examples (paper) https://github.com/Xilinx/brevitas/pull/1355
- Allow signed scales https://github.com/Xilinx/brevitas/pull/1308
- QONNX export with
dynamo=Truehttps://github.com/Xilinx/brevitas/pull/1234
What's Changed
- Fix (setup): solve incompatibility between isort and yapf by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1293
- Feat (graph/hadamard): 152 had support by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1295
- feat (ex/llm): fully parametrise attention quantization by @nickfraser in https://github.com/Xilinx/brevitas/pull/1287
- Feat (ex/llm): "auto" dtype by @pablomlago in https://github.com/Xilinx/brevitas/pull/1301
- Setup: update transformers version by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1304
- Feat (brevitas_examples/llm): quant SDPA without FX by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1299
- Fix (brevitas_examples/llm): update README and yaml by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1305
- Setup: temporary pin pytest by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1307
- Feat (brevitas_examples/llm): configurable expansion step by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1280
- Versioning support in documentation by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1298
- Feat (graph/rotate): improve R2 region in SDPA by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1310
- Docs: improve docs build by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1314
- Fix (graph/rotation): rotation on subset of channels for SDPA by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1312
- Feat (brevitas_examples/llm): GGUF export by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1291
- Setup: bump torch version by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1205
- Fix (ex/imagenet): add forward pass in imagenet ptq example by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1316
- Feat (qronos): initial implementation of Qronos by @i-colbert in https://github.com/Xilinx/brevitas/pull/1311
- Fix (graph/equalize): correct class check during rotation merging by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1317
- docs (core): Typo fix in docstring by @nickfraser in https://github.com/Xilinx/brevitas/pull/1318
- Fix (llm): removing duplicate set_seed function by @i-colbert in https://github.com/Xilinx/brevitas/pull/1319
- Fix (ex/common): save scales during optimization by @pablomlago in https://github.com/Xilinx/brevitas/pull/1313
- Fix (llm): compatibility with non-uniform RMSNorm shapes by @i-colbert in https://github.com/Xilinx/brevitas/pull/1324
- Fix (graph/gpxq): fix memory leak with weight_orig by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1325
- Shark LLM export by @Giuseppe5 in https://github.com/Xilinx/brevitas/pull/1300
- Feat (scaling): rescaled min-max scaling and zero point by @i-colbert in https://github.com/Xilinx/brevitas/pull/1320
- Fix (gguf): derived modify_tensors() returns generator by @i-co
- New / Updated PTQ Algorithms:
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Brevitas
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.