Papers
Topics
Authors
Recent
Search
2000 character limit reached

Brevitas: PyTorch Quantization Library

Updated 5 July 2026
  • Brevitas is a PyTorch-based quantization library that enables simulation and export of reduced-precision neural networks for seamless FPGA deployment.
  • It supports both quantization-aware (QAT) and post-training (PTQ) workflows with configurable fixed-point, mixed, and custom quantization schemes.
  • Brevitas integrates explicit quantization metadata with FINN, streamlining the hardware/software co-design process for optimized neural network implementations.

Brevitas is a PyTorch-based quantization library and a quantization-aware trainer facility built as a drop-in replacement of PyTorch, tightly linked to FINN for FPGA deployment (Kanda et al., 1 Feb 2026, Ducasse et al., 2021). Across the literature it is used to implement and simulate fixed-point computation for neural networks, to train quantized neural networks with quantization-aware training (QAT), to apply post-training quantization (PTQ), and to export quantized models through ONNX or QONNX into hardware-oriented toolflows such as FINN and related FPGA backends (Kanda et al., 1 Feb 2026, Günay et al., 2022). In the studies surveyed here, Brevitas functions both as a software model of reduced-precision arithmetic and as the front-end through which quantization metadata—bit-widths, scales, thresholds, and layer-level quantizer choices—are made explicit for downstream hardware generation (Ducasse et al., 2021, Samson et al., 2024).

1. Historical role and software positioning

Brevitas is presented in the literature as a PyTorch library for quantized neural networks and as a tool dedicated for optimisation and quantisation of neural networks for FPGA implementation (Przewlocka et al., 2020, Stanisz et al., 2020). In FPGA-centered workflows, it is typically paired with FINN: Brevitas performs quantization-aware training in PyTorch, while FINN imports the exported graph, applies graph transformations and optimizations, and generates HLS or RTL accelerators for Xilinx platforms (Günay et al., 2022, Khandelwal et al., 2024). One paper describes this relationship explicitly as a workflow of train a quantized model in PyTorch using Brevitas and, in principle, compile to a hardware design using FINN later on (Przewlocka et al., 2020).

The framework is repeatedly characterized as a front-end for defining low-precision models that are guaranteed, or at least intended, to be FINN-compatible (Pasqual et al., 26 Jun 2026, Ducasse et al., 2021). In the FINN benchmark study, Brevitas is described as “a quantization-aware trainer facility built as a drop-in replacement of PyTorch and tightly linked to FINN,” and as providing “a set of building blocks to model a reduced precision hardware data-path at training time” (Ducasse et al., 2021). In application papers, the same role reappears in domain-specific form: it is the single point of control for fixed-point arithmetic in few-shot learning pipelines (Kanda et al., 1 Feb 2026), the bridge between PyTorch training and FINN’s quantized hardware graph for object detection (Günay et al., 2022), and the mechanism by which low-bitwidth CNNs and MLPs are exported to FINN-ONNX for embedded deployment (Pasqual et al., 26 Jun 2026, Khandelwal et al., 2024).

A broader implication is that Brevitas is not merely a collection of layer replacements. The surveyed papers consistently use it as the software layer where quantization design choices are made explicit early enough to influence both training dynamics and hardware realizability. This suggests an important distinction from purely deployment-time quantizers: Brevitas is used when numerical format is part of model design rather than an afterthought.

2. Quantization abstractions and numerical formats

The dominant abstraction in the surveyed work is uniform integer or fixed-point quantization with configurable bit-width for weights and activations (Ducasse et al., 2021, Khandelwal et al., 2024). In several studies, standard floating-point layers are replaced with Brevitas quantized layers such as QuantConv2d, QuantLinear, QuantReLU, QuantHardTanh, and QuantIdentity (Kanda et al., 1 Feb 2026, Günay et al., 2022, Khandelwal et al., 2024). The bit-width may be constant, learned, or assigned per layer, and the framework supports binary, ternary, and integer quantization, with scaling choices available for both layers and activation functions (Stanisz et al., 2020).

A recurrent formulation is uniform fixed-point quantization. In the few-shot edge-AI study, Brevitas is used to emulate a symmetric fixed-point representation with explicitly chosen integer and fractional bit-widths, with scale Δ=2bfrac\Delta = 2^{-b_{\text{frac}}} and quantization performed by rounding, clipping, and dequantization (Kanda et al., 1 Feb 2026). The paper gives a concrete example for 4-bit integer plus 4-bit fractional precision in a ReLU output, with range claimed as 8.0-8.0 to $7.9375$ and step size Δ=1/16=0.0625\Delta = 1/16 = 0.0625 (Kanda et al., 1 Feb 2026). In PTQ studies on LSTM text classifiers, the library is configured for uniform integer quantization with symmetric quantization, per-tensor granularity, and percentile-based clipping for activation calibration (Rahaman et al., 13 Jul 2025).

