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

(feat): elem_mul 64 bit upcast option #3392

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

ilan-gold
Copy link
Contributor

@ilan-gold ilan-gold commented Dec 5, 2024

  • Release notes not necessary because:

@ilan-gold
Copy link
Contributor Author

I'm putting this in scanpy2.0 because this setting should be turned on then

@ilan-gold ilan-gold added this to the 1.10.5 milestone Dec 5, 2024
Copy link

codecov bot commented Dec 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.38%. Comparing base (f7acd02) to head (75531f3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3392      +/-   ##
==========================================
+ Coverage   75.36%   75.38%   +0.01%     
==========================================
  Files         112      112              
  Lines       13219    13229      +10     
==========================================
+ Hits         9963     9973      +10     
  Misses       3256     3256              
Files with missing lines Coverage Δ
src/scanpy/_settings.py 89.10% <100.00%> (+0.35%) ⬆️
src/scanpy/_utils/__init__.py 74.56% <100.00%> (+0.09%) ⬆️

@ilan-gold ilan-gold modified the milestones: 1.10.5, 1.11.0 Dec 8, 2024
@ilan-gold ilan-gold marked this pull request as ready for review December 8, 2024 14:03
Copy link
Member

@flying-sheep flying-sheep left a comment

Choose a reason for hiding this comment

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

So this will just use 64 bits for computation and downcast again after?

@flying-sheep flying-sheep modified the milestones: 1.11.0, 1.12.0 Dec 20, 2024
@ilan-gold
Copy link
Contributor Author

So this will just use 64 bits for computation and downcast again after?

I hadn't considered that. There's no downcasting at the moment, it just uses 64 bits for the multiplication. Maybe it should downcast to the original?

I could see that being beneficial, but then the question is what do we downcast to? The data type of the right or left matrix?

We would have to make this clear in the documentation.

@flying-sheep
Copy link
Member

@ivirshup said on Zulip:

I think the intermediary upcast is an implementation detail (in theory we could rewrite the calculation to not upcast, and still be accurate) and should not change the result dtype. For what dtype the result should be, we should use numpy type promotion rules, which should be: f32 * f32 -> f32, f32 * f64 -> f64, f64 * f64 -> f64.

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.

elem_mul in variance calculation should use float64 casting
2 participants