                                       Scaling Probabilistic Circuits via Monarch Matrices

a sparse representation for some linear transformation M             nt × nt+1 × · · · × nd × m1 × · · · × mt−1 . We define the
from Rpq to Rrs . Furthermore, in this interpretation, each          generalized Monarch matrix M ∈ R(m1 ×···md )×(n1 ×···nd )
of the A blocks (and each of the B blocks) do not need to
have the same parameters for M to be valid. Hence, we                     (Mx)j1 ,j2 ,...,jd
                                                                                                                            
“untie” the parameters of A and B to obtain the (generalized)                X               Y
Monarch transformation M.                                                  =                  Atjt it it+1 ...id j1 ...jt−1  xi1 ...id
Definition 3.1 (Generalized Monarch Matrices I). Given                        i1 ,i2 ,...id    1≤t≤d

A ∈ Rr×p×q and B ∈ Rs×q×r , we define M to be the                                 d
                                                                          = (A ∗ (A           d−1
                                                                                                    ∗ (· · · ∗ (A2 ∗ (A1 ∗ x)S )S . . . )S .
linear transformation from Rpq to Rrs such that
                X                                                    Here xt := (At ∗ · · · ∗ (A1 ∗ x)S · · · )S is of dimension
     (Mx)kl =       Akij Bljk xij = (B ∗ (A ∗ x)T )T ;               nt+1 ×· · · nd ×m1 ×· · · mt and At+1 ∗xt denotes a batched
                 i,j
                                                                     linear transformation such that
where A ∗ x denotes a “batched” linear transformation                                     X
                                                                        (At ∗ xt−1 )··· =      At jt it ···id j1 ···jt−1 xit ···id j1 ···jt−1 ,
                            X                                                                         it
               (A ∗ x)kj =      Akij xij
                                 i                                   with it+1 · · · id j1 · · · jt−1 enumerating over the batch di-
                                                                     mension. Note that the circuit materialization of this con-
with j enumerating through the “batch” dimension.
                                                                     struction of Monarch matrix consists of d consecutive sum
We visualize the generalized Monarch matrix in Figure 2.             blocks, so we call it a d-layer Monarch matrix.
Here, the 2D matrices Aj and B i are actually slices of the
                                                                     Despite the complexity of this definition, to construct a PC
3D tensors A, B in Definition 3.1; specifically (Aj )ki =                                                             Q
                                                                     A with Monarch layers of hidden size h = 1≤t≤d ht ,
Akij and (B k )lj = Bljk .
                                                                     we really just need to multiply d PCs At , each with dense
Thus, to enable structured sparsity in PCs, we propose to            layers of hidden size ht . As in the case of two circuits,
replace the dense matrices in sum blocks with generalized            we can first train the smaller PCs At with dense layers
Monarch matrices, parameterized by the tensors A, B. In              and use their parameters as anQinitialization point for the
the case where we have √ h input and output nodes (with              training of A where pA (x) ∝ t pAt (x). Such parameter
p = q = r = s = h), then the compute and memory                      initialization significantly improves the result of training
requirements are O(h3/2 ) as compared to the O(h2 ) cost for         PCs with Monarch layers of large hidden sizes, and we refer
a dense PC. The interpretation as circuit multiplication gives       readers to Section 5.2 for details.
us a principled means to initialize the parameters of such
a circuit: namely, train√two smaller PCs A, B with dense             3.3. Interpolating Butterfly and Monarch Matrices
layers and hidden sizes h and then multiply them to obtain
a circuit representing the distribution pC (x) ∝ pA (x)pB (x).       To conclude this section, we draw an interesting connection
We can then untie the parameters of C during training to             between the generalized d-layer Monarch matrices and the
leverage the fully general Monarch paramterization.                  butterfly matrices (Parker, 1995; Dao et al., 2019; Meng
                                                                     et al., 2022). Butterfly matrices are a class of expressive
                                                                     structured matrices, constructed as the product of sparse
3.2. Multiplying Multiple PCs
                                                                     matrices known as butterfly factor matrices. For ease of
A natural way to further generalize the construction above           exposition, we will describe here butterfly factor matrices
would be to consider products of multiple PCs, or more               of size D × D, where D is a power of 2.
specifically, Kronecker products of multiple matrices. We            Definition 3.3 (Butterfly Factor). Given any D = 2d and
generalize Equation 1 as:                                            1 ≤ i ≤ d, a butterfly factor matrix B(i, D) is a sparse
            (A1 ⊗ A2 · · · ⊗ Ad )x                                   matrix with the following sparsity pattern:
                                                           (2)
               = (Ad . . . (A2 (A1 x)S )S . . . )S ;                    • B(1, D) has non-zero elements only along the diago-
                                                                          nals of the four D   D
                                                                                           2 × 2 submatrices.
with At ∈ Rmt ×nt and x ∈ Rn1 ×···×nd ; the superscript
S denotes the left shifting operation where, e.g., xS jki =             • B(i, D) is a block-diagonal matrix with block         size
xijk . Similarly, we can materialize Equation 2 as a circuit,               D       D                                  D
                                                                                                                          
                                                                          2i−1 ×  2 i−1 , where each block is a B 1, 2i−1   butterfly
untie the shared parameters among the blocks A1 , . . . , Ad ,            factor.
and then obtain the (further) generalized construction of
Monarch matrices.                                                    Examples of butterfly factors for D = 16 are shown in
Definition 3.2 (Generalized Monarch Matrices II). Let                Figure 3. A D × D butterfly matrix is given by the ma-
{At }1≤t≤d be d tensors, where At has dimensions mt ×                trix multiplication B(D) := B(1, D)B(2, D) . . . B(d, D).

                                                                 4
