Sampling with Riemannian Hamiltonian Monte Carlo in a Constrained Space
Abstract
We demonstrate for the ﬁrst time that ill-conditioned, non-smooth, constrained distributions in very high dimension, upwards of 100,000, can be sampled efﬁciently in practice .
Our algorithm incorporates constraints into the Riemannian version of Hamiltonian Monte Carlo and maintains sparsity.
This allows us to achieve a mixing rate independent of condition numbers.
On benchmark data sets from systems biology and linear programming, our algorithm outperforms existing packages by orders of magnitude.
In particular, we achieve a 1,000-fold speed-up for sampling from the largest published human metabolic network (RECON3D).
Our package has been incorporated into the
COBRA toolbox.
Introduction
Sampling is Fundamental.
Sampling algorithms arise naturally in models of statistical physics, e.g., Ising, Potts models for magnetism, Gibbs model for gases, etc.
These models directly suggest
Markov chain algorithms for sampling the corresponding conﬁgurations.
In the Ising model where the vertices of a graph are assigned a spin, i e., ± 1 , in each step, we pick a vertex at random and ﬂip its spin with some probability.
The probability is chosen so that the distribution of the vector of all spins approaches a target distribution where the probability exponentially decays with the number of agreements in spin for pairs corresponding to edges of the graph.
In the Gibbs model, particles move randomly with collisions and their motion is often modeled as reﬂecting Brownian motion.
Sampling with Markov chains is today the primary algorithmic approach for high-dimensional sampling.
For some fundamental problems, sampling with Markov chains is the only known efﬁcient approach or the only approach to have guarantees of efﬁciency.
Two notable examples are sampling perfect matchings of a bipartite graph and sampling points from a convex body.
These are the core subroutines for estimating the permanent of a nonnegative matrix and estimating the volume of a convex body, respectively.
The solution space for these problems scales exponentially with the dimension.
In spite of this, polynomial-time algorithms have been discovered for both problems.
The current best permanent algorithm scales as n 7 (time) [2, 23], while the current best volume algorithm scales as n 3 (number of membership tests) [24].
For the latter, the ﬁrst polynomial-time algorithm had a complexity of n 27 [16], and the current best complexity is the result of many breakthrough discoveries, including general-purpose algorithms and analysis tools.
Sampling is Ubiquitous.
The need for efﬁcient high-dimensional sampling arises in many ﬁelds.
A notable setting is metabolic networks in systems biology.
A constraint-based model of a metabolic network consists of m metabolites and n reactions, and a set of equalities and inequalities that deﬁne a set of feasible steady state reaction rates (ﬂuxes):
[Equation]
where S is a stoichiometric matrix with coefﬁcients for each metabolite and reaction.
The linear equalities ensure that the ﬂuxes into and out of every node are balanced.
The inequalities arise from thermodynamical and environmental constraints.
Sampling constraint-based models is a powerful tool for evaluating the metabolic capabilities of biochemical networks [33, 46].
While the most common distribution used is uniform over the feasible region, researchers have also argued for sampling from the Gaussian density restricted to the feasible region; the latter has the advantage that the feasible set does not have to be bounded.
A previous approach to sampling, using hit-and-run with rounding [20], has been incorporated into the COBRA package [21] for metabolic systems analysis (Bioinformatics).
A second example of mathematical interest is the problem of computing the volume of the Birkhoff polytope.
For a given dimension n , the Birkhoff polytope is the set of all doubly stochastic n × n matrices (or the convex hull of all permutation matrices).
This object plays a prominent role in algebraic geometry, probability, and other ﬁelds.
Computing its volume has been pursued using algebraic representations; however exact computations become intractable even for n = 11 , requiring years of computation time.
Hit-and-run has been used to show that sampling-based volume computation can go to higher dimension [11], with small error of estimation.
However, with existing sampling implementations, going beyond n = 20 seems prohibitively expensive.
A third example is from machine learning, a ﬁeld that is increasingly turning to sampling models of data according to their performance in some objective.
One such commonly used criterion is the logistic regression function.
The popularity of logistic regression has led to sampling being incorporated into widely used packages such as STAN [44], PyMC3 [41], and Pyro [3].
However, those packages in general do not run on the constraint-based models we are interested in.
Problem Description.
In this paper, we consider the problem of sampling from distributions whose densities are of the form
[Equation]
where f is a convex function and K is a convex body.
We assume that a self-concordant barrier φ for K is given.
Note that any convex body has a self-concordant barrier [32] and there are explicit barriers for convex bodies that come up in practical applications [37], so this is a mild assumption.
We introduce an efﬁcient algorithm for the problem when K is a product of convex bodies K i , each with small dimension.
Many practical instances can be written in this form.
As a special case, the algorithm can handle K in the form of { x ∈ R n : l i ≤ x i ≤ u i for all i ∈
[ n ] } with l i ∈ R ∪ {−∞} and u i ∈
R ∪ { + ∞} , which is the common model structure in systems biology.
Moreover, any generalized linear model exp( − [Equation] f i [Equation]
a [Equation] i x − b i )) , e.g., the logistic model, can be rewritten in the form
[Equation]
where K =
Π K i and each K i =
{ ( s i , t i ) :
f i ( s i ) ≤ t i } is a two-dimensional convex body.
The Challenges of Practical Sampling.
High dimensional sampling has been widely studied in both the theoretical computer science and the statistics communities.
Many popular samplers are ﬁrst-order methods, such as MALA [40], basic HMC [36, 14] and NUTS [22], which update the
Markov chain based on the gradient information of f .
The runtime of such methods can depend on the condition number of the function f
However, the condition number of real-world applications can be very large.
For example, RECON1 [27], a reconstruction of the human metabolic network, can have condition number as large as 10 6 due to the dramatically different orders of different chemicals’ concentrations.
Motivated by sampling from ill-conditioned distributions, another class of samplers use higher-order information such as Hessian of f to take into account the local structure of the problems [43, 9].
However, such samplers cannot handle non-smooth distributions, such as hinge-loss, lasso, or uniform densities over polytopes.
For non-smooth distributions, the best polytime methods are based on discretizations of Brownian motion, e.g., the Ball walk [25] (and its afﬁne-invariant cousin, the Dikin walk [26]), which takes a random step in a ball of a ﬁxed size around the current point.
Hit-and-Run [34] builds on these by avoiding an explicit step size and going to a random point along a random line through the current point.
Both approaches hit the same bottleneck — in a polytope that contains a unit ball, the step size should be O (1 / √ n ) to avoid stepping out of the body with large probability.
This leads to quadratic bounds (in dimension) on the number of steps to “mix”.
Due to the reduction mentioned in (1.2), non-smooth distributions can be translated to the form in (1.1) with constraint K .
Both the ﬁrst and higher-order sampler and the polytime non-smooth samplers have their limitations in handling distributions with non-smooth objective function or constraint K .
Given the limitations of all previous samplers, a natural question we want to ask is the following.
Question.
Can we develop a practically efﬁcient sampler that can handle the constrained problem in (1.1) and preserve sparsity 1 with mixing time independent of the condition number?
In some applications, smoothness and condition number can be controlled with tailor-made models.
Our goal here is to propose a general solver that can sample from any non-smooth distributions as given.
For traditional samplers such as the Ball walk and Hit-and-Run, as mentioned earlier, the step size needs to be small so that the process does not step out.
An approach that gets around this bottleneck is Hamiltonian Monte Carlo (HMC), where the next step is given by a point along a
Hamiltonian-preserving curve according to a suitably chosen Hamiltonian.
It has two advantages.
First, the steps are no longer straight lines in Euclidean space, and we no longer have the concern of “stepping out”.
Second, the process is symplectic (so measure-preserving), and hence the ﬁltering step is easy to compute.
It was shown in [31] that signiﬁcantly longer steps can be taken and the process with a convergence analysis in the setting of Hessian manifolds, leading to subquadratic convergence for uniformly sampling polytopes.
To make this practical, however, is a formidable challenge.
There are two high-level difﬁculties.
One is that many real-world instances are highly skewed (far from isotropic) and hence it is important to use the local geometry of the density function.
This means efﬁciently computing or maintaining second-order information such as a Hessian of the logarithm of the density.
This can be done in the Riemannian HMC (RHMC) framework [17, 31], but the computation of the next step requires solving the Hamiltonian ODE to high accuracy, which in turn needs the computation of leverage scores, a procedure that takes at least matrix-multiplication time in the worst case.
Another important difﬁculty is maintaining hard linear constraints.
Existing high-dimensional packages do not allow for constraints (they must be somehow incorporated into the target density), and RHMC is usually considered with a full-dimensional feasible region such as a full-dimensional polytope.
This can also be done in the presence of linear equalities by working in the afﬁne subspace deﬁned by the equalities, but this has the effect of losing any sparsity inherent in the problem and turning all coefﬁcient matrices and objective coefﬁcients into dense objects, thereby potentially incurring a quadratic blow-up.
Our Solution: Constrained Riemannian Hamiltonian Monte Carlo (CRHMC).
We develop a constrained version of RHMC, maintaining both sparsity and constraints .
Our reﬁnement of RHMC ensures that the process satisﬁes the given constraints throughout, without incurring a signiﬁcant overhead in time or sparsity.
It works even if the resulting feasible region is poorly conditioned.
Since many instances in practice are ill-conditioned and have degeneracies, we believe this is a crucial aspect.
Our algorithm outperforms existing packages by orders of magnitude.
In Section 2, we give the main ingredients of the algorithm and discuss how we overcome the challenges that prevent us from sampling efﬁciently in practice.
Following that, in Section 3, we present empirical results on several benchmark datasets, showing that CRHMC successfully samples much larger models than previously known to be possible, and is signiﬁcantly faster in terms of rate of convergence (“number of steps”) and total sampling time.
Our complete package is available on GitHub.
We refer the reader to Appendix for theory, notations, and deﬁnitions.
Algorithm: Constrained RHMC
In this section, we propose a constrained Riemannian Hamiltonian Monte Carlo (CRHMC 2 ) algorithm to sample from a distributions of the form e − f ( x ) subject to c ( x ) = 0 and x ∈ K for some convex body K, where the constraint function c : R n → R m satisﬁes the property that the Jacobian Dc ( x ) has full rank for all x such that c ( x ) = 0 .
It is useful to keep in mind the case when c ( x ) = {+
+} is an afﬁne subspace
Ax = b , in which case Dc ( x ) = A , and the full-rank condition simply says that the rows of
A are independent.
We refer readers to [1, 4, 39] for preliminary versions of CRHMC called the constrained Hamiltonian
Monte Carlo (CHMC).
In particular, a framework in [4] can be extended to CRHMC when K = R n , and in fact they mention CRHMC as a possible variant.
However, their algorithm for CRHMC requires eigenvalue decomposition and is not efﬁcient for large problems, which takes n 3 time and n 2 space per MCMC step in practice.
In this section, we propose an algorithm that overcomes those limitations and satisﬁes the additional constraint K by using a local metric induced by the Hessian of self-concordant barriers, leading to n 1 .
5 time and n space in practice.
2.1 Basics of CRHMC
To introduce our algorithm, we ﬁrst recall the RHMC algorithm
(Algorithm 1).
In RHMC, we extend the space x to the pair ( x, v ) , where v denotes the velocity .
Instead of sampling from e − f ( x ) , RHMC samples from the distribution e − H ( x,v ) , where H ( x, v ) is the Hamiltonian, and then outputs x .
To make sure the distribution is correct, we choose the Hamiltonian such that the marginal of e − H ( x,v ) along v is proportional to e − f ( x ) .
One common choice of H ( x, v ) is
[Equation]
log det M ( x ) , (2.1) where M ( x ) is a position-dependent positive deﬁnite matrix deﬁned on R n .
Algorithm
Input: Initial point x (0) , step size h for k = 1 , 2 , · · · do // Step 1: resample v
Sample v ( k − 12 ) ∼ N (0 , M ( x ( k − 1) )) and set x ( k − 12 ) ← x ( k − 1) .
// Step 2:
Hamiltonian dynamics
Solve the ODE
[Equation]
.2) with H deﬁned in (2.1) and the initial point given by ( x ( k − 12 ) , v ( k − 12 ) ) .
Set x ( k ) ← x ( h ) and v ( k ) ← v ( h ) .
end
Output: x ( k )
To extend RHMC to the constrained case, we need to make sure both Step 1 and Step 2 satisfy the constraints, so the Hamiltonian dynamics has to maintain c ( x ) =
throughout Step 2.
Note that
[Equation]
where Dc ( x ) is the Jacobian of c at x .
With H deﬁned in (2.1), Condition (2.3) becomes Dc ( x ) M ( x ) − 1 v = 0 .
However, for full rank Dc ( x ) , if M ( x ) is invertible, then Range( v ) =
Range( N (0 , M ( x )))
=
R n immediately violates this condition due to 2 pronounced “crumch”. dim( Null( Dc ( x ) M − 1 ( x ) ) ) = n − m .
To get around this issue, we use a non-invertible matrix
M ( x ) with its pseudo-inverse M ( x ) † to satisfy Dc ( x ) M ( x ) † v = 0 for any v ∈ Range( M ( x )) .
Since we want the step to be able to move in all directions satisfying c ( x ) = 0 , we impose the following condition with Range( M ( x ))
=
Range( M ( x ) † ) in mind:
[Equation]
for all x ∈ R n , (
[Equation]
.4) which can be achieved by M ( x ) proposed soon.
Under the condition (2.4), we sample v from N (0 , M ( x )) in Step 1, which is equivalent to sampling from e − H ( x,v ) subject to v ∈ Range( M ( x )) =
Null( Dc ( x )) .
Also, the stationary distribution of
CRHMC should be proportional to e − H ( x,v ) subject to c ( x ) = 0 and v ∈ Null
( Dc ( x )) .
Here, to maintain v ∈ Null( Dc ( x )) during Step 2 we add a Lagrangian term to H .
Without the
Lagrangian term, v t would escape from Null( Dc ( x t )) =
Range( M ( x t )) in Step 2 as seen in the proof of Lemma 1, which contradicts Range( v t ) =
Range( N (0 , M ( x t )))
=
Range( M ( x t )) .
The constrained Hamiltonian we propose is (See its rigorous derivation in Lemma 1)
[Equation] where λ ( x, v ) = ( Dc ( x ) Dc ( x ) (cid:62) ) −
[Equation]
(cid:16) D 2 c ( x )[ v, dxdt ] [Equation] Dc ( x ) [Equation]
x [Equation] (cid:17) . Here, pdet denotes pseudo-determinant and λ ( x, v ) is picked so
that v ∈ Null( Dc ( x )) .
An algorithmic description of
CRHMC is the same as Algorithm 1 with the constrained H in place of the unconstrained H .
We show the convergence of CRHMC to the correct distribution exp( − f ( x )) in Appendix B.3.
Choice of M via Self-concordant Barriers.
The construction of the Hamiltonian (2.5) relies on having a family of positive semi-deﬁnite matrix M ( x ) satisfying the condition (2.4) (i.e.,
Range( M ( x )) =
Null( Dc ( x )) ).
One natural choice is the orthogonal projection to Null( Dc ( x )) :
[Equation]
which is similar to the choice in [4].
For the problem we care about, there are additional constraints on x other than { c ( x ) = 0 } .
In the standard HMC algorithm, we have dxdt ∼ N (0 , M ( x ) − 1 ) .
For example, for a simple constraint
K = [0 , 1] , to ensure every direction is moving towards/away from x = 0 multiplicatively, a natural choice of M is M ( x ) =
diag( x − 2 ) .
For general convex body K , we can use a self-concordant barrier , a function deﬁned on K such that φ ( x ) is self-concordant and φ ( x ) →
+ ∞ as x → ∂K .
Using the barrier φ , we can deﬁne the local metric based on g ( x ) = ∇ 2 φ ( x ) .
Intuitively, as the sampler approaches ∂K , the local metric stretches accordingly so that the Hamiltonian dynamics never passes the barrier, respecting x ∈ K throughout.
In summary, we need M ( x ) to have its range match the null space of Dc ( x ) and agree with g ( x ) in its range.
We can verify that M ( x ) =
Q ( x ) (cid:62) g ( x ) Q ( x ) , where Q ( x ) is the symmetric matrix deﬁned in (2.6), satisﬁes these two constraints.
2.2 Efﬁcient Computation of ∂H/∂x and ∂H/∂v
With M ( x ) =
Q ( x ) (cid:62) g ( x ) Q ( x ) , we have all the pieces of the algorithm.
However, using this naive algorithm to compute ∂H/∂x and ∂H/∂v , we face several challenges.
The algorithm involves computing the pseudo-inverse and its derivatives, which takes O ( n 3 ) except for very special matrices.
The Lagrangian term in the constrained Hamiltonian dynamics requires additional computation such as the second-order derivative of c ( x ) .
A naive approach to computing leverage scores in ∂H/∂x results in a very dense matrix.
Those challenges make the algorithm hard to implement and inefﬁcient, especially when the dimension is high.
In the following paragraphs, we give an overview of how we overcome each of the challenges above.
We defer a more detailed discussion of our approaches and the proofs to Appendix B.2.
Avoiding Pseudo-inverse and Pseudo-determinant.
We are able to show equivalent formulas for
M ( x ) † and log pdet M ( x ) that can take advantage of sparse linear system solvers.
In particular, we show that M ( x ) † = g ( x ) − 12 · ( I − P ( x )) · g ( x ) − 12 , where
[Equation]
As mentioned earlier, a majority of convex bodies appearing in practice are of the form K = (cid:81)
i K i , where K i are constant dimensional convex bodies.
In this case, we will choose g ( x ) to be a block diagonal matrix with each block of size O (1) .
Hence, the bottleneck of applying P ( x ) to a vector is simply solving a linear system of the form ( Dc · g − 1 · Dc (cid:62) ) u
= b for some b .
The existing sparse linear system solvers can solve large classes of sparse linear system much faster than O ( n 3 ) time [13].
For log pdet M ( x ) , we show
[Equation]
This simpliﬁcation allows us to take advantage of sparse Cholesky decomposition.
We prove (2.7) and (2.8) in Lemma 2 and Lemma 3 in Appendix B.2.1.
The formulas (2.7) and (2.8) avoid the expensive pseudo-inverse and pseudo-determinant computations, and signiﬁcantly improve the practical performance of our algorithm.
Simpliﬁcation for Subspace Constraints.
For the case c ( x ) =
Ax − b , the Hamiltonian is now
H ( x, v
[Equation]
+ λ
[Equation] c [Equation] where P = g − 12 A (cid:62)
( Ag − 1 A (cid:62) ) − 1 Ag − 12 .
The key observation is that the algorithm only needs to know x ( h ) in the HMC dynamics, and not v ( h ) .
Thus, we can replace H by any other that produces the same x ( h ) .
We show in Lemma 4 (Appendix B.2.2) that the dynamics corresponding to H above is equivalent to the dynamics that corresponds to a much simpler Hamiltonian:
[Equation]
Furthermore, we have
[Equation]
Efﬁcient Computation of Leverage Score.
Even after simplifying the Hamiltonian as above, we still have a term for the leverage scores, Tr( g − 12 ( I − P ) g − 12 Dg ) in dvdt so that we need to compute the diagonal entries of P = g − 12 A (cid:62) ( Ag − 1 A (cid:62) ) − 1 Ag − 12 to compute dvdt .
Since ( Ag − 1 A (cid:62) ) − 1 can be extremely dense even when A is very sparse, a naive approach such as direct computation of the inverse can lead to a dense-matrix multiplication.
To avoid dense-matrix multiplication, our approach is based on the fact that certain entries of ( Ag − 1 A (cid:62) ) − 1 can be computed as fast as computing sparse Cholesky decomposition of Ag − 1 A (cid:62) [45, 5], which can be O ( n ) time faster than computing ( Ag − 1 A (cid:62) ) − 1 in many settings.
We ﬁrst compute the Cholesky decomposition to obtain a sparse triangular matrix L such that LL (cid:62) =
Ag − 1 A (cid:62) .
Then, we show that only entries of Ag − 1 A (cid:62) in sp ( L ) ∪ sp ( L (cid:62) ) matter in computing diag( A (cid:62) (
Ag − 1 A (cid:62) )
− 1 A ) , where sp ( L ) is the sparsity pattern of L .
We give the details of our approach in Appendix B.2.3.
2.3 Discretization
Explicit integrators such as leapfrog integrator, which are commonly used for Hamiltonian Monte
Carlo, are no longer symplectic on general Riemannian manifolds (see Appendix C.1).
Even though there have been some attempts [38] to make explicit integrators work in the Riemannian setting, its variants do not work for ill-conditioned problems.
Our algorithm uses the implicit midpoint method (Algorithm 3) to discretize the Hamiltonian process into steps of step size h and run the process for T iterations.
This integrator is reversible and symplectic (so measure-preserving) [19], which allows us to use a Metropolis ﬁlter to ensure the distribution is correct so that we no longer need to solve ODE to accuracy to maintain the correct stationary distribution.
We write H ( x, v ) =
H 1 ( x, v ) + H 2 ( x, v ) , where
[Equation]
Starting from ( x 0 , v 0 ) , in the ﬁrst step of the integrator, we run the process on the Hamiltonian Hwith step size h 2 to get ( x 1 / 3 , v 1 / 3 ) .
In the second step of the integrator, we run the process on Hwith step size h by solving
[Equation]
iteratively using the Newton’s method.
This step involves computing the Cholesky decomposition of ( Ag − 1 A (cid:62) )
− 1 using the Cholesky decomposition of Ag − 1 A (cid:62) .
In the third step, we run the process on the Hamiltonian H 1 with step size h 2 again to get ( x 1 , v 1 ) .
We state the complete algorithm (Algorithm 2 and Algorithm 3) with details on the step size in
Appendix C.1 and give the theoretical guarantees in Appendix C.2 (convergence of implicit midpoint method) and Appendix D (independence of condition number).
Experiments
In this section, we demonstrate the efﬁciency of our sampler using experiments on real-world datasets and compare our sampler with existing samplers.
We demonstrate that CRHMC is able to sample larger models than previously known to be possible, and is signiﬁcantly faster in terms of rate of convergence and sampling time in Section 3.2, along with convergence test in Section 3.4.
We examine its behavior on benchmark instances such as simplices and Birkhoff polytopes in Section 3.3.
3.1 Experimental Setting
Settings.
We performed experiments on the Standard DS12 v2 model from MS Azure cloud, which has a 2.1GHz Intel Xeon Platinum 8171M CPU and 28GB memory.
In the experiments, we used our
MATLAB and C++ implementation of CRHMC 3 , which is available here and has been integrated into the COBRA toolbox.
We used twelve constraint-based metabolic models from molecular systems biology in the COBRA
Toolbox v3.0 [21] and ten real-world LP examples randomly chosen from NETLIB LP test sets.
A polytope from each model is deﬁned by { x ∈ R n : Ax = b, l ≤ x ≤ u } for A ∈ R m × n , b ∈ R m , and l, u ∈ R n , which is input to CRHMC for uniform sampling.
We describe in Appendix A how we preprocessed these dataset, along with full information about the datasets in Table 2.
Comparison.
We used as a baseline the Coordinate Hit-and-Run (CHAR) implemented in two different languages.
The former is Coordinate Hit-and-Run with Rounding (CHRR) written in
MATLAB [11, 20] and the latter is the same algorithm (CDHR) with an R interface and a C++ library,
VolEsti [6].
We refer readers to Appendix A for the details of these algorithms and our comparison setup.
We note that popular sampling packages such as STAN and Pyro were not included in the experiments as they do not support constrained-based models.
Even after transforming our dataset to their formats, the transformed dataset were too ill-conditioned for those algorithms to run.
CHMC in [4] works only for manifolds implicitly deﬁned by { c ( x ) = 0 } for continuously differentiable c ( x ) with Dc ( x ) full-rank everywhere, so we could not use it for comparison.
Measurements.
To evaluate the quality of sampling methods, we measured two quantities, the number of steps per effective sample (i.e., mixing rate) and the sampling time per effective sample,
T s .
The effective sample size (ESS) 4 can be thought of as the number of actual independent samples, [Figure] [Figure]
sub quadratic least able to statistically independent up to 4 orders of magnitude than the beneﬁt of speed-up straightforward since could not obtain enough from with more than until it
[Table]
taking into account correlation of samples from a target distribution.
Thus the number of steps per effective sample is estimated by the total number of steps divided by the ESS, and the sampling time
T s is estimated as the total sampling time until termination divided by the ESS.
Each algorithm attempted to draw 1000 uniform samples, with limits on running time set to 1 day (3 days for the largest instance ken_18 ) and memory usage to 6GB.
If an algorithm passes either the time or the memory limit, we stop the algorithm and measure the quantities of interest based on samples drawn until that moment.
After getting uniform samples, we thinned the samples twice to ensure independence of samples; ﬁrst we computed the ESS of the samples, only kept ESS many samples, and repeated this again.
We estimated the above quantities only if the ESS is more thanand an algorithm does not run into any error while running 5 .
3. Mixing Rate and Sampling Time
Sub-linear Mixing Rate.
We examined how the number of steps per effective sample grows with the number of nonzeros (nnz) of matrix A (after preprocessing) and the number of variables (dimension in the plots).
To this end, we counted the total number of steps taken until termination of algorithms and divided it by the effective sample size of drawn samples.
Note that we thinned twice to ensure independence of samples used.
The mixing rate of CRHMC was sub-linear in both dimension and nnz, whereas previous implementations based on CHAR required at least n 2 steps per sample as seen in Figure 3.1.
On the [-dataset,
-]dataset,
[Table]
mixing rate attained was up to 6 orders of magnitude faster for CRHMC compared to CHAR, implying that CRHMC converged to uniform distribution substantially faster than the other competitors.
This gap in mixing rate increased super-linearly in dimension, enabling CRHMC to run on large instances of dimension up to 100000.
Sub-quadratic Sampling Time.
We next examined the sampling time T s in terms of both the nnz of A and the dimension of the instance.
We computed the runtime of algorithms until their termination divided by the effective sample size of drawn samples, where we ignored the time it takes for preprocessing.
Note that the sampling time T s is essentially multiplication of the mixing rate and the per-step complexity (i.e., how much time each step takes).
As shown in Figure 3.2 and Table 1, we found that the per-step complexity of CRHMC was small enough to make the sampling time sub-quadratic in both dimension and nnz, whereas CHAR had at least a cubic dependency on dimension, despite of a low per-step complexity.
On our dataset, the sampling time of CRHMC was up to 4 orders of magnitude less than that of CHRR and CDHR.
While CHRR can be used on dimension only up to a few thousands, increasing beneﬁts of sampling time in higher dimension allows CRHMC to run on dimension up to 0.1 million.
3.3 CRHMC on Structured Instances
To see the behavior of CRHMC on very large instances, we ran the algorithm on three families of structured polytopes – hypercube, simplex, and Birkhoff polytope – up to dimension half-million.
We attempted to draw 500 uniform samples with a 1 day time limit (except for 2 days for half-milliondimensional Birkhoff polytope).
The deﬁnitions of these polytopes are shown in Appendix A
[Figure] To the best of our knowledge [Figure] this is the ﬁrst demonstration that it is possible to sample such a large model.
As seen in Figure 3. [Figure] CRHMC can scale smoothly up to half-million dimension on hypercubes and simplices and up to dimension 10 5 for Birkhoff polytopes (we could not obtain a reliable estimate of mixing rate and sampling time on the half-million dimensional Birkhoff polytope, as the ESS is only 16 after 2 days).
However, we believe that one can ﬁnd room for further improvement of CRHMC by tuning parameters or leveraging engineering techniques.
We also expect that CRHMC enables us to estimate the volume of B n for n ≥ 20 , going well beyond the previously best possible dimension.
3.4 Uniformity Test
We used the following uniformity test to check whether samples from CRHMC form the uniform distribution over a polytope P : check that the fraction of the samples in the scaled set x · P is proportional to x dim .
As seen in Figure 3.4, the empirical CDFs of the radial distribution to the power of (1/dim) are close to the CDFs of the uniform distribution over those polytopes.
[Figure]
Acknowledgement.
The authors are grateful to Ben Cousins for helpful discussions
[Figure]
and to Ronan
Fleming, Ines Thiele and their research groups for advice on metabolic models.
This work was supported in part by NSF awards DMS-1839116, DMS-1839323, CCF-1909756, CCF-2007443 and
CCF-2134105.