{'fraction_non_alphanumeric': 0.03913147220233834, 'fraction_numerical': 0.009525907163702439, 'mean_word_length': 4.212283554960298, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Coded Elastic Computing

Cloud providers have recently introduced new offerings whereby spare computing resources are accessible at discounts compared to on-demand computing. Exploiting such opportunity is challenging inasmuch as such resources are accessed with low-priority and therefore can elastically leave (through preemption) and join the computation at any time. In this paper, we design a new technique called coded elastic computing, enabling distributed computations over elastic resources. The proposed technique allows machines to leave the computation without sacrificing the algorithm-level performance, and, at the same time, adaptively reduce the workload at existing machines when new ones join the computation. Leveraging coded redundancy, our approach can achieve similar computational cost as the original (noiseless) method when all machines are present; the cost gracefully increases when machines are preempted and reduces when machines join. The performance of the proposed technique is evaluated on matrix-vector multiplication and linear regression tasks. In experimental validations, it can achieve exactly the same numerical result as the noiseless computation, while reducing the computation time by 46% when compared to non-adaptive coding schemes.


Introduction
New offerings from cloud-service providers allow exploiting under-utilized Virtual Machines (VMs) at a fraction of the original cost [1,3]. For example, Azure Batch provides low-priority machines at about one-fifth of the cost of ordinary virtual machines [4]. Similarly, Amazon Spot Instances provide machines at market price with a discount which can reach up to 90% with respect to regular on-demand prices [2]. Such offerings, however, have the drawback that machines can be preempted at any time if a high-priority job appears. This, in turn, will surface as a computation failure at the application level. While common distributed machine learning frameworks are already built with fault-tolerance [5,49], they often assume that failures are transient and rare. Due to this assumption, machine failures are often recovered by a "stop-the-world" scheme whereby the entire system is forced to wait until regular execution on the failure machines are restored from previous state (eventually on new machines). The above assumptions, however, do not necessarily hold for failures due to machines being preempted because (1) these failures are permanent and local data may not be accessible anymore; (2) several machines can be preempted altogether (up to 90% [46]); (3) these failures add up to transient failures, therefore leading to more frequent disruptions during computation; and (4) the computational framework may need to acquire additional machines to compensate, meaning that data has to be copied on the new machines which will likely become stragglers for the running computation. In practice, we observed situations at scale where the stop-theworld scheme results in zero computation progress because, by the time a failure is recovered, a new failure occurs. This results in the necessity to build an elastic run-time framework [18,50] and related failure-aware algorithms which can continue the computation and flexibly adapt in the presence of failures. Another possible technique to deal with preemption is to view the preempted machines as erasure-type faults and ignore them. Although machine learning algorithms are robust to small transient faults, simply ignoring the computational results in these permanently-failed preempted machines may result in algorithmic-level performance loss [50]. The influence of ignoring the computation results for the preemption type of faults is also more severe than usual computation faults because the number of failures can be really large [46]. Similarly, even if the data are redundant in some applications, ignoring partial results may still lead to reduced confidence levels on the prediction accuracy. It may also not be desirable from a customer's perspective who often requires the full dataset to be present during the entire training process in order to achieve the highest accuracy.
In order to deal with the aforementioned problems, in this paper we propose coded elastic computing: a novel distributed learning framework allowing users to train their machine learning models over preemptable machines. In our coded elastic computing framework machines are allowed to arbitrarily join or leave during a distributed iterative learning task thanks to the introduction of redundancy in the computation. Although coded elastic computing introduces redundancy using ideas from error-correcting codes [22,24,25,37,40,45,63,73,76], and can let the computation continue when a preemption failure happens like ordinary error-correcting codes, the way it utilizes the coded data to deal with preemption is fundamentally different from existing works. More specifically, coded elastic computing can flexibly change the workload of each machine at runtime based on the number of available machines by selecting to use only a subset of the encoded data in a cyclic fashion. Apart from providing fault-tolerance when machines are preempted, coded elastic computing is also positively-elastic in that it can utilize the properties of the coded data to reduce the workload at existing machines flexibly when new machines join the computation. We will show that the coded elastic computing framework can make the computational cost at each machine scale inversely with the number of machines, which leads to linear scaling of theoretical computational cost. The proposed technique is also useful in other applications besides elastic computation when the number of machines needs to be dynamically adjusted during a learning task, such as when the number of machines is tuned as a hyper-parameter, or when the machines have to be reallocated to achieve fairness [33] between users or the specific need of some users at runtime.
The proposed coded elastic computing technique is tested in the multi-tenancy cluster at Microsoft as an example of the Apache REEF EGC (Elastic Group Communication) framework. Apache REEF is a library that helps develop distributed high-performance applications on top of cluster resource managers such as YARN [66] and Mesos [33]. The Apache REEF project provides a set of abstractions and reusable functional blocks to ease the process of building cloud-scale applications. EGC is a distributed communication framework which extends Apache REEF by providing an API allowing to implement elastic computations by chaining fault-tolerant MPI-like primitives. While fault-tolerant distributed applications are usually conducted using the well-known MapReduce-style computation model based on data shuffling [19,49], recent trends in machine learning show that MPI-based computation [57] provides better performance with respect to the former. Nevertheless, MPI-based applications are in general not fault tolerant, whereas EGC tries to unify the benefits of the two worlds. Based on the EGC framework, we test the proposed technique for a coded implementation of linear regression on a real dataset when machines can leave and join the computation. We show that the current technique can obtain the same convergence behavior as ordinary gradient-descent-based algorithms but can elastically allocate the work load based on the number of available machines without moving data at the existing machines. We also compare with other baselines, such as ignore, replication and an existing algorithm called Elastic Distr-BGD [50] to show the improvement of the proposed technique in terms of the model generalization error.
In this paper, we first present a coded elastic matrix-vector multiplication algorithm to illustrate the main idea. Then, we present the generalizations of the proposed technique in broader applications, namely matrix-matrix multiplication, linear regression, master-free fully-distributed computing, and the training of deep neural networks (see Section 3). Finally, we validate the approach with a set of experiments. The proposed technique achieves the exact computation result as the noiseless computation (where the number of machines remain fixed), while adaptively changing the workload at each machine. The observed speedup compared to a non-adaptive coded computing baseline can reach up to 50%. The contributions of the paper are thus summarized in the following: • We formalize the preemption problem in elastic computing and propose a coded elastic data-partitioning framework to deal with it. • We design a computing technique that can adapt the workload at each machine in the presence of elastic events, without moving data at existing machines. • We test the proposed technique using the Apache REEF EGC framework for linear regression and show advantage on real datasets over multiple baselines.

Resource-Elastic Coded Distributed Computing
In this section, we formally define computation elasticity (see Section 2.1), and present coded elastic techniques. We initially focus on the problem of matrix-vector multiplication for having a better theoretical understanding of coded elastic computing. Before presenting the algorithm in Section 2.4, we introduce the main idea of the paper in Section 2.2 and Section 2.3. Then, in Section 2.5.1 and Section 2.5.2, we analyze the proposed techniques and prove that they are indeed elastic according to our definition.

Definition of Computation Elasticity
We characterize elastic events whereby existing machines can be preempted, and new machines can be added to the computation. A preemption means that machines are taken away and the local data is lost. To formalize the notion of elastic events that we adopt in this paper, we state the following properties that are characteristic of these events: Property 1. Which machine(s) to be preempted is decided by the resource allocator and is not known in advance. Property 2. The preemption is permanent. However, new machines may join after some unknown time. Property 3. If some machines leave or join, the other machines know immediately about which machines leave or join.
The second and third properties differentiate the elastic events from more commonly considered issues of faults and stragglers because (1) new machines can join the computation, and (2) one may adapt the computation scheme instantly after an elastic event and utilize the newly available resources.
Consider the case when a data matrix X is stored distributedly. Denote by P the initial number of machines. Denote by P max the maximum possible number of machines which equals to the overall size of the universe of machines handled by a cluster scheduler. A configuration point is a tuple (n, m) in which n is the number of machines and m is the memory size. Note that n changes over time, e.g., n can exceed P . A computation policy of a task at a given configuration point (n, m) is said to be achievable if the policy completes the task using n machines, each with size m. A policy is said to be optimal if it obtains the optimal tuple (e, u) simultaneously, where e is the number of machine preemptions that can be tolerated (i.e., the exact result can be computed even if there are e preemptions), and u is the size of data that a machine actually selects to use (u ≤ m). This means the memory of size m can be used to store (coded) data, but during computation, we only access a part of it. Note that the optimal tuple (e * ,u * ) depends on (n,m). For a given configuration (n, m), we want to minimize u to reduce the memory access time and maximize e, the number of tolerable machine failures. Denote by A n,m the set of computing policies, and A * n,m ⊂ A n,m the set of optimal computing policies that obtain the optimal tuple (e * , u * ). One may think that the optimal tuple (e * , u * ) may not be unique. For example, there may exist a computing scheme that achieves (e, u) such that e > e * and u > u * . Note that our definition of (e * , u * ) is not in the sense of Pareto optimality. The e * and u * are information-theoretical optimal values that are obtained separately. If there is no scheme that achieves the optimal e * and u * at the same time, then in this case, A * n,m is an empty set. Definition 1. (transition compatibility) A pair of policies (a, a ) with a ∈ A n,m and a ∈ A n ,m is said to be transition compatible if the policy a can be transitioned to policy a without having to move or modify the data in the existing machines in the event of a configuration transition (n,m)→(n ,m ).
The key to the above definition is that we discourage inter-machine data movement in order to make the elastic configuration transitions non-disruptive to ongoing computation tasks. Definition 2. (fully transition compatibility) A family of policies F = {a n,m }, n ∈ N , m ∈ M, is said to be fully transition compatible if every pair (a n,m , a n ,m ) in F are transition compatible. Definition 3. (optimal fully transition compatibility) A family of fully transition compatible policies F = {a n,m }, n ∈ N , m ∈ M is said to be optimal if all policies are optimal, i.e., each policy a n,m ∈ F is in A * n,m and obtains the optimal tuple (e * , u * ) for the number of tolerable machine preemptions and the size of the selected data to use.
Our goal is thus to find conditions under which an optimal fully transition compatible family exists, and to provide explicit characterizations of the transition compatible families. We now present matrixvector multiplication techniques that can provide a fully transition compatible family of optimal computation policies with fixed memory cost at each machine, i.e., when m is fixed in different transition compatible policies a n,m .

Coded Data Partitioning in the Presence of Preempted Machines
Assume that in the worst-case of preemption failures, there are at least L machines that remain 2 . We will show that the parameter L is also equal to the recovery threshold, the meaning of which will be clear in this section (Section 2.2). In this paper, we consider repeatedly using the same data but with different input vectors. For matrix multiplications, it means that we compute Xw t for t = 1, 2, . . . for the same X. This computation primitive is applicable in a variety of scenarios, including training linear models [30,72], PageRank [73], model-parallel deep neural networks [20,21] and many machine learning algorithms at the inference stage.
We partition the data matrix X into L subsets (or equivalently, submatrices obtained by row-wise partition) X 1 , X 2 , . . . , X L of equal size. If the total number of data points is not divisible by L, we can use zero-padding. The generator matrix G Pmax×L = (g s,k ), s = 1, . . . P max is predetermined. We initially generate P coded data matrices X coded s , s = 1, 2, . . . , P , (P > L), in which each matrix is a linear combination of the form: where each g s,k is a random but predetermined coefficient. The P coded data matrices are distributed to P workers. When the number of machines exceeds P , we generate new linear combinations based on G Pmax×L . The generation can be done before the computation, and the data can be stored in the cloud which has a much larger size than the local fast memory. Lemma 2.1. Suppose we want to compute the matrix-vector product Xw. Suppose the matrix G Pmax×L = (g s,k ) satisfies the property that any L × L submatrix of G Pmax×L is full-rank. Then, any L out of n coded computation results obtained at the n available machines X coded s w, s = 1, 2, . . . , n are sufficient to recover the original (uncoded) computation results Xw regardless of the current number of machines n.
The rank condition in the lemma can be satisfied by a variety of choices of linear coefficients g s,k , e.g., if g s,k 's are i.i.d. Gaussian random variables. The recovery of the results is through solving L linear systems of the form X coded s w = L k=1 g s,k X k w for the L different machines that successfully finish the computation. Lemma 2.1 is critical for the failure recovery. It essentially shows that no matter which machines are preempted, as long as the number of remaining machines is not smaller than L, the whole information of the original data is preserved in the remaining machines, and the computation results can be recovered. This is why we call the parameter L the recovery threshold. The parameter L is limited by the storage constraint at each machine. The more redundancy we can add to the data, the lower recovery threshold we need, and hence more failures we can tolerate. In our experiments, we consider the case when P = P max , i.e., the maximum number of machines is the same as the overall number of machines, and use a redundancy factor of P/L = 2. Therefore, we can at maximum tolerate failures when half of the machines are preempted. Note that this is not necessary because one can generate more data and store the extra data on the cloud so that the number of machines n can exceed the initial number of machines P . An often-used coding technique is called systematic code, in which the linear coefficients satisfy (2) In this case, the coded data at the first L machines X coded s , s = 1, 2, . . . , L are the original data X k , k = 1, 2, . . . , L. This can provide backward-compatibility to switch between coded computing and other uncoded ordinary computing techniques, and at the same time significantly reduce the cost of encoding the data at the preprocessing stage (1).

Elastic Data Partitioning for Elastic Computation by Using Data In a Cyclic Way
According to Lemma 2.1, as long as the number of machines that are not preempted is greater or equal to L, the remaining data using the coded data partitioning can preserve the whole information of the original data. However, when the number of machines is strictly larger than L, it becomes redundant to use all the coded data because the data at L machines already preserve the whole information. One may think that this amount of waste is not significant. However, consider the case when the number of machines gradually increases from L to a large number. In this case, any L machines can provide the correct results, but we are not able to utilize the parallel gain if a fixed coding technique is used. The situation can be partially solved if we use some rateless coded techniques [48]. See Section 2.6 for a comparison between the proposed technique and rateless coded computing.
To positively utilize all the remaining machines and achieve the parallel computing capabilities of the extra machines, we select to use data in a cyclic fashion as shown in Figure 1. We use a systematic

Original Data
Coded Data machine 1 machine 2 machine 3 machine 4 machine 5 machine 6 (e) Three preempted machines Figure 1: The main idea of elastic data partitioning is to use the data in a cyclic way. The black sub-blocks with "don't use" mean that the data is stored but not accessed. Each column of data is stored at one machine. For each group (i.e., row block) of data at different machines, there is enough number of sub-blocks that contain all the information. This cyclic way of using data leads to linear scaling of the per-machine computational cost in the number of machines.
code (see (2)) by which the first L of the P coded blocks X coded s , s = 1, 2, . . . , P are the original data X k , k = 1, 2, . . . , L. In Figure 1(a) we use red to denote original data and blue to denote the remaining coded data. In this example, the initial number of machines is P = 6 and the recover threshold is L = 3. From figure 1(b) to 1(e), we show how to continue the computation when machines are gradually preempted from 6 to 3 (machines correspond to the columns). The stored data remains fixed i.e., the same way as in Figure 1(a), but we further partition the data into smaller blocks and only select part of the data to use. Each machine is initially allocated a single subset of coded data X coded s , s = 1, 2, . . . , P , among which L subsets are the original data. Each subset of data is represented as a column in any subfigure of Figure 1.
If no failures occur (see Figure 1(b)), to remove redundancy from the data, we partition each data block (column) into P sub-blocks, and let each machine only use L out of P sub-blocks. By a sub-block of data, we mean one small rectangle in Figure 1(b). When there are n machines and n = P (see Figure 1(c)-1(e)), we partition each data block into n sub-blocks, and still let each node only use L out of n sub-blocks. If new machines join, they download the coded data previously used in some failed machines or some new linearly combined data based on G Pmax×L . All the machines, including the ones that just join, use elastic data partitioning based on the current number of available machines n.
There are two advantages of this type of data usage (1) the overall selected data to use is of the same size as the original data and the selected data across all remaining machines have the same size; and (2) the selected data preserve the whole information of the original data, according to Lemma 2.1. Thus, we can exactly recover the results while removing the redundancy in the way of using data. These two properties will be formally introduced and proved in Theorem 2.1.

Coded Elastic Computing for Matrix-vector Multiplications
We provide the detailed procedures of the coded elastic computing algorithm for the repeated matrixvector multiplication problem Xw t , t = 1, 2, . . . in Algorithm 1. We use X coded k,j to represent the j-th sub-block of the data at the k-th machine. We will call X coded k,j 's with the same j "the j-th group" of sub-blocks which correspond to the j-th row block in any subfigure of Figure 1. Note that the number of row blocks change with the number of preempted machines. We use G j to represent the collection of linear combination coefficients for the j-th group (row block) that are selected to use.
For example, for the first group (row block) in Figure 1 because the three selected sub-blocks are a 1 , a 1 + 2a 2 + 3a 3 and a 1 + 4a 2 + 9a 3 . And for the last group (row block) in Figure 1 , because the three selected sub-blocks are f 1 + f 2 + f 3 ,

Algorithm 1 Coded Elastic Computing for Matrix-Vector Multiplication
Input: The data matrix X, the number of machines P , the recovery threshold L, the linear combination coefficients g s,k 's in equation (1) and the sequence of input vectors w t t = 1, 2, . . .. Preprocessing: Partition the data X into L subsets and compute the coded subsets as in (1). Online computation: FOR each computation with input w t : Broadcast: The master node sends w t to each worker. FOR each group index j: Gather: The k-th worker computes u t,k,j = X coded k,j w t and sends u t,k,j to the master. The master gathers vectors u t,k,j for all workers that use the j-th sub-block and obtains the matrix u t,j which contains the results for the j-th group (row block). Decode: The master node computes u t,j G −1 j to obtain the results for the j-th group. Output: The master node outputs Xw t . IF Preemption/New Machines: Change the selected data to use based on the current number of machines.

Analysis of Coded Elastic Computing: Achieving Optimal Fully Transition Compatibility
According to Definition 3, a fully compatible family of policies can support seamless transitions between any pairs of policies in the family. The coded elastic computing scheme provided in Algorithm 1 for matrix-vector multiplication gives a family of fully-compatible policies for fixed memory cost at each machine. In Section 2.5.1, we analyze the memory cost and the number of data points to be used at each existing machine. Then, in Section 2.5.2, we provide lower bounds on these two quantities and show that Algorithm 1 achieves the optimal memory cost and the size of the selected data. Thus, the coded computing policies in Algorithm 1 is a compatible family of optimal policies, in that for the fixed storage size, each policy obtains the largest number of tolerable failures and smallest size of the selected data to use (e * ,u * ), and provides seamless transitions between each other without moving data at existing machines.

Upper Bounds on the Storage Cost and the Size of the Slected Data to Use
Suppose the original data has N data points and all data points are in R d , i.e., X has size N × d.
Recall that P max is the maximum number of machines, L is the recovery threshold, and n is the number of currently available machines. In the following theorem, by the size of the data we mean the number of data points. Theorem 2.1. Suppose the number of machines n satisfies L ≤ n ≤ P max at any time, i.e., it is not smaller than the recovery threshold L and not bigger than the maximum possible number of machines. Then, the coded elastic computing algorithm (Algorithm 1) achieves the exact computation result of Xw t for all t. The size of the data stored at each machine is N/L. The size of the selected data to use at each machine is N/n and is the same across different machines. The overall size of the selected data is the same as the size of the original data.
Proof. Recall that we call the sub-blocks on the same row block (in Figure 1) of the P different blocks of data a group, and we use X coded k,j to represent the coded sub-block of data that is at the k-th machine and belongs to the j-th group. Let X j be the collections of original data that belongs to the j-th group. For example, in Figure 1 Then, from the cyclic way of using data, we can see that when each machine uses L sub-blocks, the overall number of used sub-blocks in each group is L. From Lemma 2.1, the results u t,k,j = X coded k,j w t for all the workers that use the coded data in the j-th group can be collected together to decode X j w t .
The other claim can be seen from the figure, i.e., the area of the used data is always equal to the area of the original data, and the area of the used data is the same across all remaining machines. We prove this claim as follows. The size of the data in each of the L subsets is N/L. Thus, the used data at each machine is the same number N L · L n = N/n. There are n machines left, so the overall size of the used data is N n · n = N , which is the same as the original data.
Theorem 2.1 shows that our technique uses the same size of data as the original (uncoded) case. This is desirable for memory-bound applications. Remark 1. (Cost analysis) Recall that P is the number of workers, N × d is the size of the matrix X, L is the recovery threshold, and n is the number of currently available machines. The encoding (preprocessing step) is a one-time cost for online matrix-vector multiplications. The decoding by solving a linear system at the master node has computational cost O(LN ), because the linear system for each group (row-block) of data involves L equations on L unknown subvectors of size N/L/n (which is the height of each sub-block), and there are n such groups. Thus, the computational cost using straightforward matrix-vector multiplication is L 2 · (N/L/n) · n = N L. The matrixmultiplication step at each worker has cost O(dN/n). Thus, the decoding cost is smaller than the computational cost at each worker as long as d = Ω(nL). Even if d < Ω(nL), we can partition the machines into smaller groups and respectively code each group. The decoding complexity can be further reduced to O(N log 2 L) if Vandermonde systems are used [43], at the cost of numerical stability. One thing to note is that the decoding complexity, even for the straightforward matrix-vector multiplication method, is N L and is independent of the number of workers P .

Lower Bounds on the Storage Cost and the Size of the Selected Data to Use
Here, we provide a fundamental limit which shows that the achievable scheme provided in 2.1 is optimal in terms of the storage cost at each machine and the size of the actually used data at each iteration, for a fixed number of machines and a fixed number of tolerable machine preemptions. Before we present the theorem, we formalize the definition of the size of data using number of bits. This is because in theory, we cannot store arbitrarily high-precision numbers.
Assumption 1. Suppose the entries of the matrix X are i.i.d. random variables that take values in a finite set S ∈ R. Each of this random variable has entropy H = log |S|. Thus, the overall entropy of all the data in X is N dH. Assumption 2. For a certain computation policy, suppose each machine initially stores an array of finite-precision numbers in its memory. Each finite-precision number can be an arbitrary function of the original data. The overall number of finite-precision numbers that is stored is finite.
Note that although we use real-number computation all the time, the numbers that we deal with are always discrete, i.e., we conduct computation of finite-precision numbers in the real field. This validates Assumption 1. Also note that the number of possible combinations of floating point numbers that can be stored by a finite-length bit array is finite. Therefore, Assumption 2 is also valid. We need these two assumptions because if they do not hold, the system can concatenate all the real numbers in X into one real number and only stores that particular real number. In that case, no bound on the storage is meaningful because one only needs to read this single number in memory to access all the information of X. We also need the assumption that the size of the stored numbers are finite because otherwise, we can enumerate all possible Xw and store them. Assumption 3. Suppose we do not alter the way that we store the data X inside the memory after the computation begins. Even when a preemption-type failure happens, we do not move the data at existing machines. Assumption 4. By selecting to use one number stored in the memory, we mean the algorithm reads the whole number (e.g., reading all digits if the number is stored as a floating-point number) from the memory for further processing. The array of finite-precision numbers can only be accessed one number at a time, meaning that one cannot access a function value of two numbers and claim that only one number is selected to use. Theorem 2.2. Suppose the Assumptions 1-4 hold. Suppose we require the recovery of the exact computation result Xw. Then, the following fundamental limits hold.
(a) Denote the entropy of the encoded data at the k-th machine by H k , k = 1, 2, . . . , n. Then, to provide the tolerance to a maximum of n − L failures (recall that n is the current number of available machines), we have max k∈{1,2,...,n} H k ≥ N L · dH; (b) The worst-case entropy of the actually used data (maximized with respect to the choice of w) has to be no less than N dH, or N n · dH at each machine. Remark 2. By comparing Theorem 2.1 and Theroem 2.2, we see that the coded elastic computing technique in Algorithm 1 achieves the fundamental limit because each data point has dimension d and each entry has entropy H. We note a nuance here that the linear combinations in Algorithm 1 may make each encoded number have entropy larger than H. However, this can be solved if (i) we approximate the real-number computation using the computations in a finite field and assume each number in the data matrix X has a uniform distribution over the finite field [76], or (ii) we assume that each entry in the data matrix comes from a quantized version of the standard Gaussian-distribution, and assume that the encoding matrix has normalized rows, such that the linear combination result in (1) (before quantization) is also from the standard Gaussian distribution. To make the point (ii) formal, suppose an arbitrary entry in the data matrix X k is sampled from i.i.d. standard Gaussian and quantized to q(y k ) (here y k ∼ N (0, 1)). A linear combination of the samples has the form L k=1 g s,k q(y k ) (see equation (1)), where the linear combination coefficients satisfies L k=1 g 2 s,k = 1. Then, the linear combination is stored as q( L k=1 g s,k q(y k )) in the s-th machine. Since the unquantized sum L k=1 g s,k y k is a standard Gaussian random variable, its quantized version q( L k=1 g s,k y k ) has the same entropy as each q(y k ). Therefore, we only need to show that q( L k=1 g s,k q(y k )) has an entropy that is close to q( L k=1 g s,k y k ). This can be proved by bounding the difference in the entropy, because the two random variables q( L k=1 g s,k q(y k )) and q( L k=1 g s,k y k ) have the same support, and their pmf's can be made arbitrarily close when the quantization function q has a quantization level ∆ → 0. Remark 3. Note that the claim (b) has to be stated in a worst-case way because for many choices of w, computing Xw can be degenerated. For example, if we know in advance that w only takes value in a very small finite set of vectors, we can compute Xw for all possible w and store these vectors. When w is sparse, we also do not need to read the entire matrix X. Therefore, we indeed need to state the fundamental lower bound in terms of the worst-case w.
Proof. Now, we prove statement (a). Suppose an arbitrary set of n − L machines fail. Since the algorithm is tolerant to any n − L failures, the master node can still recover exactly all the results Xw, no matter what w is. Therefore, we can choose w to be the elements of natural basis w = e i , i = 1, 2, . . . , d, and collect all the results [Xe 1 , Xe 2 , . . . , Xe d ] = XI d = X. Since data processing can only reduce entropy (from the data processing inequality), the entropy of the overall data stored at the remaining L machines is no less than the entropy of X which is N dH. This holds for any combination of L machines, i.e., Adding up the above equation for all combinations of L out of n machines, and by plugging in Then, we prove statement (b). Suppose (b) is not true. Then, it means that there exists a way to encode and store the encoded data in the memory of the machines, such that for any arbitrary vector w, computing Xw only requires reading data of entropy strictly less than N dH. Since the overall number of stored data is finite, we can assume that the overall number of stored numbers is p. For an arbitrary subset S of the stored numbers such that H(S) < N dH, we denote by P S the set of w such that Xw is able to be computed using only the numbers in S. Then, we can see that the P S for an arbitrary subset S is a linear subspace of R d . This is because if Xw 1 and Xw 2 are both able to be computed using the numbers in S, then, aXw 1 + bXw 2 = X(aw 1 + bw 2 ) is also able to be computed. Now, we prove that P S cannot be the entire R d that w can take value from. This is because if P S is equal to R d , then Xe 1 , Xe 2 , . . . , Xe d are all able to be computed using the numbers in S (e 1 , . . . e d are the standard basis), which means X itself is able to be computed using S. This is a clear contradiction to the data-processing inequality because H(X) = N dH, while H(S) < N dH. Thus, P S can at most be a linear space of dimension d − 1 in R d . This means the union of P S for all S is a finite collection of linear spaces of dimension d − 1 in R d , which cannot cover the entire R d . Thus, there must exist w in R d such that Xw is not able to be computed by using data of entropy strictly less than N dH.
Non-elastic coded computing cannot adapt the algorithmic procedures to exploit new machines. We consider the case when the number of machines increases from L (i.e., the recovery threshold) to infinity with fixed storage size at each machine. We can easily see that elastic coded computing can have lower and lower memory-access time by using less and less data at each machine, while ordinary coded computing cannot because the used data remains unchanged at each machine. However, each node can have more than one linear combinations [48]. E.g., suppose L=8 linear combinations suffice to recover the result, and each machine has 8 linear combinations. Then, when the number of machines increases from 1 to 8, rateless coded computing can move between the optimal points (n, m) = (1, 8), (2,8), (4,8), (8,8), i.e., it achieves the optimal size of the selected data to use at some of the (n, m) configurations. But they cannot move beyond the point (8,8) and use more machines, because each machine, in the rateless-coded case, cannot use smaller than 1 (a fraction) of linear combinations 3 . From another perspective, for the rateless-coded scheme to achieve fully transition compatibility in the large scale, the number of linear combinations at each machine also has to grow with the number of (possible) machines, leading to scaling-sense higher decoding complexity than the elastic partitioning technique in Algorithm 1 (Note that the decoding cost in Algorithm 1 does not increase with the number of machines, and can be further reduced if parallel decoding is allowed. See Section 3.3 for details). Another advantage of coded elastic computing compared to the rateless-coded scheme is that it allows non-uniform partitioning of each row-strip (see Figure 1) and can have much more fine-grained task scheduling. Regarding the communication efficiency of coded elastic computing, see Section 3.3 for a fully-distributed version of coded elastic computing.
For task-level failures or stragglers, dynamic task allocation is useful [68,69]. The task scheduler can choose which tasks to replicate, relaunch based on task profiles, and delay the relaunching to save time [7,8,10,28,62]. However, unlike task relaunching and allocation, recovering from machine preemptions requires both restoring the machine states and downloading the data, which is time-consuming. The situation gets worse if elastic events are frequent.

Applications of the Coded Elastic Computing
The cyclic way of elastic data partitioning applies to general coded computing techniques proposed thus far and is not limited to matrix-vector multiplications.

Matrix-Matrix Multiplications
First, we consider the application of matrix-matrix multiplications. We consider an online version: we store an encoded version of the matrix A at P machines and compute the matrix multiplication AB for different B's. It is shown [24,25,77] that the storage-optimal technique for coded robust matrix multiplications is the MatDot scheme proposed in [24,25]. This technique partitions the matrix A column-wise and the matrix B row-wise, and stores linearly combined submatrices of A and B at each machine. In an online setting with elastic machine preemptions, we encode and store A at the initial stage, and do not move A anymore. When we receive B, we still partition the matrix B row-wise but linearly combine them using the knowledge of the availability of the machines. The advantage is that we do not need to use the polynomial-based codes and can thus avoid possible numerical issues. At the same time, since the availability of the machines are known before we encode B, we can also remove the factor of 2 in the recovery threshold of MatDot codes. We can also use the same computational time cost as the uncoded case, which is similar to what we can achieve in the matrix-vector case.
More precisely, suppose we parition the matrix A into L column blocks A 1 , . . . , A L , and encode these blocks initially into P blocks A coded s , s = 1, 2, . . . , P , where P is the initial number of machines: Denote by G Pmax×L the predetermined encoding matrix [g s,k ], which is of size P max × L. Again, the extra linear combinations A coded s , s = P + 1, P + 2, . . . , P max can be generated offline before the computation and stored on the cloud. Assume there are currently n machines that remain. Similar to Algorithm 1, we partition each coded sub-matrix A coded s into n submatrices. However, here, we partition each A coded s column-wise to A coded s,i , i = 1, 2, . . . , n. This is mathematically equivalent to partitioning each uncoded submatrix A s into A s,i , i = 1, 2, . . . , n, and compute A coded The subscript s in A s,i belongs to a subset with size n of the set {1, 2, . . . , P max }, which corresponds to the n available machines after the preemption failures. We again select to use these submatrices A s,i in a cyclic fashion, just as shown in Figure 1. For example, consider the case when P = 6, L = 3, n = 4 and the 2nd and the 4th machines are preempted, which is exactly the same as shown in Figure 1(d). Then, we use A 1,1 , A 1,2 , A 1,3 at the 1st machine, A 3,2 , A 3,3 , A 3,4 at the 3rd machine, and so on. Denote by S i the set of the indices of all the machines that use A s,i . For example, for i = 1, in the above example, S 1 = {1, 5, 6}. Again, similar to Section 2.4, denote by G i the submatrix of G with row indices in S i . Each G i is a L × L matrix. Denote by and assume H i has element h l,k , l = 1, 2, . . . , L, k = 1, 2, . . . , L.
When we get the matrix B, we partition it row-wise into L blocks B 1 , B 2 , . . . , B L . Then, we partition each submatrix B k into n row blocks B k,i , i = 1, 2, . . . , n as well. For each i, suppose S i = {s i,1 , s i,2 , . . . , s i,L }, where 1 ≤ s i,1 < s i,2 < . . . < s i,L ≤ n. Then, we encode and send B coded s i,l ,i to the s i,l -th machine to compute A coded s i,l ,i B coded s i,l ,i . Now, we show that when we do a reduction on all the partial results A coded s i,l ,i B coded s i,l ,i , we can indeed get AB. Lemma 3.1. If we use the cyclic partitioning technique to determine each S i = {s i,1 , s i,2 , . . . , s i,L } and encode B according to (7), we have Proof. Note that where (a) holds because [g s i,l ,1 , g s i,l ,2 , . . . , g s i,l ,L ] is the s i,l -th row in G, which is the l-th row in G i (recall that G i is the submatrix of G with row indices in S i = {s i,1 , s i,2 , . . . , s i,L }). Thus, by adding up the above equation for all l, we have that for each i, where the equation (a) holds because H i = (G i ) −1 (see equation (6)). Adding up the above equation for all i, we have Remark 4. (Cost analysis) We can see that the computational cost for this algorithm comes from two parts: (1) the encoding of B using (7), and (2) the computational cost of A coded Computation of a single A coded s i,l ,i B coded s i,l ,i has complexity d A × N/L/n × d B , and each machine computes L different A coded s i,l ,i B coded s i,l ,i , which means the overall complexity is d A ×N/L/n×d B ×L = d A d B N/n. Note that this is in the order of Θ(N 3 ) and the complexity is the same as distributing the matrix-matrix multiplication task to n machines. The encoding time is much less than the computation time per worker if Ld B N d A d B N/n, or Ln d A . If the encoding time is much smaller than the matrix-multiplication time, we again achieve linear scaling of the theoretical computational complexity in the number of available machines n without moving data at the existing machines. At the same time, the computation time cost is the same at each worker machine as the uncoded case, which means that the factor 2 in the MatDot codes [24] can be removed 4 .

Coded Elastic Computing for Linear Models
Then, we focus on the application of coded computing for linear regression [40,44]. For the ease of presentation, we consider vanilla gradient descent (we also use line search in the experiment validation for all competing techniques), in which the full matrix X is used at each iteration. The technique developed here naturally generalizes to stochastic gradient descent and other generalized linear models such as logistic regression. Consider the linear objective function: The vanilla distributed gradient descent has the form w t+1 = w t − ηg t and g t = X (Xw t − y) + ∂ w h(w t ). When the data matrix X is large, the most time-consuming part is the computation of X (Xw t − y). We thus extend Algorithm 1 in the following way to compute X (Xw t − y). It is nothing but a combination of Algorithm 1 and the matrix-matrix multiplication algorithm in Section 3.1.
• Compute X j w t (where X j is the data in the j-th group, or the j-th row block in Figure 1 across different machines) for all group-index j in an elastic way using Algorithm 1; • The master computes z j t = X j w t − y j for all group-index j, where y j are the labels corresponding to the data points in the j-th group; • The master re-encodes z j t 's using the (pre-computed) inverse generator matrix H j = (G −1 j ) to obtain (G −1 j ) z j t , and scatters the results to the workers that use the j-th group of data; • Since data at workers are encoded using G j , the reduced results from all the workers are Note that in the above extension of Algorithm 1, the workers also utilize the data as in Figure 1. The experiment results of coded elastic computing in linear models are provided in Section 4.

Fully Distributed Coded Elastic Computing
Coded elastic computing is not restricted to a master-worker setting. In this section, we consider a fully distributed coded elastic matrix-vector multiplication technique that is a trivial generalization of Algorithm 1. The advantage of a fully distributed framework is that communication among workers can be overlapped and the communication to the master does not become the single bottleneck in the limit of a large number of machines. Consider an application of iterative matrix-vector multiplication where X is a square data matrix, and f (·) is an entry-wise low-complexity operation on the vector Xw t . We again consider the example shown in Figure 1, 5 but apart from the 6 worker machines, there is no master-node. In each iteration, each machine computes its own matrix-vector multiplication based on the selected data to use. For example, the 2nd machine computes b 2 w t , c 2 w t , d 2 w t , and stacks the results into one vector. Then, the results at each machine can be broadcast to all the other machines using an all-gather communication (using a bucketing algorithm [12]). The communication is also done in a cyclic way so that all the communications can be maximally overlapped (i.e., all machines can communicate at the same time). In this way, the communication bandwidth can be reduced when compared to the master-worker framework. Moreover, the overall communication time in this scheme is the same as the uncoded scheme using the same number of machines, because the selected size of data at each machine is the same as the uncoded case. The decoding of the intermediate results at each iteration is done independently at each machine. The decoding can also be conducted distributedly for each group of data (each row-block), i.e., each machine only takes care of the decoding of each row-block. This can significantly reduce the decoding time, but requires removes the factor of 2 because we consider a different problem: the system becomes aware of the indices of the failed machines after the preemptions have happened, and can adaptively change the encoding of B. 5 Note that the example in Figure 1 partitions the data row-wise. The column-wise partition can use the elastic coding scheme in Section 3.1, which is essentially an elastic dot-product scheme. all machines to exchange different messages twice and carry out an all-to-all communication [15]. Also, the smaller communication is possible at the cost of more storage or computation [6,45,60,75] in the individual machines .

Application to Deep Neural Networks
The proposed coded elastic data partitioning directly applies to the coded training of model-parallel deep neural networks [20,21]. The coded computation in [20,21] utilizes a novel technique called PolyDot, which adopts a 2D partitioning on the weight matrices of a neural network and encodes the weight matrices using polynomial-based codes. The way to apply coded elastic data partitioning to the PolyDot technique is exactly the same as Section 2.3: • In PolyDot, each machine has one encoded submatrix of the weight matrix. Partition each encoded submatrix in Polydot into n small submatrices. Recall that n represents the number of currently available machines.
• Let each machine select to compute the matrix-vector multiplication using only L out of n small submatrices. Recall that L is the recovery threshold.
• The selection is done in a cyclic way as well to ensure that there are enough encoded computation results to decode the original computation results.
Note that the matrix-vector multiplication in [20,21] requires both forward pass and backward pass. This means that for the weight matrix W, we need to compute matrix-vector multiplications in two ways, i.e., Wx and W x. Therefore, in the forward pass, the partitioning of the encoded weight submatrix at each machine should be done in a row-wise way, which is similar to Section 2.3. In the backward pass, the partitoining should be done in a column-wise way because one needs to compute W x.

Implementation and Experimental Evaluation
The proposed coded elastic computing technique has been implemented on top of Apache REEF [18] Elastic Group Communication (EGC) framework 6 . REEF EGC provides an API allowing to implement elastic computations by chaining fault-tolerant MPI-like primitives. In this short paper we assess the performance of our elastic code computing approach through 2 mini-benchmarks.
Matrix-vector mini-benchmark. In this mini-benchmark, we test that indeed the time cost decreases linearly with the increase in the number of machines available. We mimic an elastic computing environment on Amazon EC2 by using different numbers of M4.large instances to compute the same matrix-vector product Xw. The master node is a M4.4xlarge machine. The matrix is randomly generated and with size 100000 × 10000, and it is partitioned initially into 10 submatrices of size 10000 × 10000. Then, they are encoded into 20 submatrices of the same size, and each submatrix is stored at one machine (for a total of 20 machines). To mimic the elastic events, we change the number of available machines by injecting artificial failures. The maximum number of failures is 10. The per-iteration overall time (including both communication and computation) is shown in Figure 2(a). The result is averaged using 20 independent trials. As we can see, the coded elastic computing technique can utilize the extra machines when the number of machines increases (see the blue bars). We also compare it with a non-adaptive coded computation baseline. It can be seen that when the number of machines increases, the adaptive scheme can provide increasing speedup when compared to the non-adaptive coded computing scheme 7 . The maximum observed speedup in our experiment is 46%.
Linear model mini-benchmark. In this experiment, we test a coded implementation of linear regression using line-search-based batch gradient descent (the same setting as the baseline [50]). We run the test over 20 machines on a Microsoft internal multi-tenancy cluster. Each data point in the dataset has 3352 features, and we sample 10000 data for training and 10000 data for testing. We generate random failures and allow REEF EGC to reschedule new machines when failures occur. We start with Figure 2(b) where we plot the time for each iteration. In theory, when all the workers are present, the computational cost per iteration should be the same as the uncoded case. However, the coded method (all) has slight overhead due to coding and a second round of communication for coded linear regression using matrix-vector multiplications. The coded method (half) shows the cost when only half of the workers are running, which is, as expected, twice the cost of the uncoded method. In Figure 2(c) and 2(d) we report the generalization error and we compare our coded elastic computing technique with three baselines, namely noiseless (no failure), ignore the failure and continue, and an existing algorithm called Elastic Distr-BGD [50]. The coded method can achieve the same convergence behavior as the noiseless case, while the ignore method achieves worst generalization error even for different regularization parameters (the other techniques all use the same regularization 8 coefficient 0.001). In Figure 2(c), we show 5 different experiments on Distr-BGD using the same failure probability but different realizations. The convergence of Distr-BGD depends on when a failure occurs and can lead to different algorithm performance. This is because the Distr-BGD keeps using previous gradient vectors at the failed machines, and this can (1) lead to overfitting, and (2) make the optimization miss the minimum point. In the plot of Distr-BGD, the valley part is due to overfitting, and the sudden change to near flat loss growth is because when the gradient descent has missed the optimal point of empirical training loss, the fixed gradient at the failure nodes makes the line search choose the smallest step size. In some cases, the Distr-BGD works extremely well because the fixed gradients act like momentum and can improve the speed of convergence.
From the experiment results, we can see that the coded elastic computing technique can obtain the same convergence behavior as ordinary gradient-descent-based algorithms but can elastically allocate the workload based on the number of available machines without moving data around.

Conclusions
The coded elastic computing framework presented in this paper can deal with new cloud offerings where machines can leave and join during the computation. Our framework handles the elastic events in a positive way, meaning that when machines leave, it shifts the computation to the remaining workers, and when new machines join the computation, it actively reduces the workload of existing machines without the reallocation of data. We prove that the coded elastic computing technique can achieve the same memory-access cost as the noiseless case, and hence is optimal for memory-bound applications. Using experiments in both Amazon EC2 and on a Microsoft multi-tenancy cluster, we show that the coded elastic computing technique can achieve the same convergence behavior as if no failure occurs, and can dynamically adjust working loads respect to the number of remaining workers. The proposed technique can be applied to coded matrix-vector, matrix-matrix multiplications and linear regression, and potentially other applications where the large-scale matrix operations are the bottleneck.