2 Methodology: compression-aware training
For , we denote the ith coordinate of x by . The diagonal matrix with x on its diagonal is denoted by . For , the -ball of radius τ is denoted by . denotes the number of nonzero components of . For any compact convex set , let us further denote the -diameter of by . As usual, we denote the gradient of a function at θ by and the batch gradient estimator by . We abuse notation and apply univariate functions to vectors in an elementwise fashion, for example, denotes the vector . If not indicated otherwise, we treat a tensor x of a network as a vector .
Constrained optimization using stochastic Frank–Wolfe
We aim at optimizing the parameters θ of an NN while enforcing structure-inducing constraints by considering the constrained finite-sum optimization problem
where the per-sample loss functions are differentiable in θ and is a compact, convex set. When using SGD, imposing hard constraints requires a potentially costly projection back to to ensure feasibility of the iterates [15]. An alternative is the Stochastic Frank–Wolfe (SFW) algorithm [23], [7], [57], being projection-free and perfectly suited for yielding solutions with structural properties. To ensure feasibility, SFW does not use the gradient direction for its updates but rather chooses a boundary point or vertex of that is best aligned with the descent direction. In each iteration t, SFW calls a linear minimization oracle (LMO) on the stochastic batch gradient to solve
which is then used as to update the parameters using the convex combination
where is a suitable learning rate. If the initial parameters are ensured to lie in the convex set , then the convex update rule ensures feasibility of the parameters in each iteration. Solving Equation (10.2) is often much cheaper than performing a projection step [34], [15], in many cases even admitting a closed-form solution. If is given by the convex hull of (possibly infinitely many) vertices, a so-called atomic domain, then the solution to Equation (10.2) is attained at one of these vertices.
Inducing structure through the feasible region
Apart from constraining the parameters to satisfy a certain norm constraint, for example, a bounded Euclidean norm as in the case of weight decay, the unique update rule Equation (10.3) of the SFW algorithm can be used to induce structure through the feasible region. A structured feasible region with update directions satisfying highly structural constraints, cannot only enhance generalization [59], [57] but also induce desirable network properties like sparsity. A recent example is the k-sparse polytope introduced by Pokutta et al. [57] as a generalization of the -ball . The k-sparse polytope is defined as the convex hull of vectors with at most k nonzero entries, which form the solution set to Equation (10.2). For small k, exhibits a high degree of sparsity and by Equation (10.3) only k parameters are activated while all remaining parameters are discounted strongly, encouraging convergence toward sparse solutions [57], [53].
In the following, we propose leveraging a suitable family of norm constraints, which arise naturally from -regularization with sparsification requirements. In general, our goal is to choose the constraints to result in sparse update directions when applying the update rule of Equation (10.3), discriminating between predefined groups of parameters resulting in a decay on seemingly “unimportant” groups of parameters while allowing others to grow. Similarly to Pokutta et al. [57] and Miao et al. [53], we control the degree of sparsification with a tunable hyperparameter k such that the update vectors are k-sparse, that is, nonzero at most k entries. However, existing approach are limited to the sparsification of NNs on an individual-weight basis (i. e., unstructured pruning) and may lead to hyperparameter and convergence instability. We construct constraints for structured sparsification, while also including the unstructured case. In addition, we ensure that (similar to classical SGD), the individual parameters receive updates corresponding to the magnitude of the gradient, enabling better convergence independent of the choice of k.
2.1 Inducing group sparsity to NNs
Given a disjoint partition of the network’s parameters into groups , we define the group-k-support norm [58] ball of radius τ as
where is the smallest number of groups that are needed to cover the support of v, that is, its nonzero entries. In other words, the vertex set of is given by all (vectorized) parameters for which the Euclidean norm is bounded by τ and where at most k groups contain nonzero entries. Here, the definition of a set of groups is left abstract, as it could be any disjoint partition of the parameters, that is each parameter w must lie in exactly one group .
Choosing as the set of all convolutional filters of the lth convolutional layer, we can now state the solution to Equation (10.2) as follows. For a filter , let be the -norm of when only considering elements of G. Given the batch gradient of the lth convolutional layer , let be the k groups or filters with the largest gradient -norm and let . The solution to Equation (10.2) is then given by
A proof can be found in Rao et al. [58]. Originally, the norm was motivated by the group lasso [74], which is common in the statistics and classical machine learning literature. To the best of our knowledge, these constraints have not been previously applied to deep NNs. SFW applied to updates the k filters whose gradient entries correspond to those of fastest loss decrease while accounting for the distribution of magnitude among them instead of using the same magnitude for all parameters. Due to the convex update rule, the weights of the remaining filters are decayed, eventually resulting in few of them not being close to zero and thus making the trained network robust toward filter pruning. Figure 10.4 in the Appendix A shows how different values of k as a fraction of the overall number of filters influence the relative distance to the pruned model, indicating that k allows controlling the degree of robustness toward sparsification.
Unstructured sparsity as a special case
Our approach is easily extendable to the pruning of other groups, such as neurons. A special case arises when each weight is a group on its own group, naturally extending the above rationale to unstructured pruning. One then recovers the k-support norm [4], being a suitable candidate for comparison to the k-sparse polytope approach leveraged by Miao et al. [53]. The k-sparse approach suffers from two drawbacks, both being mitigated by our proposed method.
First of all, all activated parameters will receive an update of same magnitude, namely τ. This hinders convergence, especially when k is larger. Consider, for example, the worst-case scenario in which k equals the number of parameters n, then every single parameter of the network will receive an update of magnitude τ, essentially losing the entire information of the gradient apart from the entrywise sign. On the contrary, the k-support norm with will lead to optimization over the -ball, yielding the default and best converging case of NN training. Figure 10.5 in the Appendix A shows the facilitated convergence of our approach, which is nonetheless highly robust towards unstructured pruning. The k-sparse approach performs well in the medium to high sparsity regime, but quickly collapses for higher compression rates. A clear advantage of k-support norm ball constraints is that SFW is able to obtain this performance in the high compression regime while not suffering from underperformance before pruning.
Second, Pokutta et al. [57] and Miao et al. [53] specify the desired -diameter of to control the regularization strength and then in turn choose the radius τ such that . Defined this way, τ depends on k as . This is counterintuitive, since k controls both the amount of activated parameters as well as the magnitude of the parameter updates, resulting in unnecessarily coupled parameters. As opposed to the k-sparse polytope, the diameter of the k-support norm ball does not depend on k, and hence decouples the parameters k and τ as desired. Figure 10.6 in the Appendix A shows the successful decoupling of the radius and k. The k-support norm ball is less sensitive to hyperparameter changes and obtains better results throughout a wide range of hyperparameter configurations than its k-sparse counterpart.
2.2 A different sparsity notion: pruning singular values
So far, we considered one particular notion of sparsity, namely that of the existence of zeros in a matrix or tensor. Instead of removing individual parameters or groups thereof, networks can also be compressed after training by decomposing parameter matrices into a product of smaller matrices, allowing one to replace a layer by two consecutive ones that require a drastically smaller amount of FLOPs at inference [18]. The key ingredient is the truncated singular value decomposition (SVD), where setting the smallest singular values to zero leads to an optimal low-rank approximation by virtue of the Eckart–Young–Mirsky theorem. More precisely, given a rank r parameter matrix with singular values and SVD , , , the k-SVD of approximates as
where the magnitude of “pruned” singular values quantifies the error in approximation. A detailed account of this approach can be found in the Appendix A. A natural approach to ensure robustness to matrix decomposition is hence based on penalizing the nuclear norm [65], [3], which requires the costly computation of the full SVD in each iteration.
When constraining the parameters to have bounded nuclear norm instead of penalizing it, the LMO solution to Equation (10.2) utilized by SFW can be computed efficiently by requiring only the first singular value-vector-pair [34]. Extending this notion to consider the k largest singular pairs, we propose utilizing the spectral-k-support norm [52], for which the ball of radius τ is defined as
where is the 2-Schattennorm of , being the -norm of the vector of singular values of matrix [34]. The following lemma allows to efficiently compute the LMO solution to batch gradient .
Lemma 10.1.
Let , where is the truncated k-SVD of such that only the k largest singular values are kept. Then is a solution to Equation (10.2).
A proof can be found in the Appendix A. Note that similar to the group-k-support norm ball taking the magnitude of k largest gradient groups into account, the scaling by takes the magnitude of k largest singular values into account. In Section 3.2, we study the capabilities of SFW when constraining the spectral-k-support norm of convolutional tensors, which account for the majority of FLOPs at inference [26]. While there exist higher-order generalizations of the SVD to decompose tensors directly [cf. 42], [cf. 35], we follow the approach of interpreting the tensor with c in-channels, n convolutional filters, and spatial size d as an -matrix [3], [32].