Other papers emphasize mixed precision. The embedded license-plate-recognition system uses 4-bit weights in the first 3 convolution layers, 2-bit weights in the next 7 convolution layers, and 1-bit weights in the final layer, while using 4-bit quantization for all activations except the final layer, where the model is trained with 8-bit quantization and run with 4-bit quantization during inference (Pasqual et al., 26 Jun 2026). The automotive CAN intrusion-detection work uses 2-bit precision for weights and activations in a custom-quantized MLP (Khandelwal et al., 2024). The quantized U-Net work treats bitwidth as a trainable parameter over 23 convolutional layers, with allowed values from 2 to 8 bits and an average converging to about 4.24 bits (Boerkamp et al., 10 Mar 2025).

The framework has also been extended beyond standard fixed-point integer schemes. In “Exploring FPGA designs for MX and beyond,” the authors integrate MX quantization into Brevitas by adding quantizers to floating-point element types and a new MX scaling regime based on block-wise E8M0 scales, principal-dimension grouping, and configurable block size kk (Samson et al., 2024). That work explicitly states that the latest version of Brevitas at the time did not support quantization schemes with low-precision floating-point elements, motivating the extension (Samson et al., 2024). This indicates that Brevitas has been used both as a fixed-point quantization framework and as a host for more specialized number systems such as MXFP and MXINT.

3. Training, calibration, and post-training workflows

The central methodological pattern is QAT: quantizers for weights and activations are inserted into the forward pass, and the network is trained under simulated low-precision arithmetic (Kanda et al., 1 Feb 2026, Günay et al., 2022). Although several papers do not spell out the mechanism in detail, they consistently describe the use of straight-through estimators as standard practice in Brevitas-based training (Kanda et al., 1 Feb 2026, Günay et al., 2022, Khandelwal et al., 2024). In the few-shot learning paper, QAT is implemented by replacing all convolution and activation layers in a ResNet12 backbone with Brevitas modules and retraining the backbone with quantization active throughout training (Kanda et al., 1 Feb 2026). In LPYOLO, the network is defined directly in quantized form in PyTorch, using quantized convolution layers and quantized activation layers, and is trained in a quantized structure with the WiderFace dataset (Günay et al., 2022).

PTQ is also supported and studied in detail. In the few-shot setting, PTQ consists of loading a float32 ResNet, constructing a quantized ResNet with Brevitas, copying the float32 weights into the quantized model, extracting features with the quantized backbone, and evaluating the nearest-class-mean classifier without further training (Kanda et al., 1 Feb 2026). The LSTM text-classification study presents a more elaborate PTQ pipeline: raw quantization of weights and activation stubs, calibration on unlabeled training data, and Greedy Path-Following Quantization refinement for the final linear layer (Rahaman et al., 13 Jul 2025). That study is notable for showing that calibration data composition materially affects outcomes, especially for generative LSTM classifiers at low bit-widths; class-balanced calibration remains stable down to 4 bits, whereas class-imbalanced calibration introduces insufficient weight adaptation at lower bitwidths for generative models (Rahaman et al., 13 Jul 2025).

The literature repeatedly reports that QAT is preferable to naive post-training conversion when precision is very low. In the few-shot paper, low bit-width results show QAT clearly outperforms PTQ for aggressive quantization such as 3/3, while PTQ becomes sufficient at 5/5 or 6/6 and beyond (Kanda et al., 1 Feb 2026). In PointPillars, the authors state that quantising the weights of a trained model does not provide good results, and therefore training networks with limited precision is a much better solution (Stanisz et al., 2020). Similar conclusions appear in LPYOLO, where the model is trained in quantized form from the start and later exported to FINN (Günay et al., 2022).

A further development is joint optimization of task loss and bit-width. QuantU-Net adds a bitwidth loss function to BCE and Dice losses so that gradient descent can optimize both segmentation accuracy and the size of the model in a single training session (Boerkamp et al., 10 Mar 2025). The total loss is described as LBCE+LDice+λLBitwidth\mathcal{L}_{\text{BCE}} + \mathcal{L}_{\text{Dice}} + \lambda \cdot \mathcal{L}_{\text{Bitwidth}} with λ=0.25\lambda = 0.25, and the resulting quantized model reaches an average of 4.24 bits with a validation accuracy of 94.25%, only 1.89% lower than the floating-point baseline (Boerkamp et al., 10 Mar 2025). This suggests a line of work in which Brevitas is not only used to instantiate quantizers, but also to expose precision itself as an optimization variable.

