O N A NYTIME L EARNING AT M ACROSCALE
Anonymous authors
Paper under double-blind review
A BSTRACT
Classical machine learning frameworks assume access to a possibly large dataset in order to train a predictive model.
In many practical applications however, data does not arrive all at once, but in large batches over time.
This creates a natural trade-off between accuracy of a model and time to obtain such a model.
A greedy predictor could produce non-trivial predictions by immediately training on batches as soon as these become available but, it may also make sub-optimal use of future data.
On the other hand, a tardy predictor could wait for a long time to aggregate several batches into a larger dataset, but ultimately deliver a much better performance.
In this work, we consider such a streaming learning setting, which we dub anytime learning at macroscale (ALMA).
It is an instance of anytime learning applied not at the level of a single chunk of data, but at the level of the entire sequence of large batches.
We ﬁrst formalize this learning setting, we then introduce metrics to assess how well learners perform on the given task for a given memory and compute budget, and ﬁnally we test about thirty baseline approaches on three standard benchmarks repurposed for anytime learning at macroscale.
Our ﬁndings indicate that no model strikes the best trade-off across the board.
While replay-based methods attain the lowest error rate, they also incur in a 5 to 10 times increase of compute.
Approaches that grow capacity over time do offer better scaling in terms of training ﬂops, but they also underperform simpler ensembling methods in terms of error rate.
Overall,
ALMA offers both a good abstraction of the typical learning setting faced everyday by practitioners, and a set of unsolved modeling problems for those interested in efﬁcient learning of dynamic models.
I NTRODUCTION
Empirical risk minimization (Vapnik, 1998) is the dominant framework to formalize the learning process of a supervised task, and it has been critical to the success of large scale training of deep learning systems on a wide variety of applications.
Within this framework, training data is assumed to be provided to the learner all at once.
Alternatively, when the dataset is very large (essentially inﬁnite), data is streamed to the learner one minibatch at the time, assuming that the rate at which samples are received matches the model’s processing time to learn from them.
Learning over streams of data has been studied in the machine learning domain for a long time (see
Section 2 and Figure 1 for more details) with different assumptions: for instance in online learning, it is usually assumed that datapoints are coming one by one and have to be processed as soon as they are received.
In continual learning, the streaming of data usually corresponds to a stream of large datasets corresponding to different tasks to solve, etc.
In this paper, we deﬁne a simple yet important setting where there is a single task to solve, and where training data often comes at a slower rate than a model can process it.
Moreover, it comes in relatively large batches once in a while.
While poorly studied, this setting corresponds to practical applications encountered in production pipelines.
For instance, it is faced by teams deploying language modeling applications (e.g content moderation) build models that are trained on large amounts of data like ﬁltered versions of Common Crawl, which are dumps of the internet.
However, new snapshots are available every month, as new content is generated over time.
Therefore datasets keep getting bigger every few months and models need to be retrained accordingly.
Similarly, visual object recognition datasets used in deployed applications are often extended every few months to include new images with their corresponding annotations.
[Figure]
per datapoint Cannot overfit Concept Drift Data
[Figure]
sequentially optimize anytime performance
Continual Learning
On-the-fly training
Change in Distribution
Datapoints arrive one at a time
Model all seen distributions
Model current distribution
[Figure]
Practically, there are two main approaches to integrate information present in a new batch of data in an existing model.
If a lot of computational resources are available, a new and bigger model is instantiated and trained from scratch on the union of the old training set with the new batch of data.
However, since this is a computationally very intensive process, retraining is typically done only rarely, once several batches of data have been collected.
We call this approach “tardy” large-scale learning, since a predictor is available only at a later time.
Another option, particularly suitable when computational resources are scarce and a predictor is needed quickly, is to simply ﬁnetune the old model on the new data as this arrives.
Note that, in that settings, methods from the data stream domain or from the online learning domain that are based on the idea of processing any datapoint just once are not suitable since they have been developed for different use-cases.
This trade-off is emblematic of anytime learning , a learning setting where a learner has to provide good predictions at any point in time, while improving its performance over time as more and more data is observed.
From an anytime learning perspective, neither training a large model after all data is received nor ﬁnetuning on the newly added batch of data are not satisfying.
The former approach is a poor anytime learner because one needs to wait for a long time before obtaining a useful predictor.
The latter approach is a poor anytime learner because it typically cannot leverage very well future batches of data since the model has a ﬁxed capacity, determined on a small portion of the overall dataset and because inherently the model is trained on non i.i.d. data.
In this work, we aim at exploring this accuracy versus time trade-off of anytime learning, not at the level of a single batch of data, but at the macroscale of the entire sequence of batches.
This is a setting which more closely mimics practical applications, that we call anytime learning at mascroscale (ALMA).
In this learning setting, we assume that the time to train a model is negligible compared to the interval of time between two consecutive batches of data (and therefore we do not care about how quickly a learner adapts to a new batch), yet efﬁciency matters in the sense that for the same performance a predictor that uses less compute and memory is preferable.
In summary, we are interested in a learner that i) yields high accuracy, ii) can make non-trivial predictions at any point in time while iii) limiting its computational and memory resources.
Our ﬁrst contribution is to formalize the ALMA problem and to introduce metrics to evaluate learners (§3).
We consider three different axes: error rate, memory and amount of computation.
By measuring these quantities against time, via an area under the curve, we account not only for the ﬁnal performance but also for the whole training trajectory over the sequence of large batches of data.
Our second contribution is an extensive empirical evaluation (§5) of various models (§4) that strike different trade-offs between accuracy and time to obtain a useful predictor.
In particular, we explore models that fall in between greedy ﬁnetuning and tardy large-scale learning, and investigate models that leverage batches of data at an intermediate rate.
We also consider a rich family of modular architectures, from plain ensembling methods to hierarchical mixture of experts, and several variants thereof, including those that have access to a replay buffer storing all previous batches of data and those that can grow capacity over time.
Our ﬁndings across three different benchmarks, including a large scale language modeling one, can be summarized as follows.
a) An intermediate waiting time offers the best trade-off between accuracy and time to yield such a predictor.
However, b) there is no single approach striking the best trade-off between performance and efﬁciency for various model sizes.
c) Retraining from scratch a big model does offer the lowest error rate but sacriﬁces efﬁciency.
d) Interestingly, large models are the most statistically efﬁcient even when considering small datasets (like MNIST) and fully connected networks.
e) While approaches to grow capacity exhibit gains in terms of computational efﬁciency, these do not even outpeform simple ensembles.
Overall, our work points at several research opportunities to improve modeling in a streaming setting of broad practical relevance, rather then pointing at any particular solution.
We have also released code to reproduce our experiments and the entire platform implementing ALMA.
R ELATED W ORK
ALMA relates to several other learning frameworks: ofﬂine learning, continual learning, online learning and transfer learning as illustrated in Figure 1.
i)
It shares the same assumptions of classical empirical risk minimization (ERM) (Vapnik, 1998) at the level of each batch of data.
However, it overall violates ERM’s assumptions of i.i.d.
observations, because data points come in a stream of data chunks.
ii) Because of this, ALMA relates to continual learning (CL) (Ring, 1994; Thrun, 1994;
Ring, 1997; Thrun, 1998), with the key difference that the data distribution across batches (or tasks) is assumed stationary in ALMA.
Therefore, ALMA can be seen as a special case of CL with a single task to solve.
iii) ALMA relates also to online learning (Bottou, 1998) since it assumes that data are coming in a stream, an assumption also made in the concept drift literature (Lu et al., 2018).
However, in online learning examples are streamed one at the time (or at random from a large dataset), while in ALMA the learner receives large batches of data sequentially In ALMA, received data can be processed multiple times as opposite to the online learning setting that usually assumes that any new datapoint has to be processed as soon as it is available, and will not be reused in future updates.
iv)
Finally, ALMA relates more broadly to transfer learning (Pan & Yang, 2010), as the problem of adapting to a new batch of data can be interpreted as leveraging knowledge acquired on previous batches to more effciently learn from the new batch of data.
Of course, ALMA relates to anytime learning (Grefenstette & Ramsey, 1992; Ramsey & Grefenstette, 1994), which has been recently applied to compare various autoML frameworks (Liu et al., 2020).
However, in this work we are not interested in assessing the anytime learning ability at the level of each chunk of data, but only at a coarser granularity, at the level of the entire stream of chunks.
Inspired by Liu et al.
(2020), we consider the area under the curve of error rate against time to measure performance, but in order to account also for compute and memory budget, we add to our evaluation metrics also the area under the curve for memory and compute.
From the more theoretical side, there has been work about sub-bagging (Bühlmann & Yu, 2002) (bagging using subsets of a larger dataset) which is similar to our setting but without the sequential aspect of it.
In this context, Breiman (1999) proposed a model similar to our growing ensembling (gEns), Bühlmann & Yu (2002) studied sub-bagging as a way to make the prediction of tree classiﬁers more robust while Zou et al.
(2021) studied the consistency of the estimator in this setting.
We defer to future studies the analysis of ALMA, while in this work we focus on the empirical evaluation.
Shifting the discussion to prior work on models that adjust their capacity dynamically, Waterhouse &
Robinson (1995) introduced an approach to grow a hierarchical mixture of experts model (Jordan &
Jacobs, 1994).
This is a tree structured model where experts are at the leaves and gating functions are at non-terminal nodes.
The tree determines a hierarchical partition of the input space into regions that are associated to each expert.
This approach was made more efﬁcient in later work by (Fritsch et al., 1996).
In this work we consider a baseline (gMoE) that extends this prior work to hierarchical mixture of experts (Eigen et al., 2014; Denoyer & Gallinari, 2015;
Lepikhin et al., 2020).
Growing architectures have also been studied in CL.
For instance, Fernando et al.
(2017) and Veniat et al.
(2021) proposed a modular architecture that is assembled for every task, possibly reusing previously trained modules.
The major difference with our work is that in our case routing is input dependent as opposed to task dependent.
Yoon et al.
(2018) instead proposed a method to incrementally and smoothly add hidden units.
Similarly, Wen et al.
(2020) proposed a heuristic approach to automatically adjust the network depth.
Wang et al.
(2017) considered growing both depth and width when ﬁnetuning to a new task.
Liu et al. (2019a) and Wu et al.
(2020) proposed approaches to grow architectures in depth and width by leveraging Taylor approximation and greedy selection.
In our work, we benchmark against this last variant.
None of these approaches have been applied to the ALMA setting to date.
Finally, some of our ﬁndings are built upon and extend recent empirical evaluations studying the scaling properties of language models (Kaplan et al., 2020a; Li et al., 2020b).
In this study, we conﬁrm the conclusion that bigger models generalize better and are more statistically efﬁcient, not only in language modeling tasks using a transformer architecture, but also in smaller scale computer vision tasks using both fully connected and convolutional architectures.
L EARNING S ETTING
In anytime learning at macroscale (ALMA), we assume that there exists an underlying data distribution p ( x, y ) with input x ∈ R D and desired label y ∈ { 1 , . . .
, C } .
Notice that extensions to regression and unsupervised learning (where y is missing) are trivial, and therefore in this work we focus on classiﬁcation problems for simplicity of exposition.
A important property of ALMA is that data is presented to the learner as a stream S B of B consecutive batches of examples.
Let D i be a collection of N (cid:29) 0 i.i.d.
samples randomly drawn from p ( x, y ) , for i ∈ { 1 , . . .
, B } .
The stream is then deﬁned as the ordered sequence S B = {D 1 , . . .
, D B } .
We refer to each dataset D i as mega-batch , as it is composed by a large number of examples.
Typically a learner m : R D → { 1 , . . .
, C } updates its parameters by processing a mini-batch of n (cid:28) N examples at the time from each mega-batch D i , and by iterating several times over each mega-batch before being presented with the next mega-batch.
Since the learner cannot access future mega-batches, overall the data distribution is not i.i.d., even though samples drawn from each mega-batch are i.i.d., and cross-validation is performed using a subset of the current mega-batch.
A learner could decide to use previous mega-batches when learning on the current mega-batch, but this will increase its compute usage.
Finally, we assume that the time it takes a learner to update its internal parameters after having observed a mega-batch is much less than the interval between the arrival of two consecutive megabatches.
In other words, the rate at which data arrives is slower than the processing time of the model, and therefore the model could decide to iterate several times over the data at its disposal to improve its prediction accuracy.
3. M ETRICS
We evaluate learners in the ALMA setting across three axes, namely: accuracy, memory and computation.
Let t be the time at which the t -th mega-batch arrives; this data can be used by the model to update its parameters or it is simply aggregated to previous mega-batches for later use.
We compute the error rate of model m at time t (after the arrival of the t -th mega-batch) and compute the area under the curve obtained varying t from 0 till the total number of mega-batches B ; the resulting cumulative error rate (CER) is:
[Equation]
where m ( x ; θ t ) is the model at time t equipped with parameters θ t , D Ts is the test set, |D
Ts | is the number of examples in the test set, and | m ( x ; θ t ) (cid:54) =
y | is one if the model prediction does not match the ground truth label and zero otherwise.
The outer sum computes the discrete integral of the error rate over time.
CER is going to be small only when the error rate is small throughout the whole stream .
CER is instead large for a tardy model that waits till the very last mega-batch to update the model, even though eventually this may obtain a very low ﬁnal error rate.
If not perfect, CER provides a good summary of the performance of a system across time.
Anyway, to fully capture the differences between two models, it is needed to have a deeper look at the performance across time as illustrated in Figure 2 for instance.
Similarly, we compute the cumulative memory usage and compute as:
[Equation]
where | θ t | is the number of free parameters of the model at time t , and O ( m ( · ; θ t )) is the number of ﬂops used by the model to process the t -th mega-batch.
Once again, by measuring the area under the curves obtained by tracking these quantities over time we obtain a holistic assessment of memory and compute throughout the whole stream.
A model can obtain small Mem and Comp only if it does not consume memory and if it is computationally parsimonious throughout the entire duration of the stream.
1: procedure T RAIN ( m, w , replay, grow) (cid:46) m is the
, w is the waiting time 2: t ←3:
D ← ∅ 4: while t < B do (cid:46) each stage 5: if replay then (cid:46) Acquire w
-batches 6:
D ← D ∪ D t ∪ ... ∪ D t + w −7: else 8:
D ← D t ∪ ... ∪ D t + w −9: t ← t + w 10: if grow then 11: m.grow () (cid:46)
Grow the model if the model is a growing model 12: m.train ( D ) (cid:46) Fine-tune or retrain from scratch m on the collected dataset
L EARNING A LGORITHMS
In this section, we describe the methods we tested in the ALMA setting.
They generally follow the learning procedure shown in Algorithm 1.
At a high level, we consider two families of models, those with a monolithic architecture and those with a modular architecture (e.g., ensembling).
The latter are amenable to grow over time by adding new modules to the existing set.
We will start by describing ﬁxed architectures (§4.1) and then conclude with growing architectures (§4.2).
All models are also given the option to replay previous mega-batches.
4. F IXED A RCHITECTURES
The ﬁrst family of methods trains models with a ﬁxed architecture.
These models are sequentially trained over new mega-batches and exhibit a ﬁxed memory footprint.
We consider three models:
Single Model ( SM ):
This is a standard multi-layer neural network (e.g., fully connected neural network or transformer) trained by stochastic gradient descent.
It can be initialized from random or from the parameters of the model trained on the previous mega-batch.
The initializaiton choice is determined via cross-validation.
Ensemble of Models ( Ens ):
The second approach is the simplest modular approach, consisting of an ensemble of N neural networks with the same architecture, each being trained independently on the same sequence of data.
The output of the overall model at test time is the average probability distribution produced by each component 1 .
The advantage of Ens is that training and inference can be trivially parallelized, enabling to scale up model parameters very easily.
The disadvantange is that inference requires N times more compute than what is required by each component.
Uniform Mixture of Models ( UMix ):
A potential drawback of Ens is that evaluation and training are inconsistent.
UMix addresses this by training a model whose prediction is the average (in logit space) of the predictions produced by N networks.
While this requires synchronization during training, now both training and evaluation use the same model.
4. G ROWING A RCHITECTURES
In the previous section, the number of parameters and the architecture of the model are ﬁxed throughout the model’s lifetime.
However, as more data is observed, it is interesting to consider dynamic architectures that grow over time, because these may save compute and memory during the earlier stages of learning while providing more predictive power during the later stages.
We consider three growing approaches:
Growing Ensemble ( gEns ):
Like the Ens model, gEns is also a combination of neural networks trained independently.
While Ens considers N networks that are, at each stage, trained over the new chunck of data, gEns replaces this step by a growing step where n neural networks are added.
In our implementation, only these n neural networks are trained over the new data, while the other neural networks (trained on previous mega-batches) are kept ﬁxed.
Growing Mixture of Experts ( gMoE ): A hierarchical mixture of experts models (MoE) is an architecture where at layer l the output representation z l is: z l = (cid:80) kj =1 g ( j | z l − 1 )
h
( z l − 1 | j ) , where g is the gating or routing function and h ( ·| j ) is the j -th expert.
Compared to Ens , MoE has exponentially many more components albeit with a lot of parameter sharing.
Another advantage is that by selecting only one (or a few) experts, the computational cost is independent of the number of experts, assuming the cost of gating is negligible compared to the cost or executing the experts.
The main issue is that
MoE are notoriously harder to train (Eigen et al., 2014; Denoyer & Gallinari, 2015;
Lepikhin et al., 2020).
In this work, we consider a growing version of MoE, which we denote with gMoE , whereby experts are added over time.
See Appendix A for more details.
Fireﬂy (Wu et al., 2020) ( FF ): FF is a method which progressively grows neural networks, jointly optimizing both the model architecture and parameters.
Growth includes both a width expansion by adding new hidden units (or feature maps) as well as a depth expansion by adding new layers.
Importantly, this is an example of non-modular method unlike Ens or gMoE , which is potentially more expressive but also more inefﬁcient at inference time because there is no structured sparsity that can be leveraged to speed up computation.
E XPERIMENTS
In this section we ﬁrst describe how standard benchmarks can be repurposed for ALMA, we then provide the details of the models we tested, and we ﬁnally conclude with an analysis of the results we obtained, aiming to understand which method attains the best trade-off between time, accuracy, compute and memory usage.
Datasets We consider a variety of datasets.
The ﬁrst dataset is MNIST (LeCun et al., 1998), which consists of a training set with 60 , 000 quasi-binary handwritten digits of size 28 x 28 pixels, and a test set with 10 , 000 examples.
The second dataset is CIFAR 10 (Krizhevsky, 2009) that has a training set with 50 , 000 images of size 32 x 32 pixels belonging to 10 classes such as bird, car, horse, ship, truck, etc.
The third dataset, used for our large-scale language modeling evaluation, is a portion of the collection of English language text introduced in Liu et al.
(2019b), consisting of Books, Wikipedia and Common Crawl.
We consider 4 (large) mega-batches for training and one additional mega-batch for evaluation, each consisting of approximately 440M words; we also hold out a validation set with approximately 0.5M words of Common Crawl for model selection.
We use a byte-pair encoding (BPE) (Sennrich et al., 2016) vocabulary with 50 , 000 units, following Radford et al.
This dataset is fairly representative of what practitioners might face when maintaining a deployed system with new data arriving every few months.
Given a dataset like any of the above, we construct a benchmark for ALMA evaluation as follows: 1) we randomly partition the training set into B mega-batches with equal number of training examples ( B = 50 for MNIST and CIFAR 10, and 4 for the text dataset), 2) from each mega-batch we extract 10 % of the data to build the mega-batch validation set (except for the large scale language modeling dataset where we use the provided validation set), and 3) we create a learning experience by doing one pass over the sequence of mega-batches.
For each mega-batch, the learner can query as many mini-batches as desired.
The learner can also decide not to train on the data of a mega-batch right away but instead to wait and accumulate data across a few consecutive mega-batches.
While the learner observes data, it is also tested on the test set.
This is not used for validation purposes, but only for ﬁnal reporting as shown in §5.1.
Models We evaluate the six approaches presented in §4, and for each of them we consider various waiting times, a version with and without replay, and at least two model sizes.
For each setting, we cross validate over several hyper-parameters such as initializaiton type, learning rate, stopping criterion, growth rate, etc.
[Figure] [Figure]
[Table]
[Figure]
[Table]
Next, we describe in details the architecture used on each dataset.
Further experimental details to aide reproducibility are reported in Appendix B.
On MNIST the backbone architecture of SM is a three layer fully connected neural network with ReLU units.
We considered two hidden units sizes, namely 4 and 32 (denoted by [s] and [b], respectively), which let us simulate the regime of big data relative to the size of the network and explore how to grow architectures without worrying about overﬁtting.
Similarly, the components of Ens , gEns and UMix are SM networks of the same size as stated above; gMoE also starts off as SM and adds modules (at the ﬁrst two layers) that have the same size as the original layer of SM .
When varying the waiting time, i.e., the number of mega-batches that are aggregated before initiating a new training session, we use the sufﬁx “_w” to indicate its value.
On CIFAR 10, the methods and notations are the same as in MNIST.
The only difference is that the backbone architecture is a scaled down version of a VGG19 convolutional neural network (Simonyan & Zisserman, 2015), where the number of intermediate feature maps is the same for each layer and equal to either 4 or 32 .
On this dataset, we also consider FF starting off from the same VGG backbone.
For the language modeling task SM is a Switch Transformer (Fedus et al., 2021), which is a hard mixture of experts model with an additional load balancing loss term and hard capacity constraint applied during training to prevent uneven expert utilization.
Following Fedus et al.
(2021), we ﬁx the weight of the balancing loss term to 0 .
01 and use a capacity factor of 1 , ensuring relatively uniform expert utilization.
We train the model using Adam (Kingma & Ba, 2015) and tune the learning rate and dropout on the validation set.
In the growing setting we copy the expert weights and gating network weights corresponding to the top- k experts incurring the largest loss, where k is typically between 2 and 4.
We consider two model sizes: a base model with 6 layers and model dimension of 512, for a total of 40M shared parameters and 6M additional parameters per expert; and a large model with 12 layers and model dimension of 768, for a total of 96M shared parameters and 28M additional parameters per expert.
We use an input sequence length of 512 tokens and we do not use replay given the large chunk sizes.
5. R ESULTS
In Fig.
2 we start by analyzing learning curves on CIFAR 10 for a subset of the methods as a function of the waiting time.
We then dive into analyzing all methods on both MNIST (Tab. 1) and CIFAR
[Table]
: CIFAR 10 results with waiting time equal to 5.
Same notations and colors as in Table 1.
(Tab. 2), using the optimal empirical value of waiting time.
We conclude by conﬁrming the major ﬁndings at scale on the language modeling task (Tab. 3).
Fig.
2 shows the test error rate as a function of the number of mega-batches received for both the small (left) and the large (right) model.
We observe that an intermediate waiting time (in this case equal to 5) strikes the best trade-off between accuracy and time for all methods, since curves with waiting time equal to 5 have the lowest area under the curve.
Greedy methods using waiting time equal toachieve lower error rate only during the very beginning of the stream.
Second, we observe that bigger models ( SM and Ens ) not only generalize better but they are also statistically more efﬁcient: the small
Ens obtained almost 35% error rate by the end of its learning experience, which is worse than the error rate obtained by the large Ens just after having observed one tenth of the entire stream.
The statistical efﬁciency of large models does not apply only to large transformers (Kaplan et al., 2020a), but also to fully connected (we obtained similar results on MNIST) and convolutional models.
Next, using the waiting time that yielded the lowest cumulative error rate, we compare all methods discussed in §4, focusing our discussion on Tab. 2 of CIFAR 10 as same conclusions apply to MNIST as well (see Tab. 1).
First, replay lowers the CER by a relative amount of about 10% at the cost of increasing the cumulative training ﬂops by a factor of more than 5, which is rather substantial.
Notice that retraining from scratch using memory replay, as reported here in parentheses, is nowadays the dominant approach to deal with sequential datasets.
Second, Ens works better than UMix for larger models, and vice versa.
We surmise that ensembling may alleviate overﬁtting of large models, but coordinating the components of the ensemble like UMix does, is more effective in an underﬁtting regime (i.e with small models).
Ens thus looks like a good method to train large architectures without suffering of the overﬁtting aspect and may be used when the complexity of the task is not known a priori .
Third, all growing approaches perform rather similarly, particularly when starting from larger backbones, although they strike slightly different trade-offs.
For instance, gMoE is the most efﬁcient at test time, while FF yields a lower error rate.
Interestingly, none of the approaches that grow architectures currently manages to beat Ens in terms of error rate when starting from a large backbone, although they require substantially fewer ﬂops at inference time.
Finally, while methods derived from SM (for the same size of the initial backbone, see rows with the same color in the table) all manage to beat
SM , it is also worth noting that for the same number of parameters SM is still the best performing method, unless there is overﬁtting.
In particular, Ens with 12550 parameters achieves a CER of 2440 while SM with 11710 parameters obtains a CER of 2038 while requiring much less compute; same considerations apply also to the gMoE with 29550 parameters compared to SM withparameters.
Therefore there is no single model striking a much better trade-off, and more advanced approaches do not outperform simpler methods like Ens .
[Table]
The results on the large scale language modeling task reported in Tab.
3 show that bigger models perform better (the larger the number of parameters the lower the PPL for a given model class) and are also more statistically efﬁcient (for instance the base SM _w1 attains 26.53 after seeing the whole stream, while the large SM _w1 obtains 22.47 just after seeing the ﬁrst chunk of data), consistent with recent related work (Kaplan et al., 2020b; Li et al., 2020a).
We also observe that Ens is a strong performer, with Ens _w1 and gEns _w1 models dominating SM models in all settings.
Surprisingly, ensembles trained on distinct data chunks ( gEns _w1; t 1 or t 3 ) perform no better than ensembles trained on a single data chunk ( Ens _w1; t 0 ).
For instance, among Base 2-model ensembles (4@2),
Ens _w1 achieves a perplexity of 26.20 using a single data chunk ( t 0 ), while gEns _w1 achieves a perplexity of 26.27 using models trained on each of the two data chunks ( t 1 ).
Finally, if test time inference is a concern, then gMoE is a preferable choice since its runtime is comparable to SM .
C ONCLUSION AND P ERSPECTIVES
In this work we introduced the anytime learning at macroscale (ALMA) setting, which is an instance of anytime learning under the assumption that data is observed as a sequence of large batches.
ALMA better mimics the learning scenarios faced by machine learning practitioners, who want to efﬁciently solve a task, but time to time they receive more data to train on.
We introduced metrics that enable the assessment in terms of error rate, memory usage and compute throughout the entire learning experience.
Equipped with these tools, we then evaluated several approaches on three different datasets, including large scale language modeling.
We found that methods that update parameters at an intermediate rate tend to yield a better trade-off, and that bigger models tend to generalize better.
In particular, models that grow capacity over time generalize better particularly when the initial model is smaller, and ensembling is a very strong baseline.
A cynical interpretation of our ﬁnding that bigger models generalize better, could take the reader to the conclusion that it can all be solved by starting with a big model.
However, as data is added over time so is computation.
It is often the case that researchers working on large-scale learning instantiate the biggest possible model to train on their task, but few months later they can manage to launch even bigger models thanks to compute and engineering advances.
How can the larger model leverage what has been learned from the previously trained model?
Is there a modeling choice that strikes a better trade-off than retraining from scratch?
More generally, what are good approaches to extract information from a new batch of data to integrate it into an existing model?
While we do not provide a full answer to these questions, we do offer a framework to study them and several strong baseline approaches to compare against and build upon.
R EPRODUCIBILITY S TATEMENT
We have made several efforts to ensure that the results provided in the paper are fully reproducible.
We ﬁrst provide a clean codebase from which all the computer vision results in this paper are generated.
In this codebase, one can ﬁnd the exact hyperparameters used for each method in the provided conﬁgurations.
We have attached a readme to the code in order to guide users running our code.
For the LM experiments, as stated in the appendix we use the fairseq (Ott et al., 2019) and provide the required information to replicate our results.
A PPENDIX A G ROWING M IXTURES OF E XPERTS
Growing Mixture of Experts ( gMoE ): A mixture of expert ( MoE ) is a sequence of non-linear functions, each of which is potentially a mixture of experts (omitting the dependence on parameters): m ( x ) =
f l ( f l − 1 ( . . .
f 1 ( x ) . . . )) , with f i ( z ) =
k (cid:88)
j = g i
( j | z ) h i ( z | j ) where g i is the gating function at the i -th layer which outputs a categorical distribution over the number of experts, and h i ( ·| j ) is the j expert at layer i .
The gating function can be “soft” in which case it outputs non-zero weights for each expert via a softmax, or “hard” version in which case only one expert is selected through a multinomial sampling (and learned through the straight-through estimator in this paper (Bengio et al., 2013)).
At test time in the “hard” case, we select the expert with the largest probability.
The interest of mixtures of experts is they have a high expressivity, and experts can be easily added to increase the capacity of the model.
The gMoE model is the growing version where, at each stage as illustrated in Fig. 3, new experts are added at each layer – details about the precise expansion process are given in Appendix.
[Figure]
The key design considerations are: when to grow, what to grow and how to grow.
Here, we will refer to our default setting which favors simplicity, unless otherwise speciﬁed.
A growth step is triggered at each stage, ensuring a linear growth over time.
We grow by adding one expert at each layer, making sure that all experts within a layer have the same architecture albeit with different parameters.
In order to grow, we look at which expert has associated the largest cumulative loss; we call such expert the losing expert.
The cumulative loss is deﬁned as the sum of the losses of examples on the validation set that have been routed through a particular expert; each expert has associated a cumulative loss value.
The rationale is to identify at each layer the expert responsible for the largest contribution to the total loss.
To avoid drop in the loss function and to keep its differentiability when splitting an expert, we propose a tree-based approach we the losing expert is split such expert into two experts with exactly the same parameters as illustrated in Fig.
Two children leaves are derived and we instantiate a new gating for the children which decides whether an input example routed to the old expert, should now go to the right or left expert child.
The parameters of the new gate are initialized at random while the parameters of the new experts are exact copies of the ones of the losing expert that we split.
More formally, if s is the losing expert then the term g i
( s | z )
h i ( z
[Equation]
s ) is replaced by:
[Equation]
where g i ( k | z, s ) is the newly introduced gate, and z is the input of the gating and experts.
Over time, the gating function learns to partition its input space into a binary tree (if we start from a single expert), and the gating value of an expert is the product of the gating probabilities on the path from root to the leaf expert.
Both the gating tree structure and the particular initialization scheme guarantee that the growth step is smooth and fully differentiable, in particular, the loss before and after the growth step is the same.
If we consider each path in the MoE model to be a different model, then with L layer of k MoE components, there are k L many possible paths through the MoE model, hence the number of paths grows exponentially with the number of layers.
You can think of this as an ensemble with exponentially many components, but this is still tractable because components share parameters.
Algorithm 2 gMoE m
: do 8: practice sample mini batches.
9: m.update
11: m.grow
Growth step can be done at a different rate too.
12: function GROW ( D
) 13: for each layer in the network do 14:
Let i be the losing expert on D VAL, i.e. the expert incurring the largest cumulative loss.
Turn corresponding gating output in an internal node and derive 2 gate children 16:
Initialize the new experts by copying the parameters from the old parent expert.
Initialize the new gating between the two siblings at random.
B H YPER - PARAMETER SETTINGS B. C OMPUTER V ISION E XPERIMENTS
For each megabatch received, we keep 10% of the data to perform cross-validation.
All experiments are run on a single 16GB Quadro GP100 GPU.
We apply data normalization for each dataset considered.
A training minibatch size of 128 is used.
UMix and Ens models have N = 5 in all experiments.
for gEns , we train one model n = 1 at every mega-batch, so the total number of models depends on the amount of mega-batches.
For Fireﬂy we use a growth rate of 0 .
25 , meaning that at every growth phase, we add approximately a quarter of the initial number of parameters.
B.1. MNIST
Models are trained for 100 epochs, and we report results with soft gating.
We use the AdaDelta (Zeiler (2012)) optimizer with default learning rate of 1.
We use a MLP with 2 hidden layers of varying width (e.g. 4,8 or 32 neurons).
B.1. CIFAR-
Models are trained for 200 epochs, as this was shown to be long enough to allow the model to converge with a learning rate of 0.01.
We use Stochastic Gradient Descent with momentum value of 0.9 and weight decay of 1 × 10 − 4 .
During training, we apply random horizontal ﬂips and select random image crops with padding of 4 pixels.
For the architecture, we use the same reduced VGG with batch normalization as prescribed in Wu et al.
All layers are initialized with the same number of channels (e.g. 4, 8, or 32 channels).
For the Fireﬂy experiments, we keep all the Fireﬂyspeciﬁc hyperparameters to the default values suggested in the author’s public codebase.
We make one exception to this, namely we adapt the growth ratio to result in linear (rather than exponential) growth.
B. L ANGUAGE M ODELING E XPERIMENTS
All the language models are trained using fairseq (Ott et al., 2019) with a maximum of eight 32GB
GPUs (NVIDIA V100), optimized with Adam (Kingma & Ba, 2014) using β 1 = 0 .
9 , β 2 = 0 .
(cid:15) = 1e-8.
The learning rate is warmed up over the ﬁrst several hundred updates (between 500 and 4000) and then linearly decayed to 0 over the remaining updates, with a peak value tuned between 2e-4 and 5e-3.
Models are trained up to 120,000 updates with local batch size of 8 sequences per
GPU, with gradient accumulation as needed to achieve a total batch size of 192 sequences; each sequence has 512 tokens.
We ﬁx the Switch Transformer balancing loss term to 0 .
01 and use a capacity factor of 1 , following Fedus et al.
C A DDITIONAL C OMPUTER V ISION R ESULTS
In this section we show the impact of several variants of our framework.
Namely, we report results for (a) a varying number of mega-batches, (b) whether to use preemption or not, and (c) whether to initialize from scratch or simply ﬁnetuning when replay is performed.
C. CIFAR
In the following results, we vary the number of megabatches.
Below you can ﬁnd results for
MB =
C.1. D IFFERENT MB
[Equation]
[Table] [Table]
C.1. P REEMPTED R ESULTS
We also consider the use of a patience term when training the model.
When the validation accuracy has not improved over 25 consecutive epochs, we stop training for the given learning phase.
As expected, we observe gains on compute efﬁciency, with a small loss in performance
[Table] [Table]
C.1. I NITIALIZING FROM SCRATCH
Below we show results, comparing the performance of re-training models from scratch on all the data seen so far vs simply ﬁnetuning the current model(s) on all the data.
Main numbers are ﬁnetuned models , numbers in parentheses are trained from scratch .
C. MNIST
[Table]
[Table] [Table]