Repository navigation
Deferred-update LU and Cholesky with a task executor, and a RandomizedSVD compressor - #96
Merged
Merged
Conversation
…a RandomizedSVD compressor - An `RkMatrix` records which of its factors have orthogonal columns and estimates of its truncation errors (Frobenius norm). Assigning a factor resets them, and `_modified_factor!` updates them after an in-place change of one factor. - `PartialACA` recompresses its result with a truncated SVD by default (`recompress = true`). `TSVD` and the recompression drop the trailing singular values whose Frobenius norm is below `max(atol, rtol*norm)`. - New public compressor `RandomizedSVD(; atol, rtol, rank, block = 4)`: a range finder using Householder QR on blocks of Gaussian samples, stopped by the estimated Frobenius error, then a truncated SVD. It only needs products with the block and its adjoint. - New dependency on the `Random` standard library.
`ThreadsExecutor` runs pieces of work as tasks, each waiting only for the last writer of each object it reads or writes. It assumes the access pattern of the drivers: an object is written by pieces of work spawned in order, and read once final. A read of an internal block of an `HMatrix` waits for a join over the writers of its leaves. With `check_accesses = true`, the executor checks this pattern. `SerialExecutor` runs the work immediately. - `wait` rethrows the first error of a piece of work as is. - `_run!` waits for the spawned work even when the driver throws. - `workspaces`/`with_workspace` is a pool that never blocks. - CI runs the tests on 4 threads.
…he executor Every update of a block is deferred until the block is factorized, solved for or flushed, so that each admissible leaf is compressed once, from its data plus the sum of its updates. This is the accumulator of Börm (2019), following the lazy factorization of htool. - The node owes a set of products, and carries the exact low-rank terms evaluated for the leaves below it. - An admissible leaf is compressed through a `LeafOperator`, from its products with blocks of vectors, by `RandomizedSVD` (the default) or any other compressor. - `LazyDriver` does the structural work; the numeric work (low-rank terms, flushes, dense factorizations and solves of the leaves) goes to the executor. API: - `lu`/`lu!` and `cholesky`/`cholesky!` replace the eager factorizations. They take a compressor, or `atol`, `rtol`, `rank` and `block` for a `RandomizedSVD`, and run on threads with `threads = true` (the default). - The methods taking a compressor or cluster trees also accept an `executor`. `ThreadsExecutor` and `SerialExecutor` are public. - `assemble_hmatrix` assembles the leaves through the executor, with workspaces taken from a pool. - The H-matrix products and solves with a compressor become the internal `hmul!`, `hldiv!` and `hrdiv!`. `ldiv!(L, X::HMatrix, comp)` and `rdiv!(X::HMatrix, U, comp)` are removed. Fixes and cleanup: - The `Hermitian` wrappers keep their `uplo`, so a lower-stored `Hermitian` works in `Matrix`, `mul!` and `hmul!`. `cholesky!` rejects one with an `ArgumentError`. - `H + λI` with a real `λ` keeps a `Hermitian` `H` Hermitian. - Non-scalar entries raise an `ArgumentError` before a factorization or product starts. - Triangular solves with vectors and the serial products in the ordering of the trees reuse one scratch vector per call instead of allocating for each low-rank leaf. - Removed `compress!(::HMatrix, comp)` and `*(::Number, ::RkMatrix)`, which had no caller.
…and internal pages - The guide describes the factorizations (each low-rank block compressed once, by a randomized SVD by default), the Cholesky factorization of a `Hermitian` and its shifts, and the recompression of the assembly. - A new section on threads: BLAS on a single thread, `threads = false` for full backtraces, and the executors. - The reference page holds the public API. The internals have two pages of their own, each below Documenter's size warning.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #96 +/- ##
==========================================
+ Coverage 90.08% 93.13% +3.05%
==========================================
Files 13 15 +2
Lines 1351 1588 +237
==========================================
+ Hits 1217 1479 +262
+ Misses 134 109 -25 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…-hosted runners - The workflow uses the AirspeedVelocity action on `ubuntu-latest` with 4 threads, for pull requests labeled `run benchmark` from branches of this repository. It runs the pull request's script on both revisions and posts the ratios as a comment. - The suite defines its own kernel (single layer on a Fibonacci sphere), and no longer depends on the test utilities or LoopVectorization. - It covers the compressors on one block, then assembly, `mul!`, `lu`, `cholesky` and solves, serial and threaded. It only calls functions that exist on both revisions. - `HMATRICES_BENCHMARK_BLAS` loads another BLAS (e.g. AppleAccelerate) for local runs.
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
`PartialACA` no longer recompresses by default (`recompress = false`), so the assembly is as fast as on main; `recompress = true` lowers the ranks at the cost of a QR factorization of each factor. The factorizations keep `RandomizedSVD` as their default, which ends with a truncated SVD.
The docstrings are reached from the narrative pages through cross-references, so the public and internal ones are listed together again, on a single page which says that names neither exported nor declared `public` are internal. This removes the filters of `make.jl` and the lists of source files of the internals pages. Documenter 1.9 is the first version whose `@autodocs` recognizes `public` names.
… 1.x
With `HMatrices = {path = ".."}` in `[sources]`, `julia --project=docs docs/make.jl`
uses the local checkout without a `Pkg.develop` step. The compat on Documenter allows
any 1.x release, so that the latest one is used.
- actions to their latest majors: checkout v7, setup-julia v3, cache v3, codecov-action v7 (supersedes dependabot #88 and #90) - test job: a timeout, and `actions: write` so that the cache action can delete its old caches - docs job: julia-docdeploy alone instantiates docs/ and builds; the separate environment setup, buildpkg and doctest steps were redundant (makedocs runs the doctests and fails on a broken one) - Runic: a job in CI through fredrikekre/runic-action, which checks every Julia file, replacing FormatCheck.yml - CompatHelper: the workflow CompatHelper recommends (v3 pinned, General through Git, explicit permissions)
maltezfaria
marked this pull request as ready for review
November 19, 2026 17:28
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.
This PR, made with Claude Code, replaces the hierarchical LU and Cholesky factorizations with deferred-update versions run by a task executor, and adds a randomized SVD compressor. It is breaking (0.3.0).
ThreadsExecutorruns each piece of work once the blocks it depends on are ready;SerialExecutorruns the same code sequentially. The assembly also uses it.RandomizedSVDcompressor, the default ofluandcholesky.Breaking changes
lu(H; …)/cholesky(H; …)useRandomizedSVD. Passlu(H, PartialACA(; atol))for the ACA.ldiv!/rdiv!with anHMatrixright-hand side and a compressor, andcompress!(::HMatrix, comp), are removed.choleskyrejects a lower-storedHermitian.Random.Also:
ThreadsExecutor/SerialExecutorare public.H + λIworks for aHermitianH.ArgumentErrorfor non-scalar entries.