4. Deployment paths and hardware co-design

The most common deployment path is Brevitas \rightarrow ONNX or QONNX \rightarrow FINN \rightarrow FPGA accelerator (Günay et al., 2022, Ducasse et al., 2021). Because ONNX does not provide a way to represent layers with precisions under 8 bits, Brevitas exports sub-8-bit quantization information via custom annotations that FINN can interpret during import (Ducasse et al., 2021). FINN then performs streamlining, threshold folding, operator lowering, and hardware generation (Ducasse et al., 2021, Wasala et al., 10 Jul 2025). Activation quantization is often implemented in hardware through thresholding, and one benchmark paper explicitly describes FINN’s implementation as comparing inputs to a set of thresholds and returning the number of thresholds exceeded (Ducasse et al., 2021).

Hardware-aware numerical choices recur across the literature. In the SuperPoint visual-odometry work, Brevitas is configured for uniform affine quantization with zero-point fixed to 0, per-tensor activation scales, and per-output-channel weight scales, all chosen because they simplify hardware implementation and map cleanly to FINN’s threshold-based lowering (Wasala et al., 10 Jul 2025). In the MX work, Brevitas is extended to model block-wise E8M0 power-of-two scales, minifloat quantizers, and principal-dimension reshaping so that GPU-side emulation and FPGA IP blocks follow the same MX arithmetic rules (Samson et al., 2024). In the few-shot edge-AI study, Brevitas is used as a bit-accurate or stricter model of fixed-point behavior relative to Tensil-based FPGA deployment, exposing headroom beyond the fixed 8/8 and 16/16 formats supported in Tensil (Kanda et al., 1 Feb 2026).

The following table summarizes representative deployment patterns stated in the literature.

Context Brevitas role Downstream hardware path
Few-shot learning on edge hardware fixed-point emulation for training, evaluation, and NCM computations Tensil FPGA flow (Kanda et al., 1 Feb 2026)
Low-precision YOLO face detection quantized CNN definition and QAT in PyTorch ONNX 8.0-8.00 FINN / FINN-HLS 8.0-8.01 Vivado bitstream (Günay et al., 2022)
CAN intrusion detection 2-bit QAT front-end for CQMLP ONNX 8.0-8.02 FINN dataflow accelerator on XCZU7EV (Khandelwal et al., 2024)
License plate recognition quantized LPD and LPCR models FINN-ONNX 8.0-8.03 FINN 8.0-8.04 KV260 accelerators (Pasqual et al., 26 Jun 2026)
Quantized SuperPoint hardware-aware quantization and QAT QONNX 8.0-8.05 FINN streaming accelerator (Wasala et al., 10 Jul 2025)
MX arithmetic exploration MX quantizers and scaling inside Brevitas custom FPGA IP cores for MX arithmetic (Samson et al., 2024)

These deployment studies collectively position Brevitas as part of a hardware/software co-design loop rather than as a standalone training utility. A plausible implication is that its practical value increases when a project needs numerical behavior to remain stable across training, evaluation, export, and hardware execution.

5. Representative application domains

Brevitas has been used in a wide range of architectures and tasks. In convolutional vision systems, it quantizes TinyYOLOv3-derived detectors for face detection on PYNQ-Z2, where a 4W4A model reaches 0.757 mAP on the Easy category of WiderFace with 2.4 Watt total board power consumption and 18 FPS throughput (Günay et al., 2022). In embedded license-plate recognition, it supports both a 4-bit YOLO-style detector and a mixed-precision OCR network, enabling an end-to-end system that operates at 11.5 FPS on a Xilinx Kria KV260 platform with 4.2 W total power (Pasqual et al., 26 Jun 2026). In wearable medical imaging, it is used to quantize U-Net for tumor segmentation, reducing precision to an average of 4.24 bits while maintaining 94.25% validation accuracy (Boerkamp et al., 10 Mar 2025).

In few-shot learning, Brevitas is used not only for the backbone but also for non-network computations such as nearest-class-mean operations via QuantIdentity (Kanda et al., 1 Feb 2026). That study reports that miniImageNet 1-shot accuracy remains very close to float32 at 5/5 or 6/6 precision, indicating potential for further reduction in computational resources beyond current Tensil hardware constraints (Kanda et al., 1 Feb 2026). In visual odometry, Brevitas is used to quantize SuperPoint to INT8, INT4, INT3, and mixed 4-2-4 formats; the 3-bit FINN accelerator processes 640 × 480 pixel images at up to 54 fps on a Zynq UltraScale+ platform (Wasala et al., 10 Jul 2025).

