Skip to content

Add TruncationUnion to support supplying minimal ranks - #183

Merged
lkdvos merged 9 commits into
mainfrom
ld-truncmin
Mar 11, 2026
Merged

Add TruncationUnion to support supplying minimal ranks#183
lkdvos merged 9 commits into
mainfrom
ld-truncmin

Conversation

@lkdvos

Copy link
Copy Markdown
Member

This adds a new composite truncation strategy based on the concept of taking unions instead of intersections of existing truncations.
This allows for more advanced combinations, such as minimal tolerances, multiple split regions etc, in a very agnostic way that should work with other truncation schemes we don't even know about.

Fixes#181.

lkdvosand others added 4 commits March 7, 2026 13:02
`TruncationUnion` is the symmetric counterpart to `TruncationIntersection`,
keeping values that are present in *any* component strategy. `NoTruncation`
acts as the absorbing element (union with "keep all" = keep all).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
`minrank` provides a lower bound on the number of kept values, composing with
other constraints via `TruncationUnion`. When no upper-bound constraints are
active, `minrank` alone returns `truncrank(minrank)` directly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add examples for the `minrank` keyword argument and the `|` operator,
and add `@docs` entries for `TruncationIntersection` and `TruncationUnion`.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lkdvoslkdvos added the documentation Improvements or additions to documentation label Mar 7, 2026
@github-actions

Copy link
Copy Markdown
Contributor

After the build completes, the updated documentation will be available here

lkdvosand others added 2 commits March 7, 2026 14:15
Mirrors the existing `_ind_intersect` overrides: collect GPU index vectors
to CPU before computing the union, since `union` does not work on GPU arrays.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecovBot commented Mar 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 44.68085% with 26 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
src/implementations/truncation.jl38.09%13 Missing ⚠️
src/interface/truncation.jl55.00%9 Missing ⚠️
...ixAlgebraKitAMDGPUExt/MatrixAlgebraKitAMDGPUExt.jl33.33%2 Missing ⚠️
...MatrixAlgebraKitCUDAExt/MatrixAlgebraKitCUDAExt.jl33.33%2 Missing ⚠️
Files with missing linesCoverage Δ
src/MatrixAlgebraKit.jl100.00% <ø> (ø)
...ixAlgebraKitAMDGPUExt/MatrixAlgebraKitAMDGPUExt.jl68.08% <33.33%> (-2.37%)⬇️
...MatrixAlgebraKitCUDAExt/MatrixAlgebraKitCUDAExt.jl70.00% <33.33%> (-2.35%)⬇️
src/interface/truncation.jl66.19% <55.00%> (-3.81%)⬇️
src/implementations/truncation.jl81.08% <38.09%> (-10.04%)⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lkdvos
lkdvos requested review from Jutho and kshyattMarch 9, 2026 18:08
true
```

Use `maxrank` together with a tolerance to keep at most `maxrank` values above the tolerance (intersection):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the tolerance be both/either relative/absolute?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes to all, although for this particular set of examples I think the focus is more on the fact that you can combine them, not necessarily on what trunctol accepts, which should be listed in the docstrings

Comment threaddocs/src/user_interface/truncations.md Outdated
Comment threadext/MatrixAlgebraKitAMDGPUExt/MatrixAlgebraKitAMDGPUExt.jl
Comment threadext/MatrixAlgebraKitCUDAExt/MatrixAlgebraKitCUDAExt.jl
Comment threadsrc/interface/truncation.jl
@test length(diagview(S2)) == 2
@test collect(diagview(S2)) ≈ collect(diagview(S)[1:2])
end
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am probably too tired, but this looks like two times the same identical block of code / set of tests?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, but with the addition of the alg. The goal here is to test certain operations for the supplied alg, while the goal above is to test if things work for an array type if you have not specified alg.

@lkdvos
lkdvos merged commit bb27392 into mainMar 11, 2026
5 of 9 checks passed
@lkdvos
lkdvos deleted the ld-truncmin branch March 11, 2026 12:53
@lkdvoslkdvos mentioned this pull request Mar 24, 2026
lkdvos referenced this pull request Mar 25, 2026
….4, (keep existing compat) (#201)
* CompatHelper: bump compat for GenericLinearAlgebra in [weakdeps] to 0.4, (keep existing compat)
* Remove JET dependency
Removed JET dependency from Project.toml
* Remove JET from test targets
Removed JET from the test targets in Project.toml.
---------
Co-authored-by: CompatHelper Julia <compathelper_noreply@julialang.org>
Co-authored-by: Lukas Devos <ldevos98@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow one to set a minimum dimension when truncating.

3 participants

@lkdvos@kshyatt@Jutho