Repository navigation
Device-resident linear algebra, tiled Cholesky and TSQR - #22
Open
AdvaitTahilyani wants to merge 10 commits into
Open
AdvaitTahilyani wants to merge 10 commits into
AdvaitTahilyani wants to merge 10 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Operand blocks travel as device chunks (<= 64 MB, CUDA IPC between processes) through receive_data (input_index LA_DEV_INPUT + kind) to chare 0 of the operands' partition, which assembles column-major operands in device memory, factors them in place with cuSOLVER/cuBLAS (QR in place in the packed result, failure NaNs from the device info word) and sends row-major result chunks to the output tiles. No host copies except for svd/lstsq (host-assisted as before) and det/slogdet (the LU diagonal). tssvd with all columns in one tile column sums per-chare Gram matrices instead of gathering A. 1 A100: cholesky n=16000 6.8 s -> 0.13 s, qr 16384x8192 14.3 s -> 0.53 s, solve n=16384 7.1 s -> 0.32 s, tssvd 4e6x64 2.8 s -> 0.05 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lower cholesky of a whole real array, result tiled like the operand: each tile chare factors its tile in place in the result (right-looking: potrf on the diagonal, trsm by the diagonal panel, syrk/gemm updates from the panels of its row and column, sent as device chunks). The last diagonal tile broadcasts a status, so a failure anywhere still gives an all-NaN result. CNUM_LA_DIST=0 gathers instead. qr 'reduced'/'r' of a real tall matrix in one tile column: each chare runs geqrf on its row block, the root factors the stacked R_i and returns the Q slices, each chare sends its rows of Q (CNUM_LA_TSQR=0 gathers instead). Device scatter takes a sub-box of the result. Tests: multi-tile cholesky, not-PD failures in the first, a middle and the last tile, tssvd over two tile columns, tall reduced QR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, tests) - Every chare orders its operand reads after the other streams (compute_after_others at the top of the device path). - TSQR returns LAPACK's (NumPy's) signs: the top chare sends Q's top n x n block to the root, which recovers the Householder signs by a modified LU (Householder reconstruction) and broadcasts them; R and Q are scaled before they are sent. TSQR needs n <= 512 and n rows in the first row block. - QR is factored in place in the packed result only below INT_MAX elements (cuSOLVER 32-bit sizes), else in its own buffer and copied. - Gram path capped like TSQR (n^2 elements within a 64 MB chunk); tssvd clamps negative eigenvalues before sqrt; la_prof() inserts nothing unless timing. - receive_data: LINALG chunk tags start at 1 << 24 (static_assert; other tag ranges must stay below). - Tests compare Q and R with NumPy directly (signs included); add strided and offset views through TSQR, Gram tssvd and gathered cholesky, and a last row tile with fewer than n rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # CODEMAP.md # src/partition_comm.cpp
adityapb
reviewed
Nov 6, 2026
adityapb
left a comment
Member
There was a problem hiding this comment.
Verdict: approve with nits.
This is a static review, with two extra checks:
- The TSQR sign reconstruction, ported to NumPy, matches
np.linalg.qrQ and R to 7e-16 over 200 cases. - I derived the tiled Cholesky tile algebra by hand.
Line numbers are at this PR's head.
These check out:
- Device gather/scatter.
- Tiled right-looking Cholesky: each tile gets exactly the panels it needs, and a non-PD failure in the first, middle or last tile is detected.
- TSQR.
- Gram tssvd.
- Nit: "no host copies" isn't true yet. svd, lstsq and gathered tssvd still go D2H → host → H2D through
la_dev_host_compute(executor_linalg.cpp:1903). #36 removes this. - Nit:
tssvdbreaks on rank-deficient or ill-conditioned input.- It gives
s = 0and an inf/NaN column in U (tssvd_pack,:351-355). The threshold is κ ≳ 7e7 for float64 and ~3e3 for float32. - The
syevdinfo is never read (:2087-2120). - This is cuPyNumeric's definition of tssvd, but it's worth a docstring warning. Still at #44.
- It gives
- Nit: tile element counts are cast to
int(:2187,:2322). This is unreachable unless a tile edge exceeds 46340.
tssvd returns NaNs when syevd reports non-convergence. Panel chunks travel as chunk numbers instead of 32-bit element offsets, and la_k_pack takes 64-bit extents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Validated: nc build and CPU regress at +p1 (orig 15/15, ports 25/25, ops 28/28). The C++ changes are device-only: executor_linalg.cpp compiles with the GPU flags, but I did not run them on a GPU (no Cholesky or tssvd run after the change). |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #21.
la_dev_host_compute); Linalg: device svd/lstsq, distributed solve_triangular, complex/upper tiled cholesky #36 removes those host copies.1 A100: cholesky 16000 6.8 s → 0.16 s; qr 16384×8192 14 s → 0.5 s; solve 16384 7 s → 0.32 s; tssvd 4e6×64 2.7 s → 19 ms.
Tests:
test_linalg.py(587 checks, incl. non-PD failure at first/middle/last tile).Tested (full stack): CPU +p1/+p2 15/15 originals, 25/25 ports, 30/30 ops; A100 1 GPU 15/15, 25/25, 30/30 and 4 GPUs (one process per GPU) 15/15, 25/25.
🤖 Generated with Claude Code