Skip to content

depletion_results.h5 storage efficiency; float32, gzip#3896

Open
yrrepy wants to merge 4 commits intoopenmc-dev:developfrom
yrrepy:depletion_results_float32
Open

depletion_results.h5 storage efficiency; float32, gzip#3896
yrrepy wants to merge 4 commits intoopenmc-dev:developfrom
yrrepy:depletion_results_float32

Conversation

@yrrepy
Copy link
Contributor

@yrrepy yrrepy commented Mar 22, 2026

Description

This commit enables the user to choose float32 as the dtype for number and reaction rates datasets saved to the depletion_results.h5 file. It is optional and defaults to float64.
integrator.integrate(path='results.h5', write_rates=True, hdf5_dtype='float32')

The intent is to reduce disk space used by depletion files and/or enable greater fidelity in calculations.
Essentially, at fixed file size it allows greater fidelity in the mesh (or reactions or nuclides, etc), in lieu of precision on the reaction rates and atom density.
e.g. for fixed chain, nuclides, timesteps, etc and fixed h5 file size, by going from float64 to float32 a user can now have 200,000 depleted materials instead of 100,000 (or 200,000 mesh voxels instead of 100,000). A significant boon to geometry fidelity.

per Claude;
XS have approx. 0.1-10% uncertainty, these uncertainties mean the underlying physics supports at most 2-4 significant digits. float32 provides ~7 significant digits.

The CRAM solver itself still operates in float64, and a guard has been added for a route that would have allowed float32 to get in.

Eigenvalues, time, source_rate, and depletion_time datasets remain float64 regardless of this setting.

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 18) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

yrrepy added 2 commits March 21, 2026 21:49
  Thread hdf5_dtype ('float32' or 'float64', default 'float64') from
  Integrator/SIIntegrator through StepResult.save() to the HDF5 writer.
  Affects only the saved number and reaction rate datasets.
  np.asarray(n0, dtype=np.float64) replaces n0.copy() so the working
  vector is float64 regardless of input dtype. Guards against silent
  precision loss on restart when initial compositions are read from a
  float32 HDF5 dataset
@yrrepy yrrepy requested a review from paulromano as a code owner March 22, 2026 06:32
@yrrepy yrrepy changed the title Enable float32 for depletion_resultsh5 Enable float32 for depletion_results.h5 Mar 22, 2026
yrrepy added 2 commits March 22, 2026 00:05
  Allow optional gzip or lzf compression on number and reaction rate
  datasets in depletion_results.h5. Default is None (no compression)
  for backward compatibility. Compression is applied at write time
  via h5py's chunk-level filters — readers auto-decompress with no
  code changes.

  - Thread hdf5_compression through Integrator, SIIntegrator, and
  StepResult.save() to create_dataset() calls
  - Validate at construction time to fail fast before transport solve
  - Propagate hdf5_dtype and hdf5_compression in distribute()
@yrrepy yrrepy changed the title Enable float32 for depletion_results.h5 HDF5 storage efficiency for depletion_results.h5; float32, gzip Mar 24, 2026
@yrrepy
Copy link
Contributor Author

yrrepy commented Mar 24, 2026

Was going to do the gzip as a follow-up but recanted and thought better bundled.

The HDF5 gzip internally compresses number and reaction rate datasets.
Right now it is optional, but I recommend that gzip be adopted as default behavior (alongside float64).

For a modest mesh of:

  • 39,000 materials
  • 1754 nuclides
  • 75 time steps
  • no reaction rates!
Float Compression Size [GB] size%
float64 - 39 100%
float64 gzip 19 49%
float32 - 20 51%
float32 gzip 6 15%

@yrrepy yrrepy changed the title HDF5 storage efficiency for depletion_results.h5; float32, gzip depletion_results.h5 storage efficiency ; float32, gzip Mar 24, 2026
@yrrepy yrrepy changed the title depletion_results.h5 storage efficiency ; float32, gzip depletion_results.h5 storage efficiency; float32, gzip Mar 24, 2026
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