-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] MatrixAlgebraKit decompositions #230
Draft
lkdvos
wants to merge
14
commits into
master
Choose a base branch
from
matrixalgebra
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #230 +/- ##
==========================================
- Coverage 82.63% 73.28% -9.35%
==========================================
Files 43 45 +2
Lines 5557 5649 +92
==========================================
- Hits 4592 4140 -452
- Misses 965 1509 +544 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
lkdvos
commented
Mar 19, 2025
Jutho
reviewed
Mar 20, 2025
Jutho
reviewed
Mar 20, 2025
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 is some preliminary code to start geting a feeling for how we could go and implement the
MatrixAlgebraKit
functions for tensors.Looping over blocks
The first thing I did was try and generalize the "looping over blocks" concept, with an eye towards parallelizing that in the near future. I can come up with several different designs, which are all more or less equivalent, but look slightly different. The one I implemented here is centered around
foreach
, with a wink towardsOhMyThreads.tforeach
to include schedulers:There are several design questions here:
f(c, bs...)
orf(c, bs)
?Alternatives I can come up with are to generalize
blocks(t)
toblocks(t1, t2, ...) -> (c => (b1, b2, ...))...
, but that does not encapsulate the threading options.Should we also include a
mapblocks!(f, t, ts...)
and/ormapreduceblocks(f, op, t, ts...)
?If we also want
mapblocks(f, t, ts...)
, should the output be based on all arguments, or just the first?Implementing decompositions
Then, in order to define the decompositions, there are again some choices to be made.
The first is whether or not we want to define the MatrixAlgebraKit functions themselves for
AbstractTensorMap
, or only define our wrappers that dispatch to these implementations. Here, I chose to go ahead and implement the functions directly.Secondly, the current implementation preallocates the entire output first, and then applies the relevant functions blockwise. This is particularly useful for multithreading and maximally reusing memory, but might become a bit more involved for the cases where we do not know the correct sizes a priori.
As a sidenote, currently we are not very consistent with the arrows of the factorizations. For example,
leftorth(t) -> Q, R
might have different duality of the connecting space depending on the number of indices oft
, which can be a bit annoying when working with fermions.Thirdly, it would be convenient to have the
default_eig_alg
function also work in the type domain, so this can be defined for a tensor without having to instantiate a block.Similarly or additionally, a
DefaultAlgorithm
type to indicate deferring the selection until later could be useful.Let me know what you think about some of this, I'll try and add some more functionality this week if we start converging on some of these design questions :)