The K-COS MethodReading edition

Exact streamed representations

Reading tools
Reading libraryFind statementsInspect Lean
Switch work

Saved reading

Read side by side

Start reading

Resources & source

Original TeX with line links · Download TeX

The wording and mathematics follow the retained manuscript. This reading format does not add a proof review or extend Lean coverage.

Skip contents and start reading

2 Exact streamed representations

Large factors need not be resident all at once. The identities in this chapter separate total data size from the working set without changing the operator. A storage partition is therefore a choice about execution, not a statistical approximation. Weighted features provide a concrete construction, but every subsequent identity applies to a supplied real factor.

2.1 Weighted-feature specialization

A prominent application constructs the general factor from weighted, covariate-residualized features. The sequence kernel association test (SKAT) provides one application [7], but the same formulas apply to any feature matrix with nonnegative column weights.

Let

\[ G\in\mathbb R^{n\times m}, \qquad W=\operatorname{diag}(w_1,\ldots,w_m), \quad w_j\ge 0, \]

and let \(Q_X\in\mathbb R^{n\times p}\) have orthonormal columns spanning the null-model covariates. Define

\[ M_X=I-Q_XQ_X^\top, \qquad A=M_XGW^{1/2}, \qquad K=AA^\top. \]

The central implementation difficulty is not the algebraic size of the model but the mismatch between the total factor size \(n\times m\) and the working memory of an accelerator. The key point of this book is that several decompositions act on different mathematical coordinates and therefore compose:

\[ \boxed{ \text{storage blocks} \circ \text{structural phases} \circ \text{Krylov/range compression} \circ \text{spectral tail packets}. } \]

Storage blocking controls residence. Structural phases encode linkage-disequilibrium (LD) windows, annotations, frequency bands, or other coordinate groups. Krylov methods compress the operator to the rank actually requested. Spectral packets compress the final generalized-\(\chi^2\) transform.

Orthogonal residualization separates a feature into a component in the covariate span and a component retained by M X. The diagram is an illustrative coordinate model. The identity behind it is the exact projector decomposition.
Figure 2.1. Orthogonal residualization separates a feature into a component in the covariate span and a component retained by \(M_X\). The diagram is an illustrative coordinate model. The identity behind it is the exact projector decomposition.

View full-size figure (new tab)

2.2 Variant-block Gram decomposition

Partition the variant indices into disjoint blocks

\[ \{1,\ldots,m\} = J_1\sqcup\cdots\sqcup J_B. \]

Let

\[ G_b=G_{[:,J_b]}, \qquad W_b=W_{J_b,J_b}, \qquad A_b=M_XG_bW_b^{1/2}. \]

Then

\[ A=[A_1\ \cdots\ A_B]. \]

Theorem 2.1: Additive block Gram identity

\[ \boxed{ K = AA^\top = \sum_{b=1}^B A_bA_b^\top = M_X \left( \sum_{b=1}^B G_bW_bG_b^\top \right) M_X. } \]

Proof

Horizontal concatenation gives

\[ [A_1\ \cdots\ A_B] \begin{bmatrix} A_1^\top\\ \vdots\\ A_B^\top \end{bmatrix} = \sum_bA_bA_b^\top. \]

The final form follows from \(A_b=M_XG_bW_b^{1/2}\) and \(M_X^\top=M_X=M_X^2\).

Remark 2.2

The theorem is exact for every partition. Block boundaries are execution parameters, not statistical parameters.

Each resident column block contributes a complete sample-space Gram summand A bA b mathsf T . Adding the summands recovers AA mathsf T exactly. Storage partitioning changes residence and evaluation order, not the represented operator.
Figure 2.2. Each resident column block contributes a complete sample-space Gram summand \(A_bA_b^{\mathsf T}\). Adding the summands recovers \(AA^{\mathsf T}\) exactly. Storage partitioning changes residence and evaluation order, not the represented operator.

View full-size figure (new tab)

2.3 Exact streamed kernel actions

Theorem 2.3: One-pass sample-space streaming action

For every block vector \(V\in\mathbb R^{n\times s}\),

\[ \boxed{ KV = M_X \sum_{b=1}^B G_bW_bG_b^\top M_XV. } \]