In sequence and tracking models, the library supports both convolutional and recurrent regimes. A SiamFC-style tracker quantized with Brevitas explores INT16, INT4, ternary, and binary weight configurations, reducing convolutional-filter memory from 85.5 MB in FP32 to 7.2 MB in the binary setting while ternary and binary versions achieve the best tracking performance in the reported experiments (Przewlocka et al., 2020). In LSTM text classification, Brevitas PTQ is applied to embedding, LSTM, and linear layers across 8- to 3-bit settings, revealing that discriminative classifiers remain robust while generative ones are more sensitive to bitwidth, calibration data, and input noise during quantized inference (Rahaman et al., 13 Jul 2025). In automotive CAN intrusion detection, a 2-bit Brevitas-trained CQMLP achieves average accuracy 99.91%, 0.11 ms latency per CAN frame, and 0.23 mJ per inference on an FPGA dataflow implementation (Khandelwal et al., 2024).

Large 3D perception models have also been studied. In PointPillars, quantization of the backbone to INT2, PFN to INT8, SSD to INT8, and activations to INT4 yields a model about 16 times smaller than the original one, with AP decreased by max. 9% in the final configuration (Stanisz et al., 2020). This breadth of use indicates that Brevitas is not restricted to a single network family; it has been applied to CNNs, MLPs, Siamese trackers, LSTMs, ResNet variants, U-Net variants, and mixed classical/deep few-shot pipelines.

6. Design trade-offs, limitations, and open directions

Several limitations recur across the surveyed papers. First, hardware support often lags behind the numerical flexibility available in Brevitas. The few-shot paper shows that 5/5 or 6/6 fixed-point formats can maintain accuracy comparable to floating-point operations, yet Tensil only supports 8/8 or 16/16 fixed-point formats (Kanda et al., 1 Feb 2026). The FINN benchmark reports that while Brevitas trains mixed precision configurations, deployment support was at the time largely limited to equal weight and activation precision (Ducasse et al., 2021). The MX work similarly notes that software-side exploration can exceed what standard GPU or vendor deployment stacks natively support, which is precisely why custom FPGA datapaths are attractive (Samson et al., 2024).

Second, architecture coverage and toolflow constraints remain important. One tracking paper notes that the Brevitas-to-FINN flow is still limited in layer support, even though it is sufficient to guide designs for later FPGA implementation (Przewlocka et al., 2020). The LSTM PTQ study highlights a more specific restriction: Brevitas does not currently support GPFQ for LSTM layers, so recurrent weights remain quantized but unrefined by that algorithm (Rahaman et al., 13 Jul 2025). This suggests that recurrent and sequence models may require more specialized post-training procedures than feed-forward CNNs.

Third, calibration and nonlinearities can dominate behavior at low precision. In embedded license-plate detection, replacing the last sigmoid with HardTanh caused large localization errors for small license plates, whereas clipping logits to 8.0-8.06, quantizing them to 8 bits, and applying a sigmoid lookup table restored AP from 52% to 93.6% (Pasqual et al., 26 Jun 2026). In LSTM PTQ, the composition of calibration data changes activation statistics and weight adaptation enough to determine whether low-bit generative models remain usable (Rahaman et al., 13 Jul 2025). These results counter a common simplification that “quantization” is only about choosing a bit-width; in practice, range estimation, activation handling, and data selection are often equally decisive.

Finally, the literature repeatedly identifies layer sensitivity and nonuniform precision allocation as central design questions. Early feature extractors or first and last layers are often kept at higher precision in successful systems (Günay et al., 2022, Przewlocka et al., 2020). Very low precision can work remarkably well under QAT—2-bit CQMLP for CAN IDS, ternary or binary Siamese tracking, INT3 SuperPoint, INT2 backbone in PointPillars—but only when the architecture, data, and deployment stack are aligned with those constraints (Khandelwal et al., 2024, Przewlocka et al., 2020, Wasala et al., 10 Jul 2025, Stanisz et al., 2020). A plausible implication is that Brevitas is most effective not when used as a universal quantizer, but when treated as an instrument for systematic numerical co-design: per-layer precision assignment, calibration strategy, activation choice, export compatibility, and hardware backend must all be considered jointly.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Brevitas.