Skip to content
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

A fix for StaticSVD::ComputeSVD to preserve snapshots #268

Merged
merged 3 commits into from
Feb 23, 2024
Merged

Conversation

dreamer2368
Copy link
Collaborator

@dreamer2368 dreamer2368 commented Feb 11, 2024

StaticSVD::ComputeSVD performs SVD using scalapack's pdgesvd, which does not preserve the original snapshot matrix. This can be a potential source of error when running BasisGenerator::getSnapshotMatrix after SVD operation (BasisGenerator::endSamples()).

StaticSVD now has an option to preserve the snapshot. This option is driven by the bool option Options::static_svd_preserve_snapshot.

If snapshot preserving option is false, StaticSVD::computeSVD uses the original d_samples as before, modifying the matrix. StaticSVD::getSnapshotMatrix after svd operation will return an error, so that users would not use the modified snapshot matrix.

If snapshot preserving option is true, StaticSVD::computeSVD copies from d_samples into snapshot_matrix either transposed or original, and use snapshot_matrix as working matrix for SVD operation, preserving the original snapshot matrix d_samples. The working matrix snapshot_matrix is destroyed at the end of the function call.

@dreamer2368
Copy link
Collaborator Author

@chldkdtn @dylan-copeland @ckendrick @siuwuncheung , I made the change per @dylan-copeland 's suggestion and it is ready for review and merge.

I made this PR separate from other branches so that this can be merged independently.

@dreamer2368 dreamer2368 merged commit 46d6922 into master Feb 23, 2024
4 checks passed
andersonw1 pushed a commit that referenced this pull request Apr 2, 2024
* StaticSVD::ComputeSVD - copies the sample snapshot matrix for SVD operation and deletes it after SVD.

* option for StaticSVD to preserve snapshot.

* line break for long message.
@dylan-copeland dylan-copeland deleted the svd-fix branch May 17, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug RFR Ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants