Skip to content

Conversation

@HannanNaeem
Copy link
Contributor

Our current implementation does not support float32 scalars for add, multiply, and divide. This PR introduces a simple fix in the logic to allow computation with float32 scalars.


Currently Pykokkos always casts scalars as pk.double which is equivalent to float64 in numpy terms. We also then enforce that both operands, for the aforementioned ufuncs, be the same type .e.g. either float32 or float64. This creates a problem when passing a float32 value as scalar with a float32 view. The scalar is casted as float64 and the type assertion fails by our own doing.

To fix this:

  • Scalar takes the type Float32 or float64 based on the view it is passed with (so they remain the same)
  • Tweak the float impls to use modulus indexing to support scalars

Quality tweak:

  • Updated error messages to be verbose about what types mismatched

@IvanGrigorik IvanGrigorik self-requested a review December 19, 2025 15:44
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.

1 participant