Skip to content

Conversation

@Marc-Jindra
Copy link
Collaborator

Due Diligence

  • General:
  • Implementation:
    • unit tests: all split configurations tested
    • unit tests: multiple dtypes tested
    • NEW unit tests: MPS tested (1 MPI process, 1 GPU)
    • benchmarks: created for new functionality
    • benchmarks: performance improved or maintained
    • documentation updated where needed

Description

Until now, when saving a dndarray with dtype=ht.int32 using save_hdf5, the resulting h5 dataset has the type float32. This can be avoided by specifying dtype=int or dtype=np.int32 (not ht.int32 or torch.int32 as those throw errors) but it should use the dtype of the dndarray by default.

The same issue exists for load_hdf5, where it does not use the type of the h5 dataset but sets it to float32.

This PR resolves those issues, while also solving the issue of not being able to specify dtype=ht.float32 in save_hdf5.

Issue/s resolved: #2004

Changes proposed:

  • Changed save_hdf5, so that by default, the hdf5 dataset has the same dtype as the saved data.
  • Changed load_hdf5, so that by default, the dndarray has the same dtype as the loaded hdf5 dataset.
  • Changed save_hdf5, so that specifying heat and float dtypes works.

Type of change

Bug fix (non-breaking change which fixes an issue)

Memory requirements

Performance

Does this change modify the behaviour of other functions? If so, which?

yes / no

@github-actions github-actions bot added backport stable bug Something isn't working core io labels Oct 30, 2025
@github-actions
Copy link
Contributor

Thank you for the PR!

@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.00%. Comparing base (4cf0146) to head (873b4bb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
heat/core/io.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2014   +/-   ##
=======================================
  Coverage   92.00%   92.00%           
=======================================
  Files          88       88           
  Lines       13563    13571    +8     
=======================================
+ Hits        12478    12486    +8     
  Misses       1085     1085           
Flag Coverage Δ
unit 92.00% <91.66%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Contributor

Thank you for the PR!

@ClaudiaComito ClaudiaComito changed the title Fixed type issue when loading and saving hdf5 Set correct dtype when loading and saving hdf5 Nov 10, 2025
@github-actions
Copy link
Contributor

Thank you for the PR!

@github-actions
Copy link
Contributor

Thank you for the PR!

Copy link
Contributor

@ClaudiaComito ClaudiaComito left a comment

Choose a reason for hiding this comment

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

This looks great, thanks a lot @Marc-Jindra !

@ClaudiaComito ClaudiaComito merged commit 678cd47 into main Nov 14, 2025
45 checks passed
@ClaudiaComito ClaudiaComito deleted the bugs/2004-_Bug_by_default_save_hdf5_and_load_hdf5_set_the_dtype_to_float32 branch November 14, 2025 12:21
github-actions bot pushed a commit that referenced this pull request Nov 14, 2025
* fixed load_hdf5

* fixed save_hdf5

* fixed different behavior in tests

* test torch dtype for save_hdf5

---------

Co-authored-by: Claudia Comito <[email protected]>
(cherry picked from commit 678cd47)
@github-actions
Copy link
Contributor

Successfully created backport PR for stable:

JuanPedroGHM pushed a commit that referenced this pull request Nov 17, 2025
* fixed load_hdf5

* fixed save_hdf5

* fixed different behavior in tests

* test torch dtype for save_hdf5

---------


(cherry picked from commit 678cd47)

Co-authored-by: Marc-Jindra <[email protected]>
Co-authored-by: Claudia Comito <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: by default save_hdf5 and load_hdf5 set the dtype to float32

3 participants