Repository navigation
Linalg: distributed LU for solve, inv, det, slogdet - #35
Open
AdvaitTahilyani wants to merge 9 commits into
Open
AdvaitTahilyani wants to merge 9 commits into
AdvaitTahilyani wants to merge 9 commits into
Conversation
M = A^T (row-major tiles are column-major blocks of M) is factored with partial pivoting; panels of CNUM_LA_LU_NB columns are dealt cyclically to one worker chare per PE, filled in place by the chares on its PE. Panel owner getrf and broadcast, row swaps and trsm/gemm trailing updates with one-panel lookahead, fan-out U^T and L^T substitution, result rows permuted on the way to the output tiles. One worker on NVIDIA runs cusolverDnXgetrf/Xgetrs on the whole matrix in its own buffer, so 1-GPU solve holds the operand tiles plus one copy. Used from CNUM_LA_LU_MIN (2048) rows in both builds. la_dalloc now evicts cached arrays and blocks before large allocations and retries after releasing the caches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 4ac40c896bc541397bf17f7886a9d1593f71701d)
The forward and backward substitutions pass one nb x nrhs block per panel; as device messages each step paid a stream callback and an IPC round trip. Blocks up to 1 MB are now copied to the host once and sent as plain messages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit c3e04a8664997265b5990e36bda8cd969b08333b)
adityapb
reviewed
Nov 6, 2026
adityapb
left a comment
Member
There was a problem hiding this comment.
Verdict: request changes as a standalone merge. Please squash #37 into this.
This is a static review, plus a NumPy port of the LU (lu_factor_loop in both this PR's ordering and #37's, lu_subst, the output permutation and the det sign). It matches NumPy's solve and det to about 1e-13 with 1–4 workers and odd n and nb. Line numbers are at this PR's head.
The algorithm is right:
- the pivot search is local, because panels hold all n rows;
- row swaps are applied to the left and right of the panel;
- lookahead, the det sign, and singular det/slogdet
(0, -inf)are all correct.
- [major, fixed by #37] Chunks are copied into the LU buffers before their allocation is ordered on the worker's stream.
- Where:
W,Bandpivare allocated withcudaMallocAsyncon the stream of whichever chare on the PE callsctx()first, andL->readyis recorded there (executor_linalg.cpp:3462-3483). la_lu_recv(:3572-3584) copies the received LU_A/LU_B chunks into them on the worker's stream without waiting. The worker only waits onreadyat assembly (:3385).- When a non-worker chare creates the context (another 2-D chare on the PE, or a 1-D
bchare), the pool can hand out memory that pending work on the creator's stream is still using. - Effect: solve/det are intermittently wrong on 2+ PEs with n ≥ 2048.
- #37's
cudaStreamWaitEvent(..., st.lu->ready)fixes it completely, so please land the two as one commit.
- Where:
- [minor]
test_lu_dist.pymostly bypasses the LU workers by default.- The workers only run for n ≥
CNUM_LA_LU_MIN(default 2048), so with defaults only the n=2100 solve/slogdet cases reach them. - inv, det, singular, complex and strided-view cases, and #36's
solve_triangular, need the server started withCNUM_LA_LU_MIN=1. - Worth having the test set it, or documenting it in the test runner.
- The workers only run for n ≥
This was referenced Nov 6, 2026
W, B and piv are allocated on the stream of whichever chare on the PE creates the LU context; LU_A/LU_B chunks copied in on the worker's stream now wait on its ready event. test_lu_dist: CNUM_SERVER=<server.out> starts a private server with CNUM_LA_LU_MIN=1 so every case goes through the distributed LU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AdvaitTahilyani
added a commit
that referenced
this pull request
Nov 10, 2026
…sync The wait on the context's ready event now lands with the distributed LU itself; release_device_caches() already starts with a global fence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Validated: CPU regress +p1/+p2 (orig 15/15, ports 25/25, ops 32/32); |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
GPU check on 1 and 4 A100s: |
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.
solve, inv, det and slogdet used to gather the matrix onto one GPU. Now:
CNUM_LA_LU_MIN).solve on A100s:
Adds
test_lu_dist(166 checks).🤖 Generated with Claude Code