Skip to content

Use a single device/dtype#86

Open
SCiarella wants to merge 4 commits intomainfrom
fixdevicedtype
Open

Use a single device/dtype#86
SCiarella wants to merge 4 commits intomainfrom
fixdevicedtype

Conversation

@SCiarella
Copy link
Collaborator

Closes #84

@SCiarella SCiarella marked this pull request as ready for review February 3, 2026 12:48
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

cls._device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
cls._device = torch.device("cpu")
if cls._dtype is None:
cls._dtype = torch.float64
Copy link
Collaborator

Choose a reason for hiding this comment

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

If users don't explicitly set device/dtype when creating tensors in the notebook, since the Torch defaults are different than ComputeConfig, this can cause problems. For dtype can we use float32 to match torch default. See related comments in #87.

I know that for tests (when checking the results against pcse), we need float64. Let's set this in the tests.


def prepare_engine_input(
test_data, crop_model_params, meteo_range_checks=True, dtype=torch.float64, device="cpu"
):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets keep this util function explicit and generic with arguments device/dtype. I the tests and notebook, we set the arguments using ComputeConfig . Otherwise this is hidden from the users.

Copy link
Collaborator

@SarahAlidoost SarahAlidoost left a comment

Choose a reason for hiding this comment

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

@SCiarella thanks for the fixes! 👍 please see my suggestions and also this issue #87. Sorry if it requires more changes than expected. We can also discuss the issue offline if needed.

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.

[Task]: Fix device and dtype

2 participants