PTQ4VM: Post-Training Quantization for Visual Mamba
Paper · 2024 · Younghyun Cho, Changhun Lee, Seonggon Kim et al.
Summary
Visual Mamba reads an image as a sequence of tokens and carries information forward as it scans them. Much of its inference time can still go into linear layers, whose matrix multiplications are candidates for faster, low-precision arithmetic. The difficulty is that a quantization range chosen for an entire layer can represent some of its inputs poorly. A few large values can dictate the spacing of the available numbers, while a small signal that matters for the final prediction can lose much of its detail. In Vision Mamba, the token used for classification is particularly exposed to this problem.
PTQ4VM adapts a pretrained Visual Mamba backbone using a small set of calibration images. Its first component assigns each token position its own quantization range and fixes that range before inference. The approach relies on the observation that the magnitude of a token's activations frequently follows a repeatable pattern at a given position in the scan. The method also uses SmoothQuant to reduce large values in particular input channels by moving some of their numerical range into the weights. It then tunes that redistribution and the spacing of the quantized values together, using the original backbone's intermediate outputs as the target.
The strongest gains over conventional quantization appear when both weights and activations use 4 bits. On the ImageNet-1K validation set, Vim-S reached 69.6% top-1 accuracy with PTQ4VM, compared with 0.1% for MinMax and 0.2% for SmoothQuant. The FP16 reference was 80.5%. The same precision was considerably easier on VMamba-B, where PTQ4VM reached 82.8% against an FP16 reference of 83.9%. With a VMamba-T backbone for object detection and instance segmentation on MSCOCO-2017, the method matched the reported FP16 scores at 8 bits and retained much of the original performance at 4 bits.
The authors report preparing quantized checkpoints within 15 minutes on a single RTX 3090. On that GPU, the 4-bit implementation reached a 1.83× end-to-end speedup over FP16 for VMamba-B at a batch size of 32. Fixed ranges contributed to this result by avoiding the need to estimate a fresh range for every token as each image was processed. The accuracy results show why the choice of range still matters. The same 4-bit setting can be a close approximation for one backbone and a substantial quality tradeoff for another.
Deep dive: PTQ4VM: Post-Training Quantization for Visual Mamba
PTQ4VM uses fixed scales for image-token positions and tunes quantization ranges to speed up Visual Mamba while preserving accuracy. · about 32 minutes to read
The problem and its context
An image becomes a sequence with a fixed route
A Visual Mamba backbone transforms an image into features that a system can use to recognize its contents. It works with visual tokens, which represent parts of the image, and processes them along specified scan directions. As it advances through a sequence, it updates an internal state. The state gives the current step access to information carried forward from earlier steps along that route. This is the visual use of a selective state space system, the mechanism on which Mamba is based.
The paper places this design in the history of sequence processing. Earlier state space systems offered a way to handle sequences by propagating an internal state, motivated partly by the quadratic cost associated with the Transformer and attention. In the time-invariant formulation described by the authors, the rule for updating the state is shared across sequence positions. Mamba makes important parts of that rule depend on the input. The system can therefore change how it takes up new information and reads out the state as it encounters different tokens. The authors describe its selective scan as having linear complexity in the length of the sequence.
An image admits several routes through its tokens, and the backbones in the paper make different choices. Vision Mamba, abbreviated Vim, applies Mamba directly to visual recognition and includes a dedicated classification token, called CLS. VMamba has a backbone design that the authors compare to Swin Transformer. LocalMamba supplies variants of both families, LocalVim and LocalVMamba, with changes to the scan directions. The dagger in LocalVim-T † identifies the tested variant with a CLS token. These distinctions matter because the quantizer sees the intermediate feature values generated by a particular architecture, scan route, and choice of token.
The critical distinction for quantization is between what changes with the image and what stays predictable about a position. A token at a given position can contain different visual information from one image to the next. It still occupies the same place in the configured sequence, and the scan has reached it through the same arrangement of positions. The authors look for regularities in the numerical magnitudes that survive variation in image content. A regularity of that kind can support a range chosen ahead of time, while leaving the underlying visual features free to vary.
Where lower precision could help
Neural inference uses two kinds of numerical arrays relevant to this study. Weights are the coefficients stored in a pretrained checkpoint. Activations are the intermediate values produced as an input passes through it. A linear layer combines the activations with the weights by matrix multiplication. Quantization represents those values with a limited set of numbers, and integer matrix multiplication can exploit that representation when suitable hardware kernels are available. The operation must pay for any conversions or scaling required around the integer multiplication, so the cost of the whole path matters.
The paper profiles Visual Mamba to identify where that tradeoff is worth making. It singles out linear projections, the selective scan, and reshape operations as prominent costs. A linear projection is the direct target for the low-precision matrix multiplications that the authors implement. The scan has a different performance profile. Its implementation already makes use of registers and shared memory to reduce memory bottlenecks, which limits the gains the authors expect from reducing its precision. Its hidden state also serves a different computational role from a projection input. The state participates in a succession of updates, so changing one state changes what is available to subsequent steps.
Reshapes rearrange data between operations or put tokens into the order needed by a scan. Their cost depends on moving and laying out data, which the paper treats as difficult to reduce through quantization alone. PTQ4VM consequently focuses on the linear layers. This gives the method a practical target and sets the scope of its eventual speed claims. Even if a projection becomes much cheaper, the rest of the backbone still contributes to latency.
What conventional quantization can adjust
The paper distinguishes quantization-aware training from post-training quantization. Quantization-aware training incorporates the effects of lower precision during training. Post-training quantization starts from an already trained checkpoint and uses a much smaller adaptation procedure. PTQ4VM belongs to the latter tradition even though it uses gradient descent during calibration. What it learns at that stage is a set of quantities used to represent and rescale existing features and weights.
The paper's MinMax baseline uses extreme values to set the quantization range. For activations, it uses an asymmetric representation, which can accommodate different magnitudes on the negative and positive sides of the range. For weights, it uses a symmetric representation with a separate scale for each output channel. A channel is a feature coordinate. An output channel corresponds to a row of the weight matrix in the paper's notation, and an input channel corresponds to a feature shared between the incoming activations and the columns of the weights.
A single activation range is inexpensive to apply because a whole tensor shares its quantization settings. It is also sensitive to whichever values set its endpoints. A wide interval with a limited supply of representable values leaves large gaps between them. Many distinct activations can then round to the same value. Narrowing the interval makes those gaps smaller, at the cost of clipping values beyond the chosen bounds. The paper cites earlier work on learnable quantization parameters and block reconstruction in explaining why accepting some clipping can be preferable to representing every extreme.
SmoothQuant supplies another way to change the distribution before choosing the range. It was introduced to address unusually large activation values in some channels of large language models. The idea is to shrink those activation channels and compensate by enlarging the corresponding weight channels. Before quantization, the changes cancel in the matrix product. Once activations and weights are rounded separately, the two sides can have quite different errors. This creates room to move some of the difficulty from the activation side to the weight side.
The PTQ4VM authors encounter channel outliers in Visual Mamba as well, but identify a separate source of variation along the token axis. A channel scale acts on the same feature coordinate across the sequence. It cannot give one position a finer grid than another position. The straightforward way to obtain a separate grid is dynamic per-token quantization, which examines each token during inference and chooses its settings from the current values. Fixed token order offers a different possibility. If the recurring positional pattern is strong enough, a calibrated range for each position may capture much of the benefit while leaving the range-setting work outside inference.
The method, step by step
Look at the values entering a projection
The authors start by studying the activations that enter linear layers. An activation tensor for a single image can be read as a grid with input channels down one axis and token positions along the other. The column for a token contains its feature values at that point in the network. A row tracks one feature across the sequence. Looking along each axis separately reveals problems that a single histogram can conflate.
For a concrete example, the paper examines inputs to the 22nd output projection of Vim-Ti for images from 3 categories. It presents both the original activation arrangements and averages taken along the two axes. Some positions show recognizable patterns across the different images. Position 97 is the example the authors single out. They connect this repeatability to the predetermined order of visual tokens. They also report more pronounced differences among positions in middle and later blocks than in early ones. A quantization rule that is adequate near the beginning can therefore encounter a different distribution deeper in the same backbone.
The CLS token gives this observation a practical consequence. In Vim, the authors find that its activations are smaller in magnitude than those of the visual tokens across the inputs they examine. A range shared across positions has to accommodate the larger visual features. Within that range, the smaller CLS activations can occupy a narrow band of available values even though the token carries information needed for classification. Assigning the CLS position its own range lets the grid reflect the scale of that token's features.
The second pattern runs along the other axis. Especially large activations tend to appear in a few input channels, with some persistence across images. Per-token quantization deals with differences between columns of the tensor. Each column still contains all its channels, so a large entry in that column can determine the range used for the rest. The authors use channel smoothing to reduce this effect before the token-specific quantizer is applied. The channel operation and the token operation address distinct patterns in the same tensor.
The third pattern concerns the frequency of extreme values. In the distribution used to illustrate the long tail, roughly 98% of activations lie in a narrow region. The top and bottom 1% occupy a much broader span. The authors report tails that extend beyond 10,000 in the Vision Mamba family. When a distribution has that shape, going all the way to its observed endpoints devotes much of the range to values that occur infrequently. Calibrated truncation allows the interval to stop short of those extremes. Choosing where to stop requires considering the losses from both rounding the dense region and clipping the tail.
Calibrating and running PTQ4VM
The steps in order.
What the selective scan computes
The paper gives the state space equations to explain the architecture in which the projections sit. It begins with the time-invariant case, in which the state transition and input contribution can be discretized with a shared timescale. The discrete transition is written as follows.
Ā = exp(ΔA)
Here, A is the state transition parameter, Δ is the timescale, and Ā is the transition after discretization. The function exp is the exponential of its matrix argument. The state has dimension N, and A maps that state space back into itself.
B̄ = (ΔA)⁻¹ · (exp(ΔA) − I) · ΔB
B is the parameter that maps an input into the state space. B̄ is its discretized counterpart. A and Δ have the same meanings as in the previous expression, I is the identity matrix for the state space, and the superscript ⁻¹ denotes a matrix inverse. The multiplication dots indicate products of the factors in the order written.
hₜ = Ā · hₜ₋₁ + B̄ · xₜ
The index t denotes the current step in the sequence. The current state is hₜ, the preceding state is hₜ₋₁, and xₜ is the input at the current step. The first term carries forward the preceding state through the transition Ā. The second injects the current input through B̄.
yₜ = C · hₜ
The symbol yₜ denotes the output at step t, and C is the readout parameter that maps the current state hₜ to that output. Together, the two state and output equations distinguish the information carried forward from the quantity read out at a particular step.
In Mamba, the paper instead describes input-dependent quantities. It writes the projection that produces them in a compact form.
Bₜ, Δₜ, Cₜ = Linearₓ(xₜ)
Here, xₜ is the input at step t, and Linearₓ is the learned projection that produces the current input parameter Bₜ, the timescale quantity Δₜ, and the readout parameter Cₜ. The subscript t indicates that these quantities can vary with the step and the input.
Δ̄ₜ = softplus(LinearΔ(Δₜ))
In this expression, LinearΔ denotes the learned projection applied to Δₜ. The softplus function makes the result positive, and Δ̄ₜ is the resulting timescale for step t. The bar distinguishes that transformed quantity from the value entering the projection.
Āₜ = exp(Δ̄ₜA)
Āₜ is the discretized state transition at step t. A is the state transition parameter, Δ̄ₜ is the input-dependent timescale, and exp is the exponential. The transition can vary from step to step through the timescale.
B̄ₜ = Δ̄ₜBₜ
B̄ₜ is the discretized input parameter at step t in the selective formulation given by the paper. It combines the current timescale Δ̄ₜ with the current input parameter Bₜ. This is the form the authors give for Mamba alongside the earlier time-invariant discretization.
PTQ4VM applies to linear projections in the backbone around this sequence computation. The state equations explain why a projection and a scan state make different quantization targets. A projection admits an integer matrix multiplication followed by rescaling. The hidden state is repeatedly read and updated along the sequence. The paper examines quantizing that state as a diagnostic and uses the projection path for the proposed method.
Give the integer grid a spacing and an offset
For the baseline activation quantizer, the observed extrema determine the spacing of the grid. The paper's range formula can be written as follows.
Δₓ = (max(X) − min(X)) / (2ᵇ − 1)
X is the activation tensor covered by this quantizer, and max and min select its largest and smallest values. The bit width is b, and Δₓ is the step size, or the distance between neighboring quantized levels in the original numerical units. The denominator gives the number of intervals between the endpoints of the integer code range.
ϵₓ = −min(X) / Δₓ
The offset ϵₓ shifts the activation into the integer range. The minimum of X supplies the reference for that shift, and Δₓ expresses it in units of the step size. With an offset, the quantizer can accommodate a range whose most negative and most positive values have different magnitudes.
X̂ = Δₓ · (clip(round(X / Δₓ) + ϵₓ, 0, 2ᵇ − 1) − ϵₓ)
X̂ is the reconstructed activation after quantization. The operation round maps to a nearby integer, and clip restricts the code to the interval given by its last two arguments. The lower bound is 0 and the upper bound is 2ᵇ − 1, with b the bit width. The step size Δₓ maps X into grid units and later restores the original scale. The offset ϵₓ is applied on the way into the code range and removed on the way back. The array operations apply to each activation value.
The weight quantizer is symmetric. Its range is determined by the largest absolute weight within the group being quantized, which is an output channel in the setup used here.
Δ𝑤 = max(abs(W)) / (2ᵇ⁻¹ − 1)
W denotes the weights in the group. The function abs takes their magnitudes, and max selects the largest one. The bit width is b. The denominator is the largest positive code in the symmetric range used by the paper, and Δ𝑤 is the step size for the weight group.
Ŵ = Δ𝑤 · clip(round(W / Δ𝑤), −2ᵇ⁻¹ + 1, 2ᵇ⁻¹ − 1)
Ŵ is the reconstructed weight array. The operator round selects an integer code after division by Δ𝑤, and clip limits that code to the stated negative and positive bounds. The bit width b determines those bounds. Multiplication by the weight step Δ𝑤 puts the values back into the original units. The range is centered on zero, so the weight expression has no offset term.
These formulas describe the conventional range choice before truncation and tuning. They also explain the tradeoff that JLSS later exploits. When the quantization step is set by very large observations, the cost is paid throughout the group as wider rounding intervals. Choosing a smaller step at the same bit width narrows the span covered by the grid. The method can accept larger errors on some extreme entries if the resulting representation better preserves the features needed by the next operations.
Rescale the input channels without changing the exact product
SmoothQuant redistributes the range before the activation and weight quantizers are applied. The appendix gives the scale initialization in a form that exposes the hyper-parameter controlling that redistribution.
s = max(|X|)ᵅ / max(|W|)¹⁻ᵅ
The symbol s denotes the vector of smoothing scales, with one entry per input channel. X is the activation array and W is the weight matrix. The bars inside the maxima denote absolute value. Each maximum is taken over the entries associated with the input channel in question, using the activation observations for X and the corresponding weights for W. The exponent α controls the relative influence of the two maxima. The paper identifies 0.5 as the setting for its basic smoothing expression, and the appendix gives configuration-specific choices.
Y = (W · diag(s)) · (diag(s)⁻¹ · X)
Y is the linear output before quantization. W has its input channels along its columns, and X has the same channels along its rows. The function diag places the entries of s on a diagonal matrix. Right multiplication of W by that matrix scales the columns of W. Left multiplication of X by the inverse diagonal matrix scales the corresponding rows of X in the opposite direction. The dots denote matrix multiplication, and the reciprocal factors cancel when the two transformed arrays are multiplied at full precision.
For an input channel with unusually large activation magnitudes, a suitable scale can shrink the values presented to the activation quantizer. The weights on that channel then grow in compensation. The choice of scale therefore affects both sides of the integer multiplication. A scale that helps the activation representation can make the weight representation harder, especially when weights also have few available codes. That interaction is the reason PTQ4VM treats smoothing as a starting point for joint calibration.
Make the activation grid specific to a position
Per-Token Static quantization, or PTS, assigns a step size and an offset to each position of a fixed-length token sequence. The method obtains these settings using calibration images and keeps them for inference. Every image still produces its own activation values. What the images share is the grid used at a given sequence position. This retains a key property of static quantization while giving positions with different activation magnitudes different numerical ranges.
The activation and weight scales attach to opposite sides of the output. The weight scale varies with the output channel, and the activation scale varies with the token position. This arrangement lets the integer matrix multiplication combine all values along the input-channel dimension before the two scales are applied. In the paper's simplified expression, the activation offset is omitted to show that factorization.
Y ≈ (diag(Δ𝑤) · W̄) · (X̄ · diag(Δₓ)) = diag(Δ𝑤) · (W̄ · X̄) · diag(Δₓ)
Y is the approximate projection output. W̄ holds integer-mapped weights, with rows for output channels and columns for input channels. X̄ holds integer-mapped activations, with rows for input channels and columns for tokens. Δ𝑤 is the vector of weight steps for output channels, and Δₓ is the vector of activation steps for token positions. The function diag makes the corresponding diagonal matrices, and the multiplication dots indicate matrix products. The approximation sign reflects the use of quantized values. The equality between the two arrangements follows from grouping the same matrix product in different ways.
The dimensions explain which factors depend on image content. The activation tensor has dimensions Dᵢₙ by L, where Dᵢₙ is the number of input channels and L is the token count. The weight matrix has dimensions Dₒᵤₜ by Dᵢₙ, where Dₒᵤₜ is the number of output channels. Each entry in the output belongs to an output channel and a token, so its rescaling factor comes from the associated entries of the weight and activation step vectors. With static steps, the same position uses the same activation factor for each input of the configured shape.
Smoothing has a different placement because it acts on the input channels that are combined inside the product. It transforms the activations and corresponding weights before quantization. PTS then determines how the resulting activation values are represented along the token axis. This separation is what allows the method to combine smoothing with fixed per-token settings. The authors also describe the possibility of fusing scale factors across neighboring linear layers when the operations permit it. Their kernel description includes a dequantization stage for the implementation they benchmark.
Choose ranges locally, then tune the block output
JLSS adjusts three groups of quantities, and its name refers to learning the smoothing scale and step size jointly. These are the input-channel smoothing vector, the activation steps at token positions, and the weight steps at output channels. Calibration begins with a smoothing pass on the linear layers, using a small collection of images. This provides a starting distribution in which the prominent activation channels have already been rescaled.
The next stage uses a grid search to initialize the activation and weight steps. For a candidate activation step, the authors compare the FP16 activations of a layer with their reconstructed quantized values. They use L2 distance, which measures the size of the difference across the array. The search for weight steps uses the corresponding comparison between the original and quantized weights. At a fixed bit width, trying different steps also changes how much of the tail lies within the representable range. The selected truncation therefore reflects reconstruction error on the calibration data.
The grid search is local to the tensors of a layer. JLSS then changes the unit of comparison to an entire block. The quantized block processes calibration data, and its output is compared with the FP16 block output using cosine similarity. This measure compares the direction of the output feature arrays when treated as vectors. The optimization seeks closer agreement under that measure. Agreement at the block output can depend on how errors from several internal operations interact, which gives this objective a different role from the earlier L2 comparisons.
The authors tune blocks in sequence, starting towards the input and proceeding to later blocks. During this gradient-based stage, the integer weight codes stay fixed. Learning updates the smoothing scale and the two types of step size. That restriction is consistent with the paper's use of a pretrained checkpoint and its objective of keeping conversion inexpensive. It also distinguishes this procedure from changing the integer code assigned to each learned weight throughout the tuning stage.
For image classification, the calibration set comprises 256 images randomly drawn from the ImageNet-1K training split. For object detection and instance segmentation, the authors draw 16 images from the MSCOCO-2017 training split. They reuse the task-specific calibration sets across configurations to reduce variation due to image selection. For the detection and segmentation setup, they tune both smoothing and step sizes at a learning rate of 1e-5 for 10 epochs at W8A8. At W6A6 and W4A4, they use a learning rate of 1e-4 for 50 epochs. The terminology W8A8 denotes 8-bit weights and 8-bit activations. The same naming convention applies at the other bit widths.
Classification settings depend on the backbone and bit width. For Vim-Ti, for instance, the appendix lists 10 epochs at 8-bit, 50 at 6-bit, and 100 at 4-bit. The initialization exponent and learning rates are also recorded by configuration. The authors start from official pretrained checkpoints from Vision Mamba, VMamba, and LocalMamba. They release the implementation in the official ptq4vm repository.
Run the projections with integer matrix multiplication
The CUDA implementation handles activation smoothing, activation quantization, integer matrix multiplication, and dequantization. The weight codes are prepared and stored in advance. At inference, the activation smoothing stage loads the scaling vector into shared memory and applies the relevant factor to each activation channel. The next stage maps the FP16 activations to integer codes using the calibrated settings.
For INT4, the implementation packs adjacent codes into the INT8 storage type available to it in PyTorch. The appendix illustrates the packing operation with this expression.
packedData = (data[1] ≪ 4) | (data[0] & 15)
The variable data contains the adjacent quantized values, and data[1] and data[0] select them. The symbol ≪ denotes a left bit shift. The shift by 4 places data[1] in the upper part of the packed byte. The bitwise AND operator &, with the mask 15, takes the lower part of data[0]. The bitwise OR operator | combines the two fields into packedData.
The implementation uses CUTLASS Tensor Core operations for the INT4 and INT8 matrix products. For the output scales, it combines the weight and activation step vectors to obtain the factor associated with each output entry. The appendix describes using CUBLAS for this scaling calculation and shared memory when applying the factors to the output. The kernel design makes clear what static calibration saves during a forward pass. Activations still have to be transformed and represented as integer codes, but the step size can be obtained from the position instead of being estimated from the current activation values.
Experiments and results
The comparison separates quality from elapsed time
The paper evaluates image classification on the ImageNet-1K validation split. Top-1 accuracy measures how often the highest-ranked predicted class is correct. The comparison covers Vision Mamba, VMamba, and their local variants, with several backbone sizes and versions with and without a CLS token. Each backbone has an FP16 reference from its pretrained checkpoint. The quantized comparisons use MinMax, SmoothQuant, and PTQ4VM with the same nominal bit width for both weights and activations in a given setting.
The object detection and instance segmentation experiment uses the official Mask R-CNN checkpoint with a VMamba-T backbone and the 3X MS training schedule. Quantization is applied to the backbone. The evaluation uses images cropped to 1280 × 800, which fixes the input geometry for PTS. The paper reports box average precision for detection and mask average precision for instance segmentation. These metrics refer to different outputs, so the corresponding scores are reported separately.
Hardware timing is a separate comparison. It asks how fast a specific implementation runs with a particular activation granularity on a single GPU. Accuracy can show whether a setting is useful, but a strong accuracy score by itself says little about the cost of computing token ranges during inference. Conversely, a quick per-tensor implementation can have an impractical accuracy score at the same bit width. The joint reading of the tables is central to the paper's claim.
Classification at moderate and low precision
At W8A8, the contrast between the methods depends strongly on the backbone. On Vim-Ti, MinMax yielded 57.8% top-1 accuracy, SmoothQuant reached 74.7%, and PTQ4VM reached 75.8%, with 76.1% for FP16. This is a case in which conventional quantization gives up substantial accuracy even at the higher of the tested integer precisions. The channel treatment in SmoothQuant recovers much of it. The additional position-specific calibration and range tuning in PTQ4VM move the score closer to the FP16 reference.
Vim-S is more tolerant of W8A8. Its ImageNet-1K validation accuracy is 79.4% with MinMax and 80.1% with SmoothQuant. PTQ4VM and the FP16 checkpoint both give 80.5%. At W6A6, the approaches spread out more sharply. MinMax scores 27.3%, SmoothQuant gives 73.7%, and PTQ4VM reaches 79.7%. The comparison shows how a method that works well with the larger number of available codes can become sensitive when the grid is made coarser.
The separation is still larger at W4A4. Vim-S provides a direct example of both the advantage and the remaining loss. PTQ4VM retains substantial recognition ability while the two baseline scores are very low. The distance from the FP16 reference remains visible in the same comparison.
Vim-S top-1 accuracy on the ImageNet-1K validation set
PTQ4VM retains much more classification accuracy than the other quantizers at the tested low precision.
The numbers
| System or setting | top-1 accuracy % |
|---|---|
| FP16 reference | 80.5 |
| MinMax W4A4 | 0.1 |
| SmoothQuant W4A4 | 0.2 |
| PTQ4VM W4A4 (this paper) | 69.6 |
Vim-B illustrates why the outcome should be read backbone by backbone. Its FP16 reference is 81.9%. At W8A8, MinMax gives 75.8%, SmoothQuant gives 79.9%, and PTQ4VM gives 80.3%. At W6A6, the respective results are 0.5%, 52.3%, and 79.7%. At W4A4, PTQ4VM gives 55.6%, and each baseline gives 0.1%. The authors associate Vim-B's difficulty with activation outliers whose magnitudes exceed 20K. Its stronger FP16 accuracy therefore comes with a distribution that is harder to preserve at the lowest tested precision. Vim-B and Vim-S obtain the same reported PTQ4VM result of 79.7% at W6A6, while their W4A4 outcomes differ markedly.
The contrast within LocalVim also helps put the CLS issue in perspective. LocalVim-T † starts at 78.1% in FP16 and reaches 77.6% with PTQ4VM at W8A8. At W6A6, the dagger variant gives 42.4% with MinMax, 52.6% with SmoothQuant, and 76.1% with PTQ4VM. LocalVim-T without the CLS token starts at 76.2% in FP16 and reaches 75.7% with PTQ4VM at W6A6. Its MinMax and SmoothQuant results at that precision are 62.2% and 65.5%. Both variants benefit from the proposed method, with a different starting point and a different pattern of degradation under the baselines. At W4A4, their PTQ4VM results are 53.7% for LocalVim-T † and 67.2% for LocalVim-T.
VMamba retains more accuracy at the lowest precision
The VMamba family has smaller activation ranges in the authors' observations. The paper suggests that this may be connected to the architecture's lack of the gating functions found in other backbones. Its W8A8 results are generally close to FP16. On VMamba-T, the reference and all three quantization methods are reported at 82.6% on the ImageNet-1K validation split. On VMamba-B, the exact table entries show small differences. The reference and PTQ4VM give 83.9%, SmoothQuant gives 83.8%, and MinMax gives 83.6%.
At W6A6, VMamba-S is an exception to a simple ranking in which PTQ4VM always leads. SmoothQuant matches the FP16 result at 83.6%, and PTQ4VM gives 83.5%. MinMax gives 82.8%. On VMamba-B at the same precision, MinMax falls to 73.9%, SmoothQuant gives 83.3%, and PTQ4VM gives 83.8%. These rows help identify where the extra calibration matters and where a simpler baseline is already close to the reference.
At W4A4, even the smaller activation ranges of VMamba leave the baselines vulnerable. VMamba-T gives 1.2% with MinMax, 1.7% with SmoothQuant, and 80.6% with PTQ4VM. On VMamba-S the corresponding values are 1.1%, 4.5%, and 82.3%. On VMamba-B they are 0.3%, 1.2%, and 82.8%. For the local counterpart LocalVMamba-S, the FP16 reference is 83.7%. At W4A4, MinMax produces 2.5%, SmoothQuant produces 12.0%, and PTQ4VM yields 81.2%. The pattern across these checkpoints is consistent with aggressive quantization requiring a combination of channel treatment, token-specific settings, and range tuning.
Detection and segmentation with a quantized backbone
For the Mask R-CNN system with VMamba-T, the FP16 reference is 47.0 box AP and 42.3 mask AP on the paper's MSCOCO-2017 evaluation. PTQ4VM reports those same values at W8A8. MinMax and SmoothQuant both give 46.9 box AP and 42.2 mask AP at that precision. As in classification, the higher integer precision leaves these methods close on this particular backbone.
At W6A6, MinMax gives 46.2 box AP and 41.5 mask AP. SmoothQuant gives 45.5 box AP and 40.9 mask AP. PTQ4VM reaches 46.7 box AP and 42.1 mask AP. The authors interpret the ordering of the baselines as a consequence of what smoothing does to the weights. Reducing the activation outliers can increase the range the weight quantizer has to handle. The scores establish that the combination used by PTQ4VM does better in this setup. The proposed explanation for the baseline ordering concerns how that tradeoff works inside the quantizer.
The W4A4 results show a larger distinction. PTQ4VM records 43.5 box AP and 39.4 mask AP, while the baseline scores for both tasks are close to zero. This demonstrates that the quantized backbone can still provide features useful to downstream prediction at this precision. It also shows a decline from the FP16 reference on both metrics. In the qualitative comparison at W6A6, the authors show examples of detections and instance masks that retain small visual details. The measurements of box and mask AP establish the aggregate results, while the images illustrate the kinds of outputs those scores represent.
VMamba-T detection box AP on MSCOCO-2017 by quantization method
PTQ4VM preserves substantial detection performance at a precision where both baselines largely fail.
The numbers
| System or setting | box AP |
|---|---|
| FP16 reference | 47.0 |
| MinMax W4A4 | 0.3 |
| SmoothQuant W4A4 | 0.5 |
| PTQ4VM W4A4 (this paper) | 43.5 |
End-to-end timing on the RTX 3090
The timing experiment compares per-tensor static activation settings, per-token dynamic settings, and PTS. The authors use SmoothQuant in these comparisons and time W4A4 inference against FP16. Every timing measurement uses a batch size of 32 on one RTX 3090. The appendix reports a warm-up of 100 iterations, followed by 100 inference measurements. The table reports the median latency. This procedure gives an estimate of repeated inference after the initial overhead on the tested hardware.
VMamba-B provides the paper's headline result. Its FP16 latency is 165.18 ms. The W4A4 dynamic per-token configuration takes 114.87 ms and has a reported speedup of 1.44×. PTS takes 90.30 ms and has a reported speedup of 1.83×. The per-tensor static version has the lowest latency in this comparison, at 89.93 ms and a speedup of 1.84×. The small gap between the two static configurations is evidence that retaining a distinct scale for every position adds little latency here. The reason to prefer PTS within the paper's method is its much stronger accuracy at the low precision, rather than a claim that it wins the latency comparison by itself.
VMamba-B end-to-end latency on RTX 3090 at batch size 32
PTS approaches the latency of per-tensor static quantization and runs faster than the dynamic per-token setting.
The numbers
| System or setting | ms |
|---|---|
| FP16 reference | 165.18 |
| Per-tensor static W4A4 | 89.93 |
| Per-token dynamic W4A4 | 114.87 |
| PTS W4A4 (this paper) | 90.30 |
The other backbones underline the dependence on architecture. For VMamba-T, FP16 takes 60.33 ms and PTS takes 34.00 ms, reported as a 1.77× speedup. The corresponding dynamic setting takes 44.13 ms. For Vim-Ti, the FP16 time is 37.86 ms, PTS takes 32.74 ms, and the dynamic setting takes 39.15 ms. The reported PTS speedup there is 1.16×. Vim-B gives 219.48 ms in FP16 and 157.03 ms with PTS, for a 1.40× speedup. A similar range-setting strategy can therefore yield different end-to-end gains depending on the contribution of the linear layers and the overheads that remain.
The paper's profiling figure links the VMamba-B speedup to a reduction in time spent on the linear operations under W4A4. The table measures the whole backbone, so the result includes the parts that the method leaves at their original precision. Keeping these levels of measurement distinct makes the claim more concrete. The paper demonstrates a faster executable backbone under the stated settings, and the profiling explains which class of operation accounts for the improvement.
What the ablations show
The choice of quantization target comes first
The authors test what happens when they quantize different parts of Vim-Ti to INT8. The FP16 top-1 accuracy is 76.1%. Quantizing only the hidden state gives 6.8%, while the conventional setting that quantizes only the linear layers gives 57.8%. Given the different computational roles of these targets, the comparison supports spending the calibration effort on the projections. The scan already has an implementation designed to reduce memory bottlenecks, and the hidden-state experiment shows a severe accuracy cost for the form of state quantization tested here.
A companion comparison isolates the classification token. Starting from the INT8 linear-layer baseline at 57.8%, the authors retain the CLS token in FP16 and observe 73.6% top-1 accuracy. The reference is again 76.1%. This intervention shows that a large part of the original damage is tied to how the baseline represents the classification token. It complements the activation plots. Those plots establish that the CLS values tend to be small, and the precision intervention shows that preserving them has a substantial effect on the classification result.
PTS takes a different approach from keeping that token in FP16. It gives the position its own grid while still representing its activations at the selected integer precision. The intervention also helps explain why smoothing can be insufficient on its own. Changing all values in a channel can help with extreme magnitudes, but the CLS token still needs adequate resolution relative to the other tokens. Its role as the readout for classification gives a local representation error a direct route to the final score.
Static token ranges recover much of the dynamic result
The paper compares per-tensor static, per-token dynamic, and PTS activation schemes on Vim-S and VMamba-S. In the granularity table, Vim-S gives 0.2% top-1 accuracy with per-tensor static quantization, 72.6% with per-token dynamic quantization, and 69.6% with PTS. VMamba-S gives 4.5%, 82.4%, and 82.3% in the same order. The dynamic method leads the two accuracy comparisons. PTS is close to it on VMamba-S, while the difference is more visible on Vim-S. Together with the timing experiment, this is evidence for an accuracy and latency tradeoff rather than a universal ranking of the granularity choices.
There is an inconsistency in the label of the granularity table. Its caption calls the comparison INT8, while the per-tensor static and PTS entries for these backbones coincide with the corresponding W4A4 SmoothQuant and PTQ4VM scores in the main classification table. The timing table explicitly identifies its integer setting as W4A4. The granularity scores support the stated comparison among schemes as published, but the caption and matching main-table scores leave the bit width of that accuracy comparison ambiguous.
Truncation makes a large difference before joint tuning
The main component ablation starts with SmoothQuant and then adds PTS, grid-search truncation, and JLSS. These are cumulative comparisons. Each row answers what changes when the next component is added to the earlier configuration. The design is particularly informative at W4A4, where several changes that have little effect at W8A8 become important.
For Vim-Ti at W6A6, the SmoothQuant starting point is 54.5% ImageNet-1K top-1 validation accuracy. Adding PTS raises it to 71.6%. Grid-search truncation gives 72.2%, and JLSS brings the result to 73.9%. At W8A8, the corresponding values are 74.7%, 75.7%, 75.8%, and 75.8%. The clearest effect of adding position-specific ranges in this pair of settings is at W6A6. By W8A8, each of the later configurations is already close to the 76.1% FP16 reference.
At W4A4, the same Vim-Ti sequence begins at 0.1% with SmoothQuant. Adding PTS gives 5.4%. Truncation then gives 46.4%, and the final JLSS step reaches 56.4%. The result clarifies the difference between selecting a grid for each token and deciding where that grid should end. Position-specific allocation helps, but at the lowest precision a range can still spend most of its representational capacity on its tail. The grid search makes a much larger improvement in this setting because it explicitly balances saturation of extreme values against resolution for the dense part of the distribution.
VMamba-T shows that the same issue extends beyond backbones with a CLS token. Its W4A4 top-1 accuracy is 1.7% with SmoothQuant, 19.8% after PTS, 73.3% after grid-search truncation, and 80.6% after JLSS. At W6A6, the sequence reads 81.8%, 82.2%, 82.3%, and 82.4%. At W8A8, all of those configurations give 82.6%, which is also the FP16 value. The truncation and tuning story in this backbone is mostly a story about how to use very few codes. With the larger grids, the classification metric leaves little room for a visible gain.
The final increment in each series evaluates joint block-level tuning on top of the initialized system. It supports improving the calibrated grids and smoothing scales together after the grid search. Since the final increment changes several quantities and moves to an output-level objective, the scores do not estimate how much of that gain comes from allowing each parameter to move independently. What the ablation directly measures is the benefit of the complete tuning stage under the preceding calibration choices.
The activation plots test the reach of the diagnosis
The additional plots examine output projections at other depths in Vim-Ti. They also show activation distributions in VMamba-T, the two LocalVim-T variants, and LocalVMamba-S. Most of the cross-backbone illustrations use input activations at an output projection. For LocalVMamba-S, the paper uses the projection denoted dt proj. The plots of the distribution along token positions in the appendix use 32 randomly sampled images.
These visualizations show that the diagnosis extends beyond the first illustrated Vim-Ti layer and beyond systems with a CLS token. They also preserve important differences in magnitude between backbones. The authors' account links greater token imbalance to later blocks and suggests a cumulative effect as information passes through the network. The visualization supports the observation that patterns change with depth. The component ablations and the classification-token intervention supply the separate task-level evidence that the observed distributions matter for quantization.
Limitations
Limits identified by the authors
The authors recognize that the activation distribution can remain difficult even after calibration. Vim-B is the clearest example. They report very large outliers and observe that the backbone's advantages at full precision do not carry through uniformly to low precision. At W4A4, the Vim family retains much more accuracy with PTQ4VM than with the baselines, while some of those results remain well below FP16. The near-lossless results belong to particular combinations of architecture, precision, and task. The reported numbers support that narrower interpretation of the overall quality claim.
The paper also treats the selective scan and reshape stages as outside its practical acceleration target. The scan already uses a memory-conscious implementation, and the hidden-state experiment reveals strong sensitivity to the quantization applied there. Reshapes serve data-layout and scan-order needs. The measurements therefore support acceleration through low-precision projections within a mixed execution path. A system in which projections account for less of the original latency has less opportunity to benefit from the same kernel changes.
PTS requires a known correspondence between a sequence position and its stored quantization parameters. The authors point to fixed input size as what makes that choice possible. For detection and segmentation, they make the constraint concrete by cropping inputs to 1280 × 800. The reported outcome establishes that PTS can work for that configured geometry and calibration procedure. Different sequence lengths or a changed scan layout would require a way to associate those new positions with suitable calibration settings.
Limits visible in the evaluation
The downstream experiments use one backbone and one official Mask R-CNN configuration, with quantization confined to the backbone. The results show that detection and mask prediction can tolerate the resulting feature approximation in that setup. They leave the sensitivity of the remaining components open, along with performance under other backbone and prediction-head combinations. Classification covers a broader range of Visual Mamba checkpoints, but uses one validation benchmark. The depth of the classification evidence and the breadth of the downstream claim should be read accordingly.
The timing measurements concern a single RTX 3090 and a batch size of 32, with the specific CUDA kernels described in the paper. Changing the hardware, the input shape, or the batch size can change the relative costs of smoothing, quantization, integer multiplication, and data rearrangement. The paper measures latency and gives a component profile for the tested implementation. It does not supply corresponding measurements of energy or memory use from which to quantify those benefits. The headline speedup is an end-to-end latency result in the stated setup.
The calibration data are small and sampled from the training splits of the datasets used for the tasks. Reusing the same images makes comparisons less sensitive to differences in which samples each method sees. It leaves open how sensitive a fixed per-token range is to the choice of sample or to a change in the input distribution. The displayed activation patterns suggest that calibration can exploit a recurring positional structure. They do not measure how stable every learned range would be across different image sources or calibration draws.
The causal explanation of the activation patterns also has a specific evidential scope. The authors observe recurring magnitudes under fixed scans, compare architectures and layers, and show that changing quantization granularity affects accuracy. A separate controlled training comparison that changes only the scan order would be needed to isolate how much of the pattern comes from order itself. Similarly, the contrast between VMamba and the Vim family suggests a role for gating and CLS tokens, while the architectures differ in several respects. The strongest direct evidence about the CLS token comes from the experiment that preserves it in FP16 within Vim-Ti.
Finally, the detailed component ablation is conducted on Vim-Ti and VMamba-T. It establishes how the successive additions behave in those two backbones. The broader classification comparison shows the performance of the full procedure elsewhere. It leaves the precise contribution of each calibration stage in the other checkpoints unmeasured. This distinction matters most when using the paper to explain why an individual backbone either holds up or deteriorates at W4A4.
What came after
There are no documented follow-up studies to discuss here, so how later work adopted or extended PTQ4VM remains open.
Cite
Cite as Younghyun Cho, Changhun Lee, Seonggon Kim and Eunhyeok Park. 2024. PTQ4VM: Post-Training Quantization for Visual Mamba. arXiv:2412.20386.
@misc{cho2024ptq4vm,
title = {{PTQ4VM: Post-Training Quantization for Visual Mamba}},
author = {Younghyun Cho, Changhun Lee, Seonggon Kim and Eunhyeok Park},
year = {2024},
doi = {10.48550/arxiv.2412.20386},
eprint = {2412.20386},
archivePrefix = {arXiv},
url = {https://doi.org/10.48550/arxiv.2412.20386}
}This page in Markdown https://md.research.elamur.ai/free/en/papers/cho-2024-ptq4vm-post-training-quantization-visual/