Proof

Apply the additive block Gram identity to \(KV\), then associate each block product as

\[ G_bW_b(G_b^\top M_XV). \]

Algorithm 2.4: Streamed \(KV\)

  1. Compute \(U=M_XV\).

  2. Set \(Y=0\).

  3. For each resident block \(b\), compute

    \[ T_b=G_b^\top U, \qquad Y\leftarrow Y+G_b(W_bT_b). \]
  4. Return \(M_XY\).

Corollary 2.5: Working memory independent of total variant count

If at most \(c\) variants are resident and the block-vector width is \(s\), then the algebraic working set is

\[ \boxed{ O(nc+ns+cs+np), } \]

independent of total variant count \(m\).

2.4 Streamed factor actions and Golub–Kahan

Let \(V\in\mathbb R^{m\times s}\) be partitioned conformally:

\[ V= \begin{bmatrix} V_1\\ \vdots\\ V_B \end{bmatrix}. \]

Theorem 2.6: Streamed \(AV\)

\[ \boxed{ AV = M_X \sum_{b=1}^B G_bW_b^{1/2}V_b. } \]

Theorem 2.7: Streamed \(A^\top U\)

For \(U\in\mathbb R^{n\times s}\),

\[ \boxed{ (A^\top U)_b = W_b^{1/2}G_b^\top M_XU. } \]

Proof

Both identities follow by substituting \(A=M_XGW^{1/2}\) and partitioning the variant coordinate.

Corollary 2.8: Streaming Golub–Kahan equivalence

With the same initial state, algorithmic choices, and random draws, any exact-arithmetic algorithm whose access to \(A\) occurs only through \(AV\) and \(A^\top U\) produces the same iterates when those products are implemented by the preceding streamed formulas.

This applies directly to block Golub–Kahan bidiagonalization, matrix-free singular-value iteration, range finding, and restarted variants. The factor need not be resident.

2.5 Two-pass dual action

The variant-space normal operator is

\[ H=A^\top A. \]

Theorem 2.9: Two-pass streamed dual action

For every \(V\in\mathbb R^{m\times s}\),

\[ \boxed{ HV=A^\top(AV). } \]

The product is evaluated exactly by a streamed pass forming \(Y=AV\in\mathbb R^{n\times s}\), followed by a second streamed pass emitting the blocks

\[ (HV)_b=W_b^{1/2}G_b^\top M_XY. \]

This form is particularly natural for variant-space polyphase Krylov iterations because the right-coordinate blocks can be produced and consumed sequentially.

2.6 Two-dimensional sample/variant tiling

A variant block may itself exceed device memory. Let

\[ H_b=G_bW_b^{1/2} \]

and partition samples into row tiles \(I_1,\ldots,I_R\).

Theorem 2.10: Two-pass residualized tile construction

Define

\[ R_b=Q_X^\top H_b. \]

Then

\[ \boxed{ R_b = \sum_r Q_{X,I_r}^\top H_{b,I_r}, } \]

and after \(R_b\) is known,

\[ \boxed{ A_{b,I_r} = H_{b,I_r}-Q_{X,I_r}R_b. } \]

Consequently,

\[ \boxed{ K_{I_r,I_s} = \sum_b A_{b,I_r}A_{b,I_s}^\top. } \]

Proof

The first identity is the row-partitioned matrix product \(Q_X^\top H_b\). The second is the definition \(M_XH_b=H_b-Q_XQ_X^\top H_b\). The last identity is the corresponding sample-tile expansion of \(AA^\top\).

With sample tile height \(t\) and resident variant width \(c\), the dominant working storage, including a resident covariate tile, is

\[ O(tc+pc+tp+t^2). \]

This count excludes the backing input store, completed output blocks, allocator overhead, and library workspaces.

2.7 Partition refinement and permutation invariance

Theorem 2.11: Partition-refinement invariance

