8000 FIX Preserve float32 in MiniBatchDictionaryLearning by jeremiedbb · Pull Request #22428 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

FIX Preserve float32 in MiniBatchDictionaryLearning #22428

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

Merged

Conversation

jeremiedbb
Copy link
Member

Fixes #22426

MiniBatchDictionaryLearning is supposed to preserve float32 since #22002 but the inner_stats (A and B) are still initialized with float64 which causes a copy each time there's an operation between X (or dict) and A or B.

I updated a test to check the dtype of A and B, which fails on main as expected.

@jeremiedbb
Copy link
Member Author

I don't think it requires an entry in the changelog. There's already an entry for the "preserve float32 in dict learning" in v1.1 which has not been released yet. This PR is just a fix for a small oversight in that PR.

@jeremiedbb
Copy link
Member Author

Here's a quick benchmark to show the difference

# this PR
[ 50.00%] ··· =============== ============
              --                 n_jobs   
              --------------- ------------
               fit_algorithm       1      
              =============== ============
                    lars       15.5±0.09s 
                     cd        3.22±0.3s  
              =============== ============

# main
[100.00%] ··· =============== ===========
              --                 n_jobs  
              --------------- -----------
               fit_algorithm       1     
              =============== ===========
                    lars       18.7±0.8s 
                     cd         6.13±1s  
              =============== ===========

It kind of matches the regression observed in #22426

@glemaitre glemaitre changed the title Fix Preserve float32 in MiniBatchDictionaryLearning FIX Preserve float32 in MiniBatchDictionaryLearning Feb 9, 2022
Copy link
Member
@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member
@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

Thanks for the fix (and maintaining the benchmark suite that help find this regression).

@ogrisel ogrisel merged commit d1d60d2 into scikit-learn:main Feb 10, 2022
thomasjpfan pushed a commit to thomasjpfan/scikit-learn that referenced this pull request Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance regression in MiniBatchDictionaryLearning
3 participants
0