Skip to content

add random_state to svd_interface()#616

Open
MrBones1102 wants to merge 2 commits intotensorly:mainfrom
MrBones1102:randomized-svd
Open

add random_state to svd_interface()#616
MrBones1102 wants to merge 2 commits intotensorly:mainfrom
MrBones1102:randomized-svd

Conversation

@MrBones1102
Copy link
Copy Markdown

@MrBones1102 MrBones1102 commented Jan 13, 2026

From #615. Pass rng to new random_state in svd_interface() for use as kwargs in subsequent randomized svd initialization

@MrBones1102
Copy link
Copy Markdown
Author

Having had a look around some more, there are a few more instances of svd_interface() that require passing random_state

Copy link
Copy Markdown
Contributor

@aarmey aarmey left a comment

Choose a reason for hiding this comment

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

Thanks @MrBones1102! Could you please fix those other uses of svd_interface()? They should pass on random_state for the same reason as here.

If a function calls svd_interface(), but does not have a random state, note it and I can take a look.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.13%. Comparing base (983e497) to head (92adc7f).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #616      +/-   ##
==========================================
+ Coverage   88.07%   88.13%   +0.05%     
==========================================
  Files         132      132              
  Lines        7943     7941       -2     
==========================================
+ Hits         6996     6999       +3     
+ Misses        947      942       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@MrBones1102
Copy link
Copy Markdown
Author

Added all other instances where svd_interface() is called, including situations where a random_state needed to be specified. I added random_state to any enclosing function that also takes the svd argument and which the documentation claims can have any value present in tensorly.SVD_FUNS, which includes randomized_svd potentially requiring random_state.

As a result, the following enclosing functions were modified to take random_state with default value set to None:

  • _compute_projections() in _parafac2.py
  • tensor_ring() in _tr_svd.py
  • tensor_train() in _tt.py
  • svd_compress_tensor_slices() in preprocessing.py

Additionally, I modified the svd_interface() calls in test_backend.py as one of those tests explicitly checks for svd=="randomized_svd" without passing a random_state, but perhaps this was intentional?

@aarmey
Copy link
Copy Markdown
Contributor

aarmey commented Jan 22, 2026

Take a look at the test errors here. I'm happy to discuss them if it's not clear what broke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants