Skip to content

CI: add a job with torch.default_dtype = torch.float64 #22210

@ev-br

Description

@ev-br

To summarize the discussion from
https://discuss.scientific-python.org/t/should-scipy-tests-assume-float64-as-the-default-floating-point-dtype/1606/8 :

  • in our testing with multiple array backends, we currently configure jax to default to float64 but keep torch defaulting to float32;
  • the ability to run scipy tests with either f32 or f64 default dtype is important for some of us;
  • we broadly agree that inconsistent defaults are not by design;
  • there is a body of tests with handcrafted tolerances depending on whether the array backend is torch or something else.

The path forward---summarizing from and slightly extending the discourse thread above:

  • parametrize the array API CI job into a pair: one job sets torch.set_default_dtype(torch.float64), the other does not
  • add a helper (_lib feels like a right place?) to query the default, roughly _lib.default_fp_type(xp) which returns the xp-specific default dtype; do not add a publicly accessible backend-agnostic way to set the default.
  • audit existing tests for backend-specific tolerances, atol=1e-7 if is_torch(xp) else 1e-15, change to if default_fp_type(xp) == xp.float32 where appropriate;
  • once done, make float64 the default in conftest.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    CIItems related to the CI tools such as CircleCI, GitHub Actions or AzureDXEverything related to making the experience of working on SciPy more pleasant

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions