FIT: A M ETRIC FOR M ODEL S ENSITIVITY
Anonymous authors
Paper under double-blind review
A BSTRACT
Model compression is vital to the deployment of deep learning on edge devices.
Low precision representations, achieved via quantization of weights and activations, can reduce inference time and memory requirements.
However, quantifying and predicting the response of a model to the changes associated with this procedure remains challenging.
This response is non-linear and heterogeneous throughout the network.
Understanding which groups of parameters and activations are more sensitive to quantization than others is a critical stage in maximizing efficiency.
For this purpose, we propose FIT.
Motivated by an information geometric perspective,
FIT combines the Fisher information with a model of quantization.
We find that FIT can estimate the final performance of a network without retraining.
FIT effectively fuses contributions from both parameter and activation quantization into a single metric.
Additionally, FIT is fast to compute when compared to existing methods, demonstrating favourable convergence properties.
These properties are validated experimentally across hundreds of quantization configurations, with a focus on layer-wise mixed-precision quantization.
I NTRODUCTION
The computational costs and memory footprints associated with deep neural networks (DNN) hamper their deployment to resource-constrained environments like mobile devices (Ignatov et al., 2018), self-driving cars (Liu et al., 2019), or high-energy physics experiments (Coelho et al., 2021).
Latency, storage and even environmental limitations directly conflict with the current machine learning regime of performance improvement through scale.
For deep learning practitioners, adhering to these strict requirements, whilst implementing state-of-the-art solutions, is a constant challenge.
As a result, compression methods, such as quantization (Gray & Neuhoff, 1998) and pruning (Janowsky, 1989), have become essential stages in deployment on the edge.
In this paper, we focus on quantization.
Quantization refers to the use of lower-precision representations for values within the network, like weights, activations and even gradients.
This could, for example, involve reducing the values stored in 32-bit floating point (FP) single precision, to
INT-8/4/2 integer precision (IP).
This reduces the memory requirements whilst allowing models to meet strict latency and energy consumption criteria on high-performance hardware such as FPGAs.
Despite these benefits, there is a trade-off associated with quantization.
As full precision computation is approximated with less precise representations, the model often incurs a drop in performance.
In practice, this trade-off is worthwhile for resource-constrained applications.
However, the DNN performance degradation associated with quantization can become unacceptable under aggressive schemes, where post-training quantization (PTQ) to 8 bits and below is applied to the whole network (Jacob et al., 2018).
Quantization Aware Training (QAT) (Jacob et al., 2018) is often used to recover lost performance.
However, even after QAT, aggressive quantization may still result in a large performance drop.
The model performance is limited by sub-optimal quantization schemes.
It is known that different layers, within different architectures, respond differently to quantization (Wu et al., 2018).
Akin to how more detailed regions of images are more challenging to compress, as are certain groups of parameters.
As is shown clearly by Wu et al.
(2018), uniform bit-width schemes fail to capture this heterogeneity.
Mixed-precision quantization (MPQ), where each layer within the network is assigned a different precision, allows us to push the performance-compression trade-off to the limit.
However, determining which bit widths to assign to each layer is non-trivial.
Furthermore, the search space of quantization configurations is exponential in the number of layers and activations.
Existing methods employ techniques such as neural architecture search and deep reinforcement learning, which are computationally expensive and less general.
Methods which aim to explicitly capture the sensitivity (or importance ) of layers within the network, present improved performance and reduced complexity.
In particular, previous works employ the Hessian, taking the loss landscape curvature as sensitivity and achieving state-of-the-art compression.
Even so, many explicit methods are slow to compute, grounded in intuition, and fail to include activation quantization.
Furthermore, previous works determine performance based on only a handful of configurations.
Further elaboration is presented in Section 2.
The Fisher Information and the Hessian are closely related.
In particular, many previous works in optimisation present the Fisher Information as an alternative to the Hessian.
In this paper, we use the
F isher I nformation T race as a means of capturing the network dynamics.
We obtain our final FIT metric which includes a quantization model, through a general proof in Section 3 grounded within the field of information geometry.
The layer-wise form of FIT closely resembles that of Hessian
Aware Quantization (HAWQ), presented by Dong et al.
Our contributions in this work are as follows:
We introduce the Fisher Information Trace (FIT) metric, to determine the effects of quantization.
To the best of our knowledge, this is the first application of the Fisher Information to generate MPQ configurations and predict final model performance.
We show that FIT demonstrates improved convergence properties, is faster to compute than alternative metrics, and can be used to predict final model performance after quantization.
The sensitivity of parameters and activations to quantization is combined within FIT as a single metric.
We show that this consistently improves performance.
We introduce a rank correlation evaluation procedure for mixed-precision quantization, which yields more significant results with which to inform practitioners.
P REVIOUS W ORK
In this section, we primarily focus on mixed-precision quantization (MPQ), and also give context to the information geometric perspective and the Hessian.
Mixed Precision Quantization As noted in Section 1, the search space of possible quantization configurations, i.e. bit setting for each layer and/or activation, is exponential in the number of layers:
O ( |B| 2 L ) , where B is the set of bit precisions and L the layers.
Tackling this large search space has proved challenging, however recent works have made headway in improving the state-of-the-art.
CW-HAWQ (Qian et al., 2020),
AutoQ (Lou et al., 2019) and HAQ (Wang et al., 2019) deploy Deep
Reinforcement Learning (DRL) to automatically determine the required quantization configuration, given a set of constraints (e.g. accuracy, latency or size).
AutoQ improves upon HAQ by employing a hierarchical agent with a hardware-aware objective function.
CW-HAWQ seeks further improvements by reducing the search space with explicit second-order information, as outlined by Dong et al.
The search space is also often explored using Neural Architecture Search (NAS).
For instance, Wu et al.
(2018) obtain 10-20× model compression with little to no accuracy degradation.
Unfortunately, both the DRL and NAS approaches suffer from large computational resource requirements.
As a result, evaluation is only possible on a small number of configurations.
These methods explore the search space of possible model configurations, without explicitly capturing the dynamics of the network.
Instead, this is learned implicitly, which restricts generalisation.
More recent works have successfully reduced the search space of model configurations through explicit methods, which capture the relative sensitivity of layers to quantization.
The bit-width assignment is based on this sensitivity.
The eigenvalues of the Hessian matrix yield an analogous heuristic to the local curvature.
Higher local curvature indicates higher sensitivities to parameter perturbation, as would result from quantization to a lower bit precision.
Choi et al.
(2016) exploit this to inform bit-precision configurations.
Popularised by Dong et al.
, HAWQ presents the following metric, where a trace-based method is combined with a measure of quantization error:
[Equation]
Here, θ l and Q ( θ l ) represent the full precision and model parameters respectively, for each block l of the model.
¯
Tr ( H l ) denotes the parameter normalised Hessian trace.
HAWQ-V
(Dong et al., 2019) used the top eigenvalue as an estimate of block sensitivity.
However, this proved less effective than using the trace as in HAWQ-V2 Dong et al.
The ordering of quantization depth established over the set of network blocks reduces the search space of possible model configurations.
The Pareto front associated with the trade-off between sensitivity and size is used to quickly determine the best MPQ configuration for a given set of constraints.
HAWQ-V3 (Yao et al., 2021) involves integer linear programming to determine the quantization configuration.
Although Dong et al.
(2020) discusses activation quantization, it is considered separately from weight quantization.
In addition, trace computation can become very expensive for large networks.
This is especially the case for activation traces, which require large amounts of GPU memory.
Furthermore, only a handful of configurations are analysed.
Other effective heuristics have been proposed, such as batch normalisation γ (Chen et al., 2021) and quantization (Tang et al., 2022) scaling parameters.
For these intuition-grounded heuristics, it is more challenging to assess their generality.
More complex methods of obtaining MPQ configurations exist.
Kundu et al.
(2021) employ straight-through estimators of the gradient (Hubara et al., 2016) with respect to the bit-setting parameter.
Adjacent work closes the gap between final accuracy and quantization configuration.
In Liu et al.
(2021), a classifier after each layer is used to estimate the contribution to accuracy.
Previous works within the field of quantization have used the Fisher Information for adjacent tasks.
Kadambi (2020), use it as a regularisation method to reduce quantization error, whilst it is employed by Tu et al.
as a method for computing importance rankings for blocks/parameters.
In addition,
Li et al.
(2021) use the Fisher Information as part of a block/layer-wise reconstruction loss during
Connections to the loss landscape perspective Gradient preconditioning using the Fisher Information Metric (FIM) - the Natural Gradient - acts to normalise the distortion of the loss landscape.
This information is extracted via the eigenvalues which are characterised by the trace.
This is closely related to the Hessian matrix (and Netwon’s method).
The two coincide, provided that the model has converged to the global minimum θ ∗ , and specific regularity conditions are upheld (Amari, 2016) (see Appendix G.3).
The Hessian matrix H is derived via the second-order expansion of the loss function at a minimum.
Using it as a method for determining the effects of perturbations is common.
The FIM is more general, as it is yielded (infinitesimally) from the invariant f-divergences.
As a result, FIT applies to a greater subset of models, even those which have not converged to critical points.
Many previous works have analysed and provided examples for, the relation between second-order information, and the behaviour of the Fisher Information.
(Kunstner et al., 2019; Becker & Lecun, 1989; Martens, 2014; Li et al., 2020).
This has primarily been with reference to natural gradient descent (Amari, 1998), preconditioning matrices, and Newton’s method during optimization.
Recent works serve to highlight the success of the layer-wise scaling factors associated with the Adam optimiser (Kingma & Ba, 2014) whilst moving in stochastic gradient descent (SGD) directions (Agarwal et al., 2020; 2022).
This is consistent with previous work (Kunstner et al., 2019), which highlights the issues associated with sub-optimal scaling for SGD, and erroneous directions for Empirical Fisher (EF)-based preconditioning.
The EF and its properties are also explored by Karakida et al.
It is important to make the distinction that FIT provides a different use case.
Rather than focusing on optimisation, FIT is used to quantify the effects of small parameter movements away from the full precision model, as would arise during quantization.
Additionally, the Fisher-Rao metric has been previously suggested as a measure of network capacity (Liang et al., 2019).
In this work, we consider taking the expectation over this quantity.
From this perspective, FIT denotes expected changes in network capacity as a result of quantization.
M ETHOD
First, we outline preliminary notation.
We then introduce an information geometric perspective to quantify the effects of model perturbation.
FIT is reached via weak assumptions regarding quantization.
We then discuss computational details and finally connect FIT to the loss landscape perspective.
3. P RELIMINARY NOTATION .
Consider training a parameterised model as an estimate of the underlying conditional distribution p ( y | x, θ ) , where the empirical loss on the training set is given by:
L ( θ ) =
1 N (cid:80) Ni =
1 f ( x i , y i , θ ) .
In this case, θ ∈ R w are the model parameters, and f ( x i , y i , θ ) is the loss with respect to a single member z i =
( x i , y i )
∈ R d × Y of the training dataset D
= { ( x i , y i ) } Ni =1 , drawn i.i.d.
from the true distribution.
Consider, for example, the cross-entropy criterion for training given by: f ( x i , y i , θ )
= − log p ( y i | x i , θ ) .
Note that in parts we follow signal processing convention and refer to the parameter movement associated with a change in precision as quantization noise .
3. F ISHER I NFORMATION T RACE (FIT) M ETRIC
Consider a general perturbation to the model parameters: p ( y | x, θ + δθ ) .
For brevity, we denote p ( y | x, ϕ ) as p ϕ .
To measure the effect of this perturbation on the model, we use an f -divergence (e.g. KL, total variation or χ 2 ) between them: D f ( p θ || p θ + δθ ) .
It is a well-known concept in information geometry (Amari, 2016; Nielsen, 2018) that the FIM arises from such a divergence:
D KL
[Equation]
p θ || p θ + δθ ) = 12 δθ T I ( θ ) δθ .
The FIM, I ( θ ) , takes the following form:
[Equation]
In this case, p θ ( x, y ) denotes the fact that expectation is taken over the joint distribution of x and y .
The Rao distance (Atkinson & Mitchell, 1981) between two distributions then follows.
The exact (per parameter) perturbations δθ associated with quantization are often unknown.
As such, we assume they are drawn from an underlying quantization noise distribution, and obtain an expectation of this quadratic differential:
[Equation]
We assume that the random noise associated with quantization is symmetrically distributed around mean of zero: E [ δθ ] = 0 , and uncorrelated:
Cov [ δθ ] =
Diag ( E [ δθ 2 ]) .
This yields the FIT heuristic in a general form:
[Equation]
To develop this further, we assume that parameters within a single layer or block will have the same noise power, as this will be highly dependent on block-based configuration factors.
As a concrete example, take the quantization noise power associated with heterogeneous quantization across different layers, which is primarily dependent on layer-wise bit-precision.
As such, we can rephrase FIT in a layer-wise form:
[Equation]
Where l denotes a single layer/block in a set of L model layers/blocks.
3.2. E XTENDING THE NEURAL MANIFOLD
The previous analysis applies well to network parameters, however, quantization is also applied to the activations themselves.
As such, to determine the effects of the activation noise associated with quantization, we must extend the notion of neural manifolds to also include activation statistics, ˆ a , over the dataset as well.
The general perturbed model is denoted as follows:
p ( y | x, θ + δθ, ˆ a + δ ˆ a ) .
The primary practical change required for this extension involves taking derivatives w.r.t.
activations rather than parameters - a feature which is well supported in deep learning frameworks (see Appendix C for activation trace examples).
After which, the expectation is taken over the data.
Once again, this change is simple, as the empirical form of the Fisher Information requires a similar approximation (Section 3.3, and the two can be computed at the same time.
Having considered the quantization of activations and weights within the same space, these can now be meaningfully combined in the FIT heuristic.
This is illustrated in Section 4.
3. C OMPUTATIONAL DETAILS
The empirical form of FIT can be obtained via approximations of E [ δθ 2 ] l and Tr ( I ( θ l )) .
The former requires either a Monte-Carlo estimate, or an approximate noise model (see Appendix F), whilst the latter requires computing the Empirical Fisher (EF): ˆ I ( θ ) .
This yields the following form:
[Equation]
Kunstner et al.
(2019) illustrates the limitations, as well as the notational inconsistency, of the EF, highlighting several failure cases when using the EF during optimization.
Recall that the FIM involves computing expectation over the joint distribution of x and y .
We do not have access to this distribution, in fact, we only model the conditional distribution.
This leads naturally to the notion of the EF:
[Equation]
The EF trace is far less computationally intensive than the Hessian matrix.
Previous methods (Dong et al., 2020; Yao et al., 2021; Yu et al., 2022) suggested the use of the Hutchinson algorithm (Hutchinson, 1989).
The trace of the Hessian is extracted in a matrix-free manner via zero-mean random variables with a variance of one:
Tr ( H ) ≈ 1 m (cid:80) mi =1 r Ti Hr i , where m is the number of estimator iterations.
It is common to use Rademacher random variables r i ∈ {− 1 , 1 } .
First, the above method requires a second backwards pass through the network for every iteration.
This is costly, especially for DNNs with many layers, where the increased memory requirements associated with storing the computation graph become prohibitive.
Second, the variance of each estimator can be large.
This is given by: V [
[Equation]
Appendix G.4).
Even for the Hessian, which has a high diagonal norm, this variance can still be large.
This is validated empirically in Section 4.
In contrast, the EF admits a simpler form (see Appendix G.4):
[Equation]
The convergence of this trace estimator improves upon that of the Hutchinson estimator in having lower variance.
Additionally, the computation is faster and better supported by deep learning frameworks: its computation can be performed with a single network pass, as no second derivative is required.
A similar scheme is used in the Adam optimizer (Kingma & Ba, 2014), where an exponential moving average is used.
Importantly, the EF trace estimation has a more model-agnostic variance, also validated in Section 4.
E XPERIMENTS
We perform several experiments to determine the performance of FIT.
First, we examine the properties of FIT, and compare it with the commonly used Hessian.
We show that FIT preserves the relative block sensitivities of the Hessian, whilst having significantly favourable convergence properties.
Second, we illustrate the predictive performance of FIT, in comparison to other sensitivity metrics.
We then show the generality of FIT, by analysing the performance on a semantic segmentation task.
Finally, we conclude by discussing practical implications.
4. C OMPARISON WITH THE H ESSIAN
To evaluate trace performance and convergence in comparison to Hessian-based methods, we consider several computer vision architectures, trained on the ImageNet (Deng et al., 2009) dataset.
We first illustrate the similarity between the EF trace and the Hessian trace and then illustrate the favourable convergence properties of the EF.
Further analysis for BERT on SST-2 is given in Appendix A.
Trace Similarity.
Figure 1 shows that the EF preserves the relative block sensitivity of the Hessian.
Substituting the EF trace for the Hessian will not affect the performance of a heuristic-based search algorithm.
Additionally, even for the Inception-V3 trace in Figure 1(d), the scaling discrepancy would present no change in the final generated model configurations because heuristic methods (which search for a minimum) are scale agnostic.
[Figure]
Convergence Rate.
Across all models
[Table]
the variance associated with the EF trace is orders of magnitude lower than that of the Hessian trace, as shown in Table 1.
This is made clear in Figure
[Table]
where the EF trace stabilises in far fewer iterations than the Hessian.
The analysis in Section
[Table]
where we suggest that the EF estimation process has lower variance and converges faster, holds well in practice.
Importantly, whilst the Hessian variance shown in Table 1 is very model dependent
[Table]
the EF trace estimator variance is more consistent across all models.
These results also hold across differing batch sizes (see Appendix D).The results of this favourable convergence are illustrated in Table 1.
For fixed tolerances, the model agnostic behaviour, faster computation, and lower variance, all contribute to a large speedup
[Table]
4. F ROM FIT TO A CCURACY
In this section, we use correlation as a novel evaluation criterion for sensitivity metrics, used to inform quantization.
Strong correlation implies that the metric is indicative of final performance, whilst low correlation implies that the metric is less informative for MPQ configuration generation.
In this MPQ setting, FIT is calculated as follows (Appendix F):
[Equation]
Each bit configuration - { b l } L 1 - yields a unique FIT value from which we can estimate final performance.
The space of possible models is large, as outlined in Section 2, thus we randomly sample configuration space.
100 CNN models, with and without batch-normalisation, are trained on the
Cifar-10 and Mnist datasets, giving a total of 4 studies.
[Figure]
Comparison Metrics.
As noted in Section 2 previous works (Kundu et al., 2021; Liu et al., 2021; Tang et al., 2022) provide layer-wise heuristics with which to generate quantization configurations.
This differs from FIT, which yields a single value.
These previous methods are not directly comparable.
However, we take inspiration from Chen et al.
; Tang et al.
(2022), using the quantization ranges (QR: | θ max − θ min | ) as well as the batch normalisation scaling parameter (BN: γ ) (Ioffe & Szegedy, 2015), to evaluate the efficacy of FIT in characterising sensitivity.
In addition to these, we also perform ablation studies by removing components of FIT, resulting in
FIT W , FIT A , and the isolated quantization noise model, i.e. E [ δθ 2 ] .
Note that we do not include
HAWQ here as it generates results equivalent to FIT W .
Equations for these comparison heuristics are shown in Appendix E.
This decomposition helps determine how much the components which comprise FIT contribute to its overall performance.
[Table]
quantization experiment.
W/A subscript indicates using only either weights or activations.
BN indicates the presence of batch-normalisation within the architecture.
Figure 3 and Table 2 show the plots and rank-correlation results across all datasets and metrics.
From these results, the key benefits of FIT are demonstrated.
FIT correlates well with final model performance.
From Table 2, we can see that FIT has a consistently high rank correlation coefficient, demonstrating its application in informing final model performance.
Whilst other methods vary in correlation, FIT remains consistent across experiments.
FIT combines contributions from both parameters and activations effectively.
We note from
Table 2, that combining FIT W and FIT A consistently improves performance.
The same is not the case for QR.
Concretely, the average increase in correlation with the inclusion of FIT A is 0.12, whilst for QR A , the correlation decreases on average by 0.02.
FIT scales the combination of activation and parameter contributions correctly, leading to a consistent increase in performance.
Furthermore, from Table 2 we observe that the inclusion of batch-normalisation alters the relative contribution from parameters and activations.
As a result, whilst FIT combines each contribution effectively and remains consistently high, QR does not.
[Figure]
4. S EMANTIC S EGMENTATION
In this section [Figure] we illustrate the ability of FIT to generalise to larger datasets and architectures, as well as more diverse tasks.
We choose to quantify the effects of MPQ on the U-Net architecture (Ronneberger et al., 2015), for the Cityscapes semantic segmentation dataset (Cordts et al., 2016) [Figure]
Additional analysis of BERT on SST-2 is shown in Appendix A.
In this experiment, we trainmodels with randomly generated bit configurations for both weights and activations.
For evaluation, we use Jaccard similarity, or more commonly, the mean Intersection over Union (mIoU).
The final correlation coefficient is between FIT and mIoU. EF trace computation is stopped at a tolerance of 0 .
01 , occurring at 82 individual iterations.
The weight and activation traces for the trained, full precision, U-Net architecture is shown in Figure 4.
Figure 4(c) shows the correlation between FIT and final model performance for the U-Net architecture on the Cityscapes dataset.
In particular, we obtain a high final rank correlation coefficient of 0.86 .
[Figure]
4. F URTHER PRACTICAL DETAILS Small perturbations
In Section 3, we assume quantization noise, δθ , is small with respect to the parameters themselves.
This allows us to reliably consider a second-order approximation of the divergence.
In Figure 5, we plot every parameter within the model for every single quantization configuration from experiment A.
Almost all parameters adhere to this approximation.
We observe that our setting covers most practical situations, and we leave characterising more aggressive quantization (1/2 bit) to future work.
Distributional shift
Modern DNNs often over-fit to their training dataset.
More precisely, models are able to capture the small distributional shifts between training and testing subsets.
FIT is computed from the trained model, using samples from the training dataset.
As such, the extent to which FIT captures the final quantized model performance on the test dataset is, therefore, dependent on model over-fitting.
Consider for example
dataset D.
We observe a high correlation of 0.98 between FIT and final training accuracy, which decreases to 0.90 during testing .
This is further demonstrated in Figure 5.
For practitioners, FIT is more effective where over-fitting is less prevalent.
[Figure]
C ONCLUSION
In this paper, we introduced FIT, a metric for characterising how quantization affects final model performance.
Such a method is vital in determining high-performing mixed-precision quantization configurations which maximise performance given constraints on compression.
We presented FIT from an information geometric perspective, justifying its general application and connection to the Hessian.
By applying a quantization-specific noise model, as well as using the empirical fisher, we obtained a well-grounded and practical form of FIT.
Empirically, we show that FIT correlates highly with final model performance, remaining consistent across varying datasets, architectures and tasks.
Our ablation studies established the importance of including activations.
Moreover, FIT fuses the sensitivity contribution from parameters and activations yielding a single, simple to use, and informative metric.
In addition, we show that FIT has very favourable convergence properties, making it orders of magnitude faster to compute.
We also explored assumptions which help to guide practitioners.
Finally, by training hundreds of MPQ configurations, we obtained correlation metrics from which to demonstrate the benefits of using FIT.
Previous works train a small number of configurations.
We encourage future work in this field to replicate our approach, for meaningful evaluation.
Future Work.
Our contribution, FIT, worked quickly and effectively in estimating the final performance of a quantized model.
However, as noted in Section 4, FIT is susceptible to the distributional shifts associated with model over-fitting.
In addition, FIT must be computed from the trained , full-precision model.
We believe dataset agnostic methods provide a promising direction for future research, where the MPQ configurations can be determined from initialisation.
R EPRODUCIBILITY S TATEMENT
We have included sample code for generating the parameter and activation traces, as well as generating and analysing quantized models.
Further experimental details are presented in Appendix E. Relevant complete proofs are shown in Appendices F and G. A A DDITIONAL E XPERIMENTS : BERT ON SST-  [Table] [Figure]
[Table]
[Figure]
This section extends our experimental evaluation of FIT to other challenging datasets and benchmarks. Notably, we focus on quantizing BERT-base Devlin et al. (2018) for the SST-2 dataset Socher et al. BERT-base is quantized via layer-wise mixed precision simulated asymmetric quantization of weights and activations.
We chose 50 distinct MPQ configurations for BERT on SST-2 across a range of bit precisions [2,3,4,6,8].
We obtain a final correlation score of 0.752 between post-fine-tuning accuracy and FIT score for these MPQ configurations.
Similar to other experiments, this demonstrates that FIT has an excellent predictive power of the impact of quantization, even for large and deep models such as BERT.
To illustrate a use case for FIT, Figures 6 and 7 show highly non-trivial MPQ configurations compared to the uniform baseline methods constrained by operations (BOPs).
In this case, we obtain higher MPQ accuracy at comparable BOPs, showing the superior performance of
FIT in selecting high-performing MPQ configurations.
Notably, FIT can trade off with any arbitrary hardware constraint (e.g. latency, power), making it very flexible.
From a computational perspective, given a batch size of 256, FIT converged with a variance of 0.
in very few iterations.
Conversely, the Hessian trace method could not properly converge even after 200 iterations, which is reflected in a variance of 5256.
This granularity of layer-wise quantization renders Hessian-based methods challenging to use in practice.
The EF traces for the weights and activations of BERT are shown in Figure 8.
[Figure]
B Q UANTIZATION A WARE T RAINING (QAT)
Quantization can lead to significant performance degradation Gholami et al.
It is, therefore, necessary to perform additional quantization aware training (QAT) in order to recover this lost performance.
QAT involves simulating the effects of quantization during training.
The quantization function Q ( θ ) is applied to the floating point parameter values during the forward pass of the network.
Q ( θ ) is piece-wise flat.
As a result, to propagate gradients, we use a straight-through estimator (STE) (Hubara et al., 2016).
In effect, this bypasses the quantization function during gradient computation in the backwards pass.
Figure 9 illustrates this process.
QAT also involves learning the quantization ranges.
For weights, a max-min approach is taken, whilst for activations, an exponential moving average is used.
As a result, the scaling and zero points for quantization are mapped correctly.
In addition, batch-normalisation parameters can be folded into weights for efficiency.
B. F URTHER Q UANTIZATION D ETAILS
During our experiments, we employ layer-wise symmetric/asymmetric simulated quantization.
In addition, layer-wise quantization ranges are accumulated for a short period (30 iterations) at the beginning of QAT to accurately tune the quantization function across the expected range.
Note that this is particularly important for activation quantization.
As a result of the simulated nature of the quantization, we do not perform batch-norm folding in our experiments.
However, this may improve results further, given the additional scaling factor per channel (rather than just per-layer).
Notably, investigating FIT combined with other more complicated quantization schemes such as those proposed by Chang et al.
(2021b)
and Chang et al.
(2021a) provide appealing directions for future work.
In particular, we note that due to the formulation of FIT, differing quantization schemes are realised by changing the quantization noise model.
We look forward to investigating this in future.
C A CTIVATION T RACES
[Figure]
D E STIMATOR C OMPARISON
For the four classification models considered, Tables 3 and 4 indicate the estimator variances and iteration times associated with the EF and Hessian for a variety of batch sizes.
Whilst the EF exhibits expected variance reduction behaviour, the Hessian does not, and requires a minimum, model-dependent, batch size to achieve stable behaviour.
In all cases, the EF estimator variance is orders of magnitude lower than that of the Hessian.
Means and variances are estimated over 3 runs of 200 samples.
Deviations are normalised w.r.t.
the trace magnitude, taking the average across blocks/layers.
This ensures all the statistics are comparable, regardless of convergence bias.
The relative speedup associated with a fixed tolerance is computed as follows:
[Equation]
Where σ 2 indicates the estimator variance and t is iteration time.
This follows the Monte-Carlo estimate variance properties.
E F URTHER E XPERIMENTAL D ETAILS
For each of experiments A, B, C and D, we trained 100 convolutional classifiers on the Cifar10 and
Mnist datasets.
In both cases, we performed experiments with and without the inclusion of batch normalisation layers before each activation.
The architecture used consisted of three convolutional layers, followed by a fully connected classification head, with ReLU activations in between.
The first two blocks are also followed by MaxPool layers.
This is shown in Figure 11.
Between the Mnist and Cifar10 datasets, the number of filters was scaled by two.
To obtain the data, we first trained a full precision version of the network for 50 epochs using the Adam optimizer. A learning rate of
[Table] [Table] [Table] 0.01 was chosen, and increased to 0.1 with the inclusion of batch normalization.
A cosine-annealing learning rate schedule was used.
We then used this trained full precision model as a checkpoint to initialise our randomly chosen mixed precision configurations, and training was continued for another 30 epochs with a learning rate reduction of 0.1, using the same schedule.
Quantization configurations were chosen uniformly at random from the possible set of bit precisions: [8,6,4,3].
In these cases, initialisation and training were identical across all MPQ models, so as to compare the final performance.
QR:
The QR baseline represents the use of the quantization ranges to replace the EF as the sensitivity metric:
[Equation]
BN: the BN baseline represents the use of the batch-norm scaling factor γ to replace the EF as the sensitivity metric.
[Equation]
FIT W / A :
To obtain FIT W , we remove the component which takes into account activation quantization sensitivity.
Similarly, to obtain FIT A , we remove the component which takes into account weight quantization sensitivity.
Recall that in Section 3, we extend parameter space to include the activation statistics.
In these ablations, we remove (W) or retain (A) these contributions.
F Q UANTIZATION AND N OISE M ODEL
The following analysis serves to motivate the direct connection between model perturbation and bit configuration.
During quantization, it is common historically to assume the quantization error is uncorrelated with the original signal, yielding an approximately uniform distribution.
This leads to an important assumption: The quantization error of each parameter is independent and uniformly distributed with a mean zero.
Figure 12 serves to motivate the validity of this assumption.
[Figure]
Under this assumption, it is possible to evaluate this noise power:
[Equation]
where ∆ denotes the step width of quantization, and can be modelled directly by the quantization scheme being used.
In this case, uniform (min-max) quantization.
Letting Q ( θ ) : θ → θ q denote the quantization function, uniform quantization can be expressed as follows:
[Equation]
where b is the quantization bit precision.
This yields the following quantization noise power:
[Equation]
Consider now our revised model perturbation (w.l.o.g. remove the constant factor),
[Equation]
Each bit configuration - { b l } L 1 - yields a unique FIT value from which we can estimate final performance.
G FIT DETAILS G. S TANDARD RELATIONS IN INFORMATION GEOMETRY
Proposition 1.
The EF defines an estimate for the natural metric tensor of the statistical manifold induced by the parameterised model, obtained infinitesimally (in this case) from an expansion of the
KL divergence.
Proof.
For brevity, denote p ( z, θ ) as p θ .
Here we describe the discrete case, however, the continuous follows similarly. [Equation] [Table] [Equation]
[Table]
[Equation]
G. O BTAINING FIT
Proposition 2.
FIT is obtained (under mild noise assumptions) by taking expectation over the
Fisher-Rao metric.
Proof.
[Equation]
We assume that the random noise is symmetrically distributed around mean of zero: E [ δθ ] = 0 , and uncorrelated:
Cov [ δθ ] =
Diag ( E [ δθ 2 ]) .
This yields the FIT heuristic:
[Equation]
And in its block-wise empirical form, with an approximate noise model:
[Equation]
In cases where we compute a numerical approximation of our noise model: 1 n ( l ) · || δθ || 2 l , rather than averaging over many trained models, we leverage the high dimensionality of the parameters in each layer to obtain a good approximation.
G. C ONNECTIONS TO THE H ESSIAN
Proposition 3.
The Fisher Information Matrix is equal to the expectation of the Hessian under the correctly specified model.
Proof.
[Equation]
Taking the first term of the right-hand side (RHS).
We assume in this case the function is sufficiently smooth such that the order of integration and (second) differentiation can be exchanged.
In this case, the first term on the RHS evaluates to 0:
[Equation]
The second term on the RHS is then simplified as follows [Equation] yielding our result:
[Equation]
Proposition 4.
Provided ˆ θ n is a consistent estimator for the true model parameters θ ∗ , the Empirical
Fisher Information will converge in probability to the Fisher Information as n → ∞ .
Proof.
[Equation]
Considering the first term on the RHS, we are able to apply the uniform law of large numbers,
[Equation]
provided the following regularity conditions are upheld:
Θ must be compact 2.
f ( z, θ ) continuous at each θ ∈ Θ for almost all z ∈ Z 3.
The aforementioned dominating function must be finite
Now considering the second term on the RHS.
Our estimator in this case is defined as consistent, and therefore ˆ θ n p θ ∗ −−→ θ ∗ as n → ∞ .
Via the continuous mapping theorem, [ I (ˆ θ n ) − I ( θ ∗ )] p θ ∗ −−→ 0 .
We therefore arrive at the desired result.
G. C OMPUTATION
Proposition 5.
The trace of the EF can be computed via the sum of the square of the gradient.
Proof.
The trace is a linear operator, which allows each individual estimator to be extracted from the summation.
Additionally, the trace of the second moment matrix can then be computed by the norm of the vector of parameters from which it is composed:
[Equation]
Proposition 6.
The variance of the Hutchinson estimator is given by:
[Equation]
Proof.
Assuming r follows a Rademacher distribution, the first four moments are as follows: m = (0 , 1 , 0 , 1) .
As such, we can compute the variance of the quadratic form:
[Equation]
H E NVIRONMENTAL ANALYSIS
During the course of this research, we estimate our total emissions to be 10.8 kgCO 2 eq.
O (100) hours of computation was performed on an RTX
Ti
(TDP of 250W), using a private infrastructure which has a carbon efficiency of 0.432 kgCO 2 eq/kWh.
Estimations were conducted using the
MachineLearning Impact calculator presented by Lacoste et al.