Let \(\mathcal J\) be any partition of the variants and let \(\mathcal J'\) refine \(\mathcal J\). Then

\[ \boxed{ \sum_{J\in\mathcal J}A_JA_J^\top = \sum_{J'\in\mathcal J'}A_{J'}A_{J'}^\top = AA^\top. } \]

The analogous streamed operator action is also invariant.

Proof

Each coarse block is a disjoint union of refined blocks. Apply the additive Gram theorem within each coarse block and sum.

Corollary 2.12: Adaptive memory splitting

A runtime may recursively subdivide any block that exceeds available device memory without changing the exact operator.

Proposition 2.13: Variant permutation invariance

If the columns of \(G\) and the diagonal entries of \(W\) are permuted by the same permutation, \(K\) and every streamed sample-space action are unchanged.

Gram and operator-action discrepancies for five retained partition controls. Horizontal connectors pair the two measurements for each partition. The small floating discrepancies support the implementation check, while the partition identity itself is exact algebra.
Figure 2.3. Gram and operator-action discrepancies for five retained partition controls. Horizontal connectors pair the two measurements for each partition. The small floating discrepancies support the implementation check, while the partition identity itself is exact algebra.

View full-size figure (new tab)

2.8 Memory planning law

Let \(d\) be the number of bytes per floating scalar, \(c\) the resident variant count, \(s\) the Krylov width, and \(p\) the covariate rank. Ignoring library workspace and allocator overhead, a streamed sample-space action has working memory on the order of

\[ \boxed{ d\,[nc+2ns+cs+np+O(ps+c)]. } \]

The full factor costs

\[ dnm. \]

For fixed \(n,p,s,c\),

\[ \boxed{ \frac{M_{\rm stream}}{M_{\rm full}} = O\!\left( \frac{c}{m} + \frac{s}{m} + \frac{p}{m} \right), } \]

so device memory remains bounded as total variant count grows.

Table 2.1. Algebraic float64 memory model for \(n=2000\), \(p=4\), Krylov width \(s=16\), resident variant block \(c=1024\), and sample tile height \(t=256\).
\(m\)full factor (MiB)streamed \(KV\) (MiB)tiled Gram (MiB)
10,000152.616.3088.555
50,000762.916.3088.555
100,0001,525.916.3088.555
500,0007,629.416.3088.555
1,000,00015,258.816.3088.555
Binary64 payload as total factor width increases. The complete factor grows with m, while the streamed and tiled payloads remain constant at fixed resident dimensions. These are algebraic sizing data, not measurements of total device allocation.
Figure 2.4. Binary64 payload as total factor width increases. The complete factor grows with \(m\), while the streamed and tiled payloads remain constant at fixed resident dimensions. These are algebraic sizing data, not measurements of total device allocation.

View full-size figure (new tab)

2.9 The running example in three storage blocks

Partition the factor of Section 1.5 into consecutive pairs of columns,

\[ A=[A_1\ A_2\ A_3],\qquad A_i\in\mathbb R^{4\times2}. \]

Although \(A_2=A_3\), both column groups must be counted. Their Gram contributions are

\[ A_1A_1^\top=\frac12 \begin{pmatrix}1&0&1&0\\0&1&0&1\\1&0&1&0\\0&1&0&1\end{pmatrix},\qquad A_2A_2^\top=A_3A_3^\top=\frac12 \begin{pmatrix}1&0&-1&0\\0&1&0&-1\\-1&0&1&0\\0&-1&0&1\end{pmatrix}. \]

The sum is \(K\). Merging the last two blocks preserves it. Discarding \(A_3\) instead changes the operator and its probability law.

For the declared vector \(v=(1,2,-1,0)^\top\), the action can be evaluated without forming any block Gram matrix:

\[ \sum_{j=1}^3 A_j(A_j^\top v)=Kv=(2,3,-2,-1)^\top. \]

The symbolic check confirms both storage partitions. Every column remains represented. Dropping an operator coupling instead changes the operator and requires the error analysis developed next.

Source and conversion record

Source SHA-256: bc4a5d05cc8d7c9672a8e7a2ad5db439d4d35432b931891263bcc21525852d2a

Unsupported prose commands stop the build. The mathematical expression sequence is checked against the source, with manuscript macros expanded for display.

Conversion records

Notation in The K-COS Method

Look up a symbol without leaving this chapter. Select text before opening help to search for it.

Search this work’s notation.

    Symbols can have different meanings in different passages. Read each result in its own context.

    Open the full notation index