Skip to content

Conversation

@Oisin-M
Copy link
Contributor

@Oisin-M Oisin-M commented Nov 6, 2025

Close #73
Close #65

Description

Test devices as well as backends. Uses eku refactor/backend_for_testing_only branch.

  • test every available device for each backend
  • migrate testing code to new eku structure
  • bugfixed mismatched device errors
  • bugfixed some non array-api compliant code

Issues to note, but finally decided not to tackle here:

  • for mps, need to convert to float32 inputs (float64 not supported). Could consider having a default dtype per device+backend
  • issues with mps device giving odd results
  • issues with tolerances after changing to float32
  • issues with nan locations after changing to float32

Other points:
For now, I decided to use directly the namespaces and not the backends (I added array-api-compat versions of xp.isclose and xp.allclose, but we may want to reconsider that later if we want to have e.g. default dtype per device handling)

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

@Oisin-M
Copy link
Contributor Author

Oisin-M commented Nov 7, 2025

Already fixed many failures, but here's a log of the remaining failing tests...

Testing locally, therefore for the following combinations

  • numpy, torch-cpu, torch-mps

Test status:

extreme

  • tests/extreme/test_extreme.py::test_highlevel_efi, ::test_efi_core for torch mps - no error, just results are totally off. Not solveable via tolerance changes e.g.
E       AssertionError: assert tensor(False, device='mps:0')
E        +  where tensor(False, device='mps:0') = isclose(tensor(-8.1199, device='mps:0'), tensor(-0.1838, device='mps:0'))

solar

  • tests/solar/test_solar.py::test_cos_solar_zenith_angle_1, ::test_cos_solar_zenith_angle_integrated, ::test_toa_incident_solar_radiation for torch mps with error TypeError: unsupported operand type(s) for *: 'Tensor' and 'Tensor'
  • tests/solar/test_solar.py::test_cos_solar_zenith_angle_integrated, ::test_toa_incident_solar_radiation for torch mps - no error, just results are off. Check if tolerance issue

vertical

  • All passing!

score

  • tests/score/test_score.py::test_crps_meteo_missing, ::test_crps_meteo for torch mps - no error, just results are off. Check if tolerance issue

stats

  • tests/stats/test_stats.py::test_nanaverage for torch mps - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, mps:0 and cpu!
  • tests/stats/test_stats.py::test_quantiles_core, ::test_quantiles_nans for torch mps - IndexError: Dimension specified as -1 but tensor has no dimensions
  • tests/stats/test_stats.py::test_quantiles_core for torch mps - no error, just results are off. Check if tolerance issue

thermo

  • tests/thermo/test_thermo.py::test_wet_bulb_potential_temperature, ::test_wet_bulb_temperature, ::test_temperature_on_moist_adiabat, ::test_saturation_ept, ::test_relative_humidity_from_specific_humidity, ::test_specific_humidity_from_relative_humidity, ::test_saturation_specific_humidity_slope_number, ::test_saturation_specific_humidity_slope_1, ::test_saturation_mixing_ratio_slope_numbers, ::test_saturation_mixing_ratio_slope_1, ::test_saturation_vapour_pressure_slope, ::test_saturation_specific_humidity, ::test_saturation_mixing_ratio, ::test_saturation_vapour_pressure_1, ::test_saturation_vapour_pressure_2 for torch mps - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, mps:0 and cpu!
  • tests/thermo/test_thermo.py::test_wet_bulb_temperature for all arrays and devices - issue with nan locations not matching anymore after converting to float32. Not solveable via tolerance changes

@Oisin-M
Copy link
Contributor Author

Oisin-M commented Nov 7, 2025

The mps issues seem unrelated to the code and might be an issue we can't fix here. Since torch-cpu is passing, I have decided for now to ignore the issues with mps with a view to revisiting later. Will test cuda-based backend/device combos instead

@Oisin-M Oisin-M marked this pull request as ready for review November 7, 2025 12:48
@Oisin-M
Copy link
Contributor Author

Oisin-M commented Nov 7, 2025

Tests are passing for all the following combos*

  • numpy-cpu
  • cupy-cuda:0
  • torch-cpu
  • torch-cuda:0

*with some exceptions that we skip for now

  • torch.histogramdd not supported for torch-cuda, only for cpu. Therefore, ignoring torch-cuda for tests/wind/test_wind.py::test_windrose_1.
  • cp.percentile does not match torch or numpy nan axis semantics, so ignoring cupy for test_quantiles_nans

@Oisin-M Oisin-M requested a review from sandorkertesz November 7, 2025 14:11
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.

Cpf fails with torch due to slicing with negative strides How to support array devices?

2 participants