PHYSICAL PDF PAGE 17 / 20

                       Outlier-Aware Post-Training Quantization for Discrete Graph Diffusion Models



Algorithm 1 The inference process of quantized multiplication XW through Bit-DGDM

  Input: X ∈ Rb×m : activations, τmax , τmin : thresholds for filter activation outliers, D̂W : quantized dense part of weight

  W, SW : sparse component of weight W, LR> : low rank component of weight W.

  . Filter the activation outliers: SX = X[x > τmax |x < τmin ], DX = X[τmin < x < τmax ]

  . Quantize the DX to low-bit D̂X through Eqn. (4)

  . Calculating D̂X D̂W through low-bit multiplication

  . Calculating SX LR> through adaptive sparse-dense kernel

  . Calculating XSW through equidistributed sparse-dense kernel

  Output: D̂X D̂W + SX LR> + XSW



Algorithm 2 Ill-conditioned low-rank decomposition of weight W

  Input: W ∈ Rm×n : weight matrix, r: the rank of underlying low-rank matrix, Tα (·): sparsification operator, {ηk }: a set

  of step size.

  // Initialization:

  SW,0 = Tα (W)                                                                                              → nm flops

  [U0 , Σ0 , V0 ] = SVDr (W − SW,0 )                                                                 → nmr + nm flops

              1               1

  L0 = U0 Σ02 , R0 = V0> Σ02                                                            → nr2 + mr2 flops

  // Iterative optimization:

  repeat

      SW,k+1 = Tα (W − Lk R> k)                                                           → O(nmr) flops

                                                           −1

      Lk+1 = Lk − ηk+1 Lk R>                          >

                                              

                             k  + SW,k+1 − W    R k R k Rk                       → O(nmr + mr2 + r3 ) flops

                                                            −1

      Rk+1 = Rk − ηk+1 Lk R>                          >

                                                         

                              k + SW,k+1 − W Lk Lk Lk                             → O(nmr + nr2 + r3 ) flops

                   >                2

  until kLk+1 Rk+1 + SW,k+1 − WkF is convergent

  Output: α-Sparsity matrix SW := SW,k , r-rank component DW = LR> (L := Lk , R := Rk )





Equidistributed Sparse-Dense Kernel. For the Equidistributed Kernel, since the sparse matrix SW , which models the

outliers of weights, satisfies the α-Sparsity constraint, we only need to assign one thread per row to handle the computation,

ensuring load balancing.



Adaptive Sparse-Dense Kernel. The adaptive sparse-dense kernel is designed to optimize workload distribution on GPUs,

particularly for matrices characterized by irregular row lengths. The core concept involves partitioning the non-zero elements

into segments allocated to warps, rather than assigning entire rows to warps. The overall algorithm is shown in Algorithm 3.

The pipeline initiates with a preprocessing phase, during which the matrix is analyzed to determine the optimal segmentation

of non-zero elements. A specialized array, termed srow, is introduced to store the starting row index for each segment.

This preprocessing step entails constructing a histogram of the rowptr array and executing an exclusive scan operation to

compute the srow array. This preprocessing is performed once and stored, incurring negligible computational overhead.

During the execution phase, each warp is responsible for processing its designated segment of the val and colidx arrays.

Each segment comprises a contiguous block of non-zero elements, irrespective of row boundaries. The warp processes

these elements in fixed-size chunks (e.g., 32 elements at a time, corresponding to the warp size). For each element, the

corresponding thread multiplies the value by the respective element in the x vector and accumulates the result.

However, since elements from different rows may reside within the same segment, the algorithm must dynamically detect

row boundaries. This is achieved by examining the rowptr array. When a row boundary is encountered within a chunk,

the warp employs warp shuffle instructions to execute a segmented reduction. This mechanism facilitates the efficient

combination of partial sums from the same row without the need for shared memory.

Upon processing a chunk, if any thread transitions to a new row, a segmented scan operation is performed to aggregate the

results for each row. The first thread in the warp corresponding to each row then executes an atomic addition to update

the global y vector. This approach minimizes the number of atomic operations by ensuring that each row is updated only

once per warp after the accumulation of partial sums. Overall, the pipeline achieves load balancing by evenly distributing

non-zero elements across warps and handles irregular row lengths through optimized intra-warp communication.



                                                             17

