Ensuring Rapid Mixing and Low Bias for Asynchronous Gibbs Sampling
Christopher De Sa, Kunle Olukotun, Christopher Ré
Introduction
Gibbs sampling is one of the most common Markov chain Monte Carlo methods used with graphical models . In this setting, Gibbs sampling (Algorithm 1) operates iteratively by choosing at random a variable from the model at each timestep, and updating it by sampling from its conditional distribution given the other variables in the model. Often, it is applied to inference problems, in which we are trying to estimate the marginal probabilities of some query events in a given distribution.
For sparse graphical models, to which Gibbs sampling is often applied, each of these updates needs to read the values of only a small subset of the variables; therefore each update can be computed very quickly on modern hardware. Because of this and other useful properties of Gibbs sampling, many systems use Gibbs sampling to perform inference on big data .
Since Gibbs sampling is such a ubiquitous algorithm, it is important to try to optimize its execution speed on modern hardware. Unfortunately, while modern computer hardware has been trending towards more parallel architectures , traditional Gibbs sampling is an inherently sequential algorithm; that is, the loop in Algorithm 1 is not directly parallelizable. Furthermore, for sparse models, very little work happens within each iteration, meaning it is difficult to extract much parallelism from the body of this loop. Since traditional Gibbs sampling parallelizes so poorly, it is interesting to study variants of Gibbs sampling that can be parallelized. Several such variants have been proposed, including applications to latent Dirichlet allocation and distributed constraint optimization problems .
In one popular variant, multiple threads run the Gibbs sampling update rule in parallel without locks, a strategy called asynchronous or Hogwild! execution—in this paper, we use these two terms interchangeably. This idea was proposed, but not analyzed theoretically, in Smola & Narayanamurthy , and has been shown to give empirically better results on many models . But when can we be sure that Hogwild! Gibbs sampling will produce accurate results? Except for the case of Gaussian random variables , there is no existing analysis by which we can ensure that asynchronous Gibbs sampling will be appropriate for a particular application. Even the problems posed by Hogwild!-Gibbs are poorly understood, and their solutions more so.
As we will show in the following sections, there are two main issues when analyzing asynchronous Gibbs sampling. Firstly, we will show by example that, surprisingly, Hogwild!-Gibbs can be biased—unlike sequential Gibbs, it does not always produce samples that are arbitrarily close to the target distribution. Secondly, we will show that the mixing time (the time for the chain to become close to its stationary distribution) of asynchronous Gibbs sampling can be up to exponentially greater than that of the corresponding sequential chain.
To address the issue of bias, we need some way to describe the distance between the target distribution and the distribution of the samples produced by Hogwild!-Gibbs. The standard notion to use here is the total variation distance, but for the task of computing marginal probabilities, it gives an overestimate on the error caused by bias. To better describe the bias, we introduce a new notion of statistical distance, the sparse variation distance. While this relaxed notion of statistical distance is interesting in its own right, its main benefit here is that it uses a more local view of the chain to more tightly measure the effect of bias.
Our main goal is to identify conditions under which the bias and mixing time of asynchronous Gibbs can be bounded. One parameter that has been used to great effect in the analysis of Gibbs sampling is the total influence of a model. The total influence measures the degree to which the marginal distribution of a variable can depend on the values of the other variables in the model—this parameter has appeared as part of a celebrated line of work on Dobrushin’s condition (), which ensures the rapid mixing of spin statistics systems . It turns out that we can use this parameter to bound both the bias and mixing time of Hogwild!-Gibbs, and so we make the following contributions:
We describe a way to statistically model the asynchronicity in Hogwild!-Gibbs sampling.
To bound the bias, we prove that for classes of models with bounded total influence , if sequential Gibbs sampling achieves small sparse variation distance to in steps, where is the number of variables, then Hogwild!-Gibbs samples achieve the same distance in at most more steps.
For models that satisfy Dobrushin’s condition (that is, ), we show that the mixing time bounds of sequential and Hogwild!-Gibbs sampling differ only by a factor of .
We validate our results experimentally and show that, by using asynchronous execution, we can achieve wall-clock speedups of up to on real problems.
Related Work
Much work has been done on the analysis of parallel Gibbs samplers. One simple way to parallelize Gibbs sampling is to run multiple chains independently in parallel: this heuristic uses parallelism to produce more samples overall, but does not produce accurate samples more quickly. Additionally, this strategy is sometimes worse than other strategies on a systems level , typically because it requires additional memory to maintain multiple models of the chain. Another strategy for parallelizing Gibbs sampling involves taking advantage of the structure of the underlying factor graph to run in parallel while still maintaining an execution pattern to which the standard sequential Gibbs sampling analysis can be applied . Much further work has focused on parallelizing sampling for specific problems, such as LDA and others .
Our approach follows on the paper of Johnson et al. , which named the Hogwild!-Gibbs sampling algorithm and analyzed it for Gaussian models. Their main contribution is an analysis framework that includes a sufficient condition under which Hogwild! Gaussian Gibbs samples are guaranteed to have the correct asymptotic mean. Recent work has analyzed a similar algorithm under even stronger regularity conditions. Here, we seek to give more general results for the analysis of Hogwild!-Gibbs sampling on discrete-valued factor graphs.
The Hogwild!-Gibbs sampling algorithm was inspired by a line of work on parallelizing stochastic gradient descent (SGD) by running it asynchronously. Hogwild! SGD was first proposed by Niu et al. , who proved that while running without locks causes race conditions, they do not significantly impede the convergence of the algorithm. The asynchronous execution strategy has been applied to many problems—such as PageRank approximations , deep learning and recommender systems —so it is not surprising that it has been proposed for use with Gibbs sampling. Our goal in this paper is to combine analysis ideas that have been applied to Gibbs sampling and Hogwild!, in order to characterize the behavior of asynchronous Gibbs. In particular, we are motivated by some recent work on the analysis of Hogwild! for SGD . Several of these results suggest modeling the race conditions inherent in Hogwild! SGD as noise in a stochastic process; this lets them bring a trove of statistical techniques to bear on the analysis of Hogwild! SGD. Therefore, in this paper, we will apply a similar stochastic process model to Gibbs sampling.
Several recent papers have focused on the mixing time of Gibbs sampling based on the structural properties of the model. Gotovos et al. and De Sa et al. each show that Gibbs sampling mixes in polynomial time for a class of distributions bounded by some parameter. Unfortunately, these results both depend on spectral methods (that try to bound the spectral gap of the Markov transition matrix), which are difficult to apply to Hogwild! Gibbs sampling for two reasons. First, spectral methods don’t let us represent the sampler as a stochastic process, which limits the range of techniques we can use to model the noise. Secondly, while most spectral methods only apply to reversible Markov chains—and sequential Gibbs sampling is always a reversible chain—for Hogwild!-Gibbs sampling the asynchronicity and parallelism make the chain non-reversible. Because of this, we were unable to use these spectral results in our asynchronous setting. We are forced to rely on the other method for analyzing Markov processes, coupling—the type of analysis used with the Dobrushin condition—which we will describe in the following sections.
Modeling Asynchronicity
In this section, we describe a statistical model for asynchronous Gibbs sampling by adapting the hardware model outlined in De Sa et al. . Because we are motivated by the factor graph inference problem, we will focus on the case where the distribution that we want to sample comes from a sparse, discrete graphical model.
Any Hogwild!-Gibbs implementation involves some number of threads each repeatedly executing the Gibbs update rule on a single copy of the model (typically stored in RAM). We assume that this model serializes all writes, such that we can speak of the state of the system after writes have occurred. We call this time , and we will model the Hogwild! system as a stochastic process adapted to the natural filtration . Here, contains all events that have occurred up to time , and we say an event is measurable if it is known deterministically by time .
this represents the fact that we have an equal probability of sampling each variable.
Using this, we can relate the values of the variables across time with
This parameter is typically very close to the expected value bound ; in particular, as approaches infinity, approaches .
The First Challenge: Bias
Perhaps the most basic result about sequential Gibbs sampling is the fact that, in the limit of large numbers of samples, it is unbiased. In order to measure convergence of Markov chains to their stationary distribution, it is standard to use the total variation distance.
The total variation distance [12, p. 48] between two probability measures and on probability space is defined as
that is, the maximum difference between the probabilities that and assign to a single event .
It is a well-known result that, for Gibbs sampling on a strictly-positive target distribution , it will hold that
where denotes the distribution of the -th sample.
One of the difficulties that arises when applying Hogwild! to Gibbs sampling is that the race conditions from the asynchronous execution add bias to the samples — Equation 1 no longer holds. To understand why, we can consider a simple example.
Consider a simple model with two variables and each taking on values in , and having distribution
Sequential Gibbs sampling on this model will produce unbiased samples from the target distribution. Unfortunately, this is not the case if we run Hogwild!-Gibbs sampling on this model. Assume that the state is currently and two threads, and , simultaneously update and respectively. Since reads state it will update to or each with probability ; the same will be true for and . Therefore, after this happens, every state will have probability ; this includes the state which should never occur! Over time, this race condition will produce samples with value with some non-zero frequency; this is an example of bias introduced by the Hogwild! sampling. Worse, this bias is not just theoretical: Figure 2 illustrates how the measured distribution for this model is affected by two-thread asynchronous execution. In particular, we observe that almost of the mass is erroneously measured to be in the state , which has no mass at all in the true distribution. The total variation distance to the target distribution is quite large at , and, unlike in the sequential case, this bias doesn’t disappear as the number of samples goes to infinity.
2 Bounding the Bias
The previous example has shown that asynchronous Gibbs sampling will not necessarily produce a sequence of samples arbitrarily close to the target distribution. Instead, the samples may approach some other distribution, which we hope is sufficiently similar for some practical purpose. Often, the purpose of Gibbs sampling is to estimate the marginal distributions of individual variables or of events that each depend on only a small number of variables in the model. To characterize the accuracy of these estimates, the total variation distance is too conservative: it depends on the difference over all the events in the space, when most of these are events that we do not care about. To address this, we introduce the following definition.
For any event in a probability space over a set of variables , let denote the number of variables upon which depends. Then, for any two distributions and over , we define the -sparse variation distance to be
For the wide variety of applications that use sampling for marginal estimation, the sparse variation distance measures the quantity we actually care about: the maximum possible bias in the marginal distribution of the samples. As we will show, asynchronous execution seems to have less effect on the sparse variation distance than the total variation distance, because sparse variation distance uses a more localized view of the chain. For example, in Figure 2, the total variation distance between the sequential and Hogwild! distributions is , while the -sparse variation distance is only . That is, while Hogwild! execution does introduce great bias into the distribution, it still estimates marginals of the individual variables accurately.
This definition suggests the question: how long do we have to run before our samples have low sparse variation distance from the target distribution? To answer this question, we introduce the following definition.
The -sparse estimation time of a stochastic sampler with distribution at time and target distribution is the first time at which, for any initial distribution , the estimated distribution is within sparse variation distance of ,
In many practical systems , Gibbs sampling is used without a proof that it works; instead, it is naively run for some fixed number of passes through the dataset. This naive strategy works for models for which accurate marginal estimates can be achieved after samples. This runtime is necessary for Gibbs sampling to be feasible on big data, meaning roughly that these are the models which it is interesting to try to speed up using asynchronous execution. Therefore, for the rest of this section, we will focus on the bias of the Hogwild! chain for this class of models. When analyzing Gibbs sampling, we can bound the bias within the context of a coupling argument using a parameter called the total influence. While we arrived at this condition independently, it has been studied before, especially in the context of Dobrushin’s condition, which ensures rapid mixing of Gibbs sampling.
Let be a probability distribution over some set of variables . Let be the set of state pairs which differ only at variable . Let denote the conditional distribution in of variable given all the other variables in state . Then, define , the total influence of , as
We say the model satisfies Dobrushin’s condition if .
One way to think of total influence for factor graphs is as a generalization of maximum degree; indeed, if a factor graph has maximum degree , it can easily be shown that . It turns out that if we can bound both this parameter and the sparse estimation time of sequential Gibbs sampling, we can give a simple bound on the sparse estimation time for asynchronous Gibbs sampling.
where is the number of variables in the model. Then, for any , the sparse estimation time of Hogwild!-Gibbs across all models is bounded by
Roughly, this means that Hogwild!-Gibbs sampling “works” on all problems for which we know marginal estimation is “fast” and the total influence is bounded. Since the sparse estimation times here are measured in iterations, and the asynchronous sampler is able, due to parallelism, to run many more iterations in the same amount of wall clock time, this result implies that Hogwild!-Gibbs can be much faster than sequential Gibbs for producing estimates of similar quality. To prove Claim 1, and more explicitly bound the bias, we use the following lemma.
where denotes if and otherwise.
This lemma bounds the distance between the distributions of asynchronous and sequential Gibbs; if we let be the sparse estimation time of sequential Gibbs, we can interpret this distance as an upper bound on the bias. When , this bias is , which has an intuitive explanation: for Hogwild! execution, race conditions occur about once every iterations, so the bias is roughly proportional to the frequency of race conditions. This gives us a relationship between the statistical error of the algorithm and a more traditional notion of computational error.
Up until now, we have been assuming that we have a class for which the sparse estimation time is . Using the total influence , we can identify a class of models known to meet this criterion.
For any distribution that satisfies Dobrushin’s condition, , the -sparse estimation time of the sequential Gibbs sampling process will be bounded by
This surprising result says that, in order to produce good marginal estimates for any model that satisfies Dobrushin’s condition, we need only samples! While we could now use Lemma 1 to bound the sparse estimation time for Hogwild!-Gibbs, a more direct analysis produces a slightly better result, which we present here.
For any distribution that satisfies Dobrushin’s condition, , and for any that satisfies
the -sparse estimation time of the Hogwild! Gibbs sampling process will be bounded by
This result gives us a definite class of models for which Hogwild!-Gibbs sampling is guaranteed to produce accurate marginal estimates quickly.
The Second Challenge: Mixing Times
Even though the Hogwild!-Gibbs sampler produces biased estimates, it is still interesting to analyze how long we need to run it before the samples it produces are independent of its initial conditions. To measure the efficiency of a Markov chain, it is standard to use the mixing time.
The mixing time [12, p. 55] of a stochastic process with transition matrix at time and target distribution is the first time at which, for any initial distribution , the estimated distribution is within TV-distance of . That is,
As we did with bias, here we construct an example model for which asynchronous execution disastrously increases the mixing time. The model we will construct is rather extreme; we choose this model because simpler, practical models do not seem to exhibit this type of catastrophic increase in the mixing time. We start, for some odd constant , with variables all in , and one factor with energy
for some very large energy parameter . The resulting distribution will be almost uniform over all states with . To this model, we add another bank of variables all in . These variables also have a single associated factor with energy
for parameters and . Combining these two factors gives us the overall distribution for our model,
where is the constant necessary for this to be a distribution. Roughly, the dynamics are constructed to regularly “generate” race conditions, while the dynamics are chosen to “detect” these race conditions and mix very slowly as a result. This model is illustrated in Figure 3.
We simulated two-thread Hogwild!-Gibbs on this model, measuring the marginal probability that ; by symmetry, this event has probability in the stationary distribution for both the sequential and asynchronous samplers. Our results, for a model with , , , and , and initial state , are plotted in Figure 4. Notice that, while the sequential sampler achieves the correct marginal probability relatively quickly, the asynchronous samplers take a much longer time to achieve the correct result, even for a relatively small expected delay (). These results suggest that something catastrophic is happening to the mixing time when we switch from sequential to asynchronous execution — and in fact we can prove this is the case.
For the example model described above, there exist parameters , , and (as a function of ) such that the mixing time of sequential Gibbs sampling is but the mixing time of Hogwild!-Gibbs sampling, even with , can be .
The intuition behind this statement is that for sequential Gibbs, the dynamics of the part of the chain quickly causes it to have , and then remain there for the remainder of the simulation with high probability. This in turn causes the energy of the factor to be essentially , a model which is known to be fast-mixing because it satisfies Dobrushin’s condition. On the other hand, for Hogwild! Gibbs, due to race conditions we will see with constant probability; this will cause the effective energy of the factor to be dominated by the term, a model that is known to take exponential time to mix.
2 Bounding the Mixing Time
This example shows that fast mixing of the sequential sampler alone is not sufficient to guarantee fast mixing of the Hogwild! chain. Consequently, we look for classes of models for which we can say something about the mixing time of both sequential and Hogwild!-Gibbs. Dobrushin’s condition is well known to imply rapid mixing of sequential Gibbs, and it turns out that we can leverage it again here to bound the mixing time of Hogwild!-Gibbs.
Assume that we run Gibbs sampling on a distribution that satisfies Dobrushin’s condition, . Then the mixing time of sequential Gibbs will be bounded by
Under the same conditions, the mixing time of Hogwild!-Gibbs will be bounded by
The above example does not contradict this result since it does not satisfy Dobrushin’s condition; in fact its total influence is very large and scales with . We can compare these two mixing time results as
the bounds on the mixing times differ by a negligible factor of . This result shows that, for problems that satisfy Dobrusin’s condition, Hogwild!-Gibbs sampling mixes in about the same time as sequential Gibbs sampling, and is therefore a practical choice for generating samples.
3 A Positive Example: Ising Model
To gain intuition here, we consider a simple example. The Ising model on a graph is a model over probability space , and has distribution
where is a parameter that is called the inverse temperature, the are parameters that encode a prior on the variables, and is the normalization constant necessary for this to be a distribution. For graphs of maximum degree and sufficiently small , a bound on the mixing time of Gibbs sampling is known when . It turns out that the total influence of the Ising model can be bounded by , and so this condition is simply another way of writing Dobrushin’s condition. We can therefore apply Theorem 3 to bound the mixing time of Hogwild!-Gibbs with
This illustrates that the class of graphs we are considering includes some common, well-studied models.
4 Proof Outline
In order to bound the probability that the chains are not equal at a particular time , we focus on the quantity
Experiments
Now that we have derived a theoretical characterization of the behavior of Hogwild!-Gibbs sampling, we examine whether this characterization holds up under experimental evaluation. First, we examine the mixing time claims we made in Section 5. Specifically, we want to check whether increasing the expected delay parameter actually increases the mixing time as predicted by Equation 2.
To do this, we simulated Hogwild!-Gibbs sampling running on a random synthetic Ising model graph of order , degree , inverse temperature , and prior weights . This model has total influence , and Theorem 3 guarantees that it will mix rapidly. Unfortunately, the mixing time of a chain is difficult to calculate experimentally. While techniques such as coupling from the past exist for estimating the mixing time, using these techniques in order to expose the (relatively small) dependence of the mixing time on proved to be computationally intractable.
Of course, in order for Hogwild!-Gibbs to be useful, it must also speed up the execution of Gibbs sampling on some practical models. It is already known that this is the case, as these types of algorithms been widely implemented in practice . To further test this, we ran Hogwild!-Gibbs sampling on a real-world GB Knowledge Base Population dataset (derived from the TAC-KBP challenge) using a machine with a single-socket, 18-core Xeon E7-8890 CPU and TB RAM. As a comparison, we also ran a “multi-model” Gibbs sampler: this consists of multiple threads with a single execution of Gibbs sampling running independently in each thread. This sampler will produce the same number of samples as Hogwild!-Gibbs, but will require more memory to store multiple copies of the model.
Figure 6 reports the speedup, in terms of wall-clock time, achieved by Hogwild!-Gibbs on this dataset. On this machine, we get speedups of up to , although the program becomes memory-bandwidth bound at around threads, and we see no significant speedup beyond this. With any number of workers, the run time of Hogwild!-Gibbs is close to that of multi-model Gibbs, which illustrates that the additional cache contention caused by the Hogwild! updates has little effect on the algorithm’s performance.
Conclusion
We analyzed Hogwild!-Gibbs sampling, a heuristic for parallelized MCMC sampling, on discrete-valued graphical models. First, we constructed a statistical model for Hogwild!-Gibbs by adapting a model already used for the analysis of asynchronous SGD. Next, we illustrated a major issue with Hogwild!-Gibbs sampling: that it produces biased samples. To address this, we proved that if for some class of models with bounded total influence, only sequential Gibbs samples are necessary to produce good marginal estimates, then Hogwild!-Gibbs sampling produces equally good estimates after only additional steps. Additionally, for models that satisfy Dobrushin’s condition (), we proved mixing time bounds for sequential and asynchronous Gibbs sampling that differ by only a factor of . Finally, we showed that our theory matches experimental results, and that Hogwild!-Gibbs produces speedups up to on a real dataset.
The authors acknowledge the support of: DARPA FA8750-12-2-0335; NSF IIS-1247701; NSF CCF-1111943; DOE 108845; NSF CCF-1337375; DARPA FA8750-13-2-0039; NSF IIS-1353606; ONR N000141210041 and N000141310129; NIH U54EB020405; Oracle; NVIDIA; Huawei; SAP Labs; Sloan Research Fellowship; Moore Foundation; American Family Insurance; Google; and Toshiba.
“The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies or endorsements, either expressed or implied, of DARPA, AFRL, NSF, ONR, NIH, or the U.S. Government.”
References
Appendix A Additional Bias Results
In this section, we present the following additional result that bounds the sparse estimation time of general Gibbs samplers. In particular, this theorem provides an explicit form of the result given in Claim 1.
Then, as long as is large enough that
where we use the notation , the -sparse estimation time of the Hogwild! chain can be bounded with
Appendix B Proofs
Here, we provide proofs for the results in the paper. In the first subsection, we will state lemmas and known results that we will use in the subsequent proofs. Next, we will prove the Claims and Theorems stated in the body of the paper. Finally, we will prove the lemmas previously stated.
First, we state a proposition from \citetseclevin2009markov. This proposition relates the concept of a coupling with the total variation distance between the distributions of two random variables.
Let and be two random variables that take on values in the same set, and let their distributions be and , respectively. Then for any coupling, it will hold that
Furthermore, there exists a coupling for which equality is achieved; this is called an optimal coupling.
We can prove a related result for sparse variation distance.
Let and be two random variables that each assign values to a set of variables , and let their distributions be and , respectively. Then for any coupling, it will hold that
We state a lemma that bounds the expected total variation distance between the marginal distributions of two states using the total influence . Note that a similar statement to that proved in this lemma may be used as an alternate definition for the total influence ; the definition given in the body of the paper is used because it is more intuitive and does not require introducing the concept of a coupling. This lemma will be useful later when proving the subsequent lemmas stated in this subsection.
If is a distribution with total influence , and and are two random variables that take on values in the state space of , then for any variable
where, for simplicity of notation, we let denote the conditional distribution of variable in given the values of all the other variables in state .
Next, we state three lemmas, each of which give bounds on the quantity
for some coupling of two (potentially asynchronous) Gibbs sampling chains. First, we state the result for comparing two synchronous chains.
Consider sequential Gibbs sampling on a distribution with total influence . Then, for any initial states there exists a coupling of the chains such that for any variable and any time ,
Second, we state the result comparing two Hogwild! chains.
Consider any model of Hogwild!-Gibbs sampling on a distribution with total influence . Then, for any initial states there exists a coupling of the Hogwild!-Gibbs sampling chains starting at and respectively such that for any variable and any time ,
Third, we state the result comparing a sequential and an asynchronous chain.
Consider any model of Hogwild!-Gibbs sampling on a distribution with total influence . Then if for any initial states we can construct a coupling such that the process is distributed according to the dynamics of Hogwild!-Gibbs, the process is distributed according to the dynamics of sequential Gibbs, and for any time ,
As a secondary result, if the chain satisfies Dobrushin’s condition (), then for any variable and any time ,
Let be a sequence such that, for all ,
where is a function that is monotonically increasing in all of its arguments. Then, for any sequence , if and for all ,
Consider the model on variables , for odd, where each takes on values in and has probability
Then Gibbs sampling on this model (assuming that we allow the chain to start only at a state where ) has mixing time
B.2 Proofs of Bias Results
First, we restate and prove Claim 1. This proof will use the result of Theorem 4, which we will prove subsequently. We note here that the use of a convex upper bound for the sparse estimation time of the sequential chain (as opposed to using the sequential chain’s sparse estimation time directly) is an unfortunate consequence of the proof—we hope that a more careful analysis could remove it or replace it with a more natural condition.
First, note that, since , we know by the definition of big- notation that for some , for all models in the class, the total influence of that model will be . Similarly, since we assumed that, for any and across all models ,
then for each , there must exist a such that for any distribution with variables in the class,
For some error and model , we would like to apply Theorem 4 to bound its mixing time. In order to apply the theorem, we must satisfy the conditions on : it suffices for
Under this condition, applying the theorem allows us to bound the -sparse estimation time of the Hogwild! chain with
then it follows that, for any and for all models with ,
This is equivalent to saying that, for any and across all models,
Next, we restate and prove the bias lemma, Lemma 1.
We start by using the primary result from Lemma 6. This result states that we can construct a coupling of the Hogwild! and sequential chains starting at any initial distributions and such that at any time ,
Now, for any initial distribution , assume that we start with , where both are distributed according to . Then, trivially,
It follows from recursive application of the sub-result of Lemma 6 that, for this coupling,
where denotes . It follows by the union bound that, for any set of variables with , the probability that the coupling is unequal in at least one of those variables is
Since this inequality holds for any set of variable with , it follows that
We can proceed to apply Lemma 2, which lets us conclude that
Next, we restate and prove the full bias result, Theorem 4.
We start with the result of Lemma 1, which lets us conclude that
Therefore, by the triangle inequality, for any ,
Therefore, for any ,
and so, if we want this to be less than , it suffices to choose such that
Recall that as a condition for the theorem, we assumed that
It follows from this and our expression for that
Therefore this assignment of will satisfy the previous constraint that , and so for this assignment of , and for any initial distribution , it holds that
Therefore, by the definition of sparse estimation time, the sparse estimation time of the Hogwild! chain will be
for this assignment of . Now, recall that above we assigned
Under this condition, we can bound this whole error term as
Combining this with the definitions of and lets us state that
Since we above defined to be the distribution of Hogwild! Gibbs after timesteps, , where is the transition matrix of Hogwild! Gibbs after timesteps. We can thus equivalently write this as
Therefore, by the definition of sparse estimation time,
Next, we restate and prove the theorem that bounds the sparse estimation time of sequential Gibbs for distributions that satisfy Dobrushin’s condition.
We start by using the result of Lemma 4. This result states that, for any initial distributions , there exists a coupling of the sequential Gibbs sampling chains starting at distributions and , respectively, such that for any variable and any time ,
It follows by the union bound that, for any set of variables with , the probability that the coupling is unequal in at least one of those variables is
Since this inequality holds for any set of variable with , it follows that
We can proceed to apply Lemma 2, which lets us conclude that, if we let and denote the distributions of and , respectively, then
Since this was true for any initial distributions for and , it will hold in particular for distributed according to , the stationary distribution of the chain. In this case, , and so for any initial distribution for ,
Now, in order for this to be bounded by , it suffices to choose such that
(here we used the fact that to do the division). Taking the ceiling, we can conclude that when
Since we defined to be the distribution of , it must hold that , where is the initial distribution of , and is the transition matrix associated with running steps of sequential Gibbs sampling. Thus, we can rewrite this as
Since this result held for any initial assignment of and therefore for any , by the definition of sparse estimation time it follows that
Next, we restate and prove the theorem that bounds the sparse estimation time of Hogwild! Gibbs for distributions that satisfy Dobrushin’s condition.
We start by using the secondary result from Lemma 6—we can safely use this result because we assumed the chain satisfied Dobrushin’s condition (). This result states that we can construct a coupling of the Hogwild! and sequential chains starting at any initial distributions and such that at any time ,
It follows by the union bound that, for any set of variables with , the probability that the coupling is unequal in at least one of those variables is
Since this inequality holds for any set of variable with , it follows that
We can proceed to apply Lemma 2, which lets us conclude that, if we let and denote the distributions of and respectively,
To bound the sparse estimation time, notice that for any fixed (independent of ), in order to achieve
therefore is large enough that
It is easy to prove that, for all ,
Therefore, under this condition in , it suffices to choose such that
Since we defined above to be the distribution of , it follows that , where is the initial distribution of and is the transition matrix associated with running steps of Hogwild! Gibbs. Therefore, we can rewrite this as
Since this is true for any initial distribution of and therefore for any , it follows from the definition of sparse estimation time that
B.3 Proofs of Mixing Time Results
We start out by proving that the model mixes rapidly in the sequential case.
First, we assume that we select large enough that, even for potentially exponential run times, the dynamics of the chain are indistinguishable from the chain with . In particular, this alternate chain will have the following properties:
The dynamics of the part of the chain do not depend in any way on the value of .
If at any point, , whenever we sample an variable, we will re-sample it if possible to decrease the value of with probability .
As long as at some point in time, this will remain true, and the dynamics of the part of the chain will be those of the chain described in Lemma 8.
We assume that we choose large enough that these properties hold over all time windows discussed in this proof with high probability.
Now, by the coupon collector’s problem, after timesteps, we have sampled all the variables with high probability. If we have sampled all the variables with high probability, then we will certainly have with high probability.
Once we have , Lemma 8 ensures that, after additional timesteps, the part of the chain will be close to its stationary distribution.
Meanwhile, while , the dynamics of the part of the chain are exactly Gibbs sampling over the model with energy
For any , this is known to mix in time, since it satisfies Dobrushin’s condition. Therefore, after steps after we have , the part of the chain will also be close to its stationary distribution.
Summing up the times for the above events gives us a total mixing time for this chain of
Next we prove that the model takes a potentially exponential time to mix in the asynchronous case. Assume here that our model of execution has two threads, which always either sample two variables independently and asynchronously, or sample a single variable synchronously (i.e. there is never any delay when reading the value of a variable). For this execution pattern, we have uniformly that . In particular, this has .
Now, consider the case where the two threads each choose to sample a variable in that can be switched. Since at least of the variables are variables in that can be switched, this will occur with probability at least . Given this, they will each independently switch their variable with probability . This means that both variables are switched with probability — but this would place the system in a state where
At any time when , this will occur with probability , which implies that whenever we sample , the probability that is at least .
Now, assume without loss of generality that we initialize such that . Let denote the value of at time . Assuming that we sample a variable with value , while , the probability that it will be switched will be
Note that since at all times, if ,
We also can verify that, for any , as a basic property of the exponential function,
Therefore, as long as , and ,
On the other hand, if , then we can pick large enough such that with high probability, as long as , all variables are always sampled to be . In this case,
In general, since with probability at least ,
Since is written as a sum of independent samples, as long as , the distribution of is going to be exponentially concentrated around its expected value, which we have just shown is at least . It follows that it is exponentially unlikely to ever achieve a value of that is not positive. By the union bound, there is some such that, after timesteps, with high probability.
But, the actual probability that in the stationary distribution is exactly , by symmetry. It follows that the mixing time for the Hogwild! chain must be greater than ; that is,
This finishes our proof of the statement. ∎
If we use the coupling from Lemma 4, then by the result of that lemma,
Now, assume that we initialize with distribution , and with the stationary distribution . By Proposition 1, since has distribution and has distribution , this is equivalent to saying
If we use the coupling from Lemma 5, then by the result of that lemma,
Next, recall that we assumed that our Hogwild!-Gibbs sampler has target distribution . Now, assume that we initialize with distribution , and with the target distribution . By Proposition 1, since has distribution and has distribution , this is equivalent to saying
Next, we restate and prove Statement 2, which says that our experimental strategy provides a valid upper bound on the mixing time.
Consider the partial ordering of states in this Ising model defined by
This sampling procedure is equivalent to the one that we use in the experiment, and it will produce a chain that is consistent with the Ising model’s dynamics.
then the marginal probability of assigning to any particular variable in is always no less than the marginal probability of assigning to the same variable in .
Therefore, if we initialize all and all , and run the coupling until time , the time at which
then by the previous analysis, since for any chain initialized at any state ,
Since this was true for any initial value of , it follows that is a coupling time for any two initial values of the chain. Therefore, by Corollary 5.3 from \citetseclevin2009markov,
If we use our definition of where
This in turn implies that is a upper bound on the mixing time, which is the desired result. ∎
B.4 Proofs of Lemmas
In this section, we will restate and prove the lemmas used earlier in the appendix.
For any set of variables , let denote the marginal distribution of the variables in in the distribution . In particular, includes all events that depend only on variables in set . Next, let and denote the values of and on those variables in ; this will be a coupling of the distributions and . Therefore, by Proposition 1,
Let denote all events in the original probability space that depend only on the variables in . By the definition of total variation distance,
Now, since this was true for any , it is certainly true if we maximize both sides over all with . Therefore,
and applying the definition of sparse variation distance proves the lemma. ∎
Let be the number of variables in the model. For all , let be a random variable that takes on values in the state space of such that, for all ,
In particular, and . Now, by the triangle inequality on the total variation distance,
Next, we note that if and only if . Therefore,
Since and differ only at most at index , it follows that , and so,
Taking the expected value of both sides produces
Finally, applying the definition of total influence gives us
Define the coupling as follows. Start in state , and at each timestep, choose a single variable uniformly at random for both chains to sample. Then, sample the selected variable in both chains using the optimal coupling, of the conditional distributions of the variable to be sampled in both chains, guaranteed by Proposition 1. Iterated over time, this defines a full coupling of the two chains.
Next, consider the event that . This event will occur if one of two things happens: either we didn’t sample variable at time and ; or we did sample variable at time , and the sampled variables were not equal. Since the probability of sampling variable is , and we know the probability that the sampled variables were not equal from Proposition 1, it follows that, by the law of total probability,
where denotes the conditional distribution of variable in given the values of the other variables in .
Next, we apply the Lemma 3, which gives us
Applying this inequality recursively, and noting that , we get
As in the sequential case, we sample the selected variable in both chains using the optimal coupling (of the conditional distributions of the variable to be sampled in both chains) guaranteed by Proposition 1. Iterated over time, this defines a full coupling of the two chains.
We follow the same argument as in the sequential case. First, consider the event that . This event will occur if one of two things happens: either we didn’t sample variable at time and ; or we did sample variable at time , and the sampled variables were not equal. Since the probability of sampling variable is , and we know the probability that the sampled variables were not equal from Proposition 1, it follows that, by the law of total probability,
where denotes the conditional distribution of variable in given the values of the other variables in .
Next, we apply the Lemma 3, which gives us
then maximizing the previous expression over implies that
Now, for some constant , let be defined to be the sequence
Now, by the convexity of the exponential function,
Now, we choose such that the argument to this exponential is zero; that is, we choose
Notice that this choice satisfies the earlier assumption that . Using this choice, we can conclude that
We follow a similar argument as in the above lemmas used to bound the mixing time. First, consider the event that . This event will occur if one of two things happens: either we didn’t sample variable at time and ; or we did sample variable at time , and the sampled variables were not equal. Since the probability of sampling variable is , and we know the probability that the sampled variables were not equal from Proposition 1, it follows that, by the law of total probability,
where denotes the conditional distribution of variable in given the values of the other variables in .
Next, we apply the Lemma 3, which gives us
Since the probability of sampling variable at any time is always just , we can reduce this to
Substituting this into our previous expression produces
then maximizing the previous expression over implies that
Subtracting from both sides to identify the fixed point gives us
Applying this inequality recursively lets us conclude that
We will approach this by induction. The base case holds by assumption, since . For the inductive case, if for all , then
By monotonicity and the inductive hypothesis,
Applying induction to this proves the lemma. ∎
(This lemma contains much of the technical work needed to prove Statement 1. A higher-level motivation for why we are proving this lemma is furnished in the proof of that result.)
Assume that, as we run the chain described in this lemma, we also assign a “color” to each of the variables. All variables with an initial value of start out as black, and all other variables start out as white. Let denote the set of variables that are colored black at any time , and let denote the sum of all variables that are colored black at that time. We re-color variables according to the following procedure:
Whenever we change a variable’s value from to , if it is colored white, color it black.
Whenever we change a variable’s value from to , if it is already colored black, choose a random variable that had value at time , and if it is white, color it black.
Note that as a consequence of this result, a variable that is colored white always has value .
We will prove the following sub-result by induction on : given a time , set , and sum , the values of the variables in are uniformly distributed over the set of possible assignments that are consistent with .
(Base Case.) The base case is straightforward. Since is just the set of variables that have value , there is only one possible assignment that is consistent with : the assignment in which all variables take on the value . Since this assignment actually occurs with probability , the statement holds.
(Inductive Case.) Assume that the sub-result is true at time . The sampler chooses a new variable to sample. One of the following things will happen:
We don’t re-color any variables, or change the values of any variables in . In this case, and . Since there is no change to or , all consistent assignments of the black variables are still equiprobable.
We don’t re-color any variables, but we do change the value of some variable in (by changing its value from to ). Since we sampled the variable at random, all consistent assignments of the black variables will remain equiprobable.
We re-color some variable black. There are two events that can cause this:
We could have sampled variable (that is ), and changed its value from to . This will happen with probability
We could have sampled a variable that is already colored black, changed its value from to , and then chosen variable at random to color black. Since, at time , the number of variables with value must be
(since we are about to change a value from to ), this will happen with probability
where is the number of black-colored variables that have value at time .
From this analysis, it follows that, given that we re-colored some variable black, it will have value with probability
In particular, at time , the number of variables that are in is
since all variables with value are in , and is stipulated to contain additional variables with value . It follows that at time , the number of variables that are in is
and there will still be variables in with value . Therefore, the fraction of variables in that have value will be
Note that this is exactly equal to the probability that variable will have value . Combining this with the inductive hypothesis shows that the consistent states will all remain equiprobable in this case.
Since the consistent states remain equiprobable in all of the possible cases, it follows from the law of total probability that the consistent states are equiprobable in all cases. This shows that the sub-result holds in the inductive case.
We have now showed that given a time , set , and sum , the values of the variables in are uniformly distributed over the set of possible assignments that are consistent with . This implies that if is the first time at which the set contains all variables, the value of is are uniformly distributed over all possible states with .
Now, we performed this construction for a particular polarity of swaps (i.e. focusing on switches from to ), but by symmetry we could just as easily have used the same construction with the signs of all the variables reversed. If we let be the first time at which the set contains all variables using this reverse-polarity construction, then the value of is uniformly distributed over all possible states with .
Let be a random variable that is with probability and with probability . It follows that at time , the distribution of will be . Therefore, is a strong stationary time for this chain. By the properties of strong stationary times,
To bound the mixing time, we start by noticing that
If we let be the first time at which each variable has been set to at least once, then
Now, if we sample a variable, the probability that we will set it to is (roughly) . It follows from the coupon collector’s problem bound that the expected amount of time required to set all variables to at least once is
Combining this with the previous inequalities lets us conclude that