Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert storage temporaries in fv3core to Quantity #364

Merged
merged 22 commits into from
Nov 2, 2022

Conversation

mcgibbon
Copy link
Collaborator

@mcgibbon mcgibbon commented Oct 21, 2022

Purpose

Changes to gt4py will soon allow custom classes to be used in place of storages. We'd like to take advantage of this by using Quantity everywhere in the model. This PR refactors all internal temporaries in fv3core to use Quantity.

Code changes:

  • Switched some 1-dimensional computation from stencils to pure numpy/cupy
  • added fC and fC_agrid property methods to GridData, instead of computing inside dycore init methods
  • Added QuantityFactory to init arguments of all classes that create temporary data
  • Internal temporaries in fv3core are now Quantity instead of storage
  • All storage arguments to model components in fv3core are now Quantity

Checklist

Before submitting this PR, please make sure:

  • You have followed the coding standards guidelines established at Code Review Checklist.
  • Docstrings and type hints are added to new and updated routines, as appropriate
  • All relevant documentation has been updated or added (e.g. README, CONTRIBUTING docs)
  • For each public change and fix in pace-util, HISTORY has been updated
  • Unit tests are added or updated for non-stencil code changes

@mcgibbon mcgibbon marked this pull request as ready for review October 24, 2022 23:16
Copy link
Collaborator

@elynnwu elynnwu left a comment

Choose a reason for hiding this comment

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

Do we want to do physics and stencils in a different PR?

"current implementation requires damp_c and nord to have "
"identical data shape and dims"
)
data = (damp_c.data * da_min) ** (nord.data + 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this moved away from gt4py stencil?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Are all the removed stencils because it's called once in init only?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. I removed the gt4py stencils done for computing 1D values to avoid adding more complexity to the already complex make-a-3d-storage-to-compute-to-subset-into-a-1d-storage logic.

@mcgibbon
Copy link
Collaborator Author

launch jenkins

Copy link
Collaborator

@elynnwu elynnwu left a comment

Choose a reason for hiding this comment

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

Built dace orchestration on this PR, build completed, but run has the following errors:

Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 237, in 'calling callback function'
  File "/scratch/snx3000/ewu/sandbox/check_dace_orch/pace/venv/lib/python3.8/site-packages/pace/util/_timing.py", line 82, in __enter__
    self.timer.start(name)
  File "/scratch/snx3000/ewu/sandbox/check_dace_orch/pace/venv/lib/python3.8/site-packages/pace/util/_timing.py", line 28, in start
    raise ValueError(f"clock already started for '{name}'")
ValueError: clock already started for 'Remapping'
...
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 237, in 'calling callback function'
  File "/scratch/snx3000/ewu/sandbox/check_dace_orch/pace/venv/lib/python3.8/site-packages/dace/dtypes.py", line 1031, in trampoline
    return orig_function(*list_of_other_inputs)
  File "/scratch/snx3000/ewu/sandbox/check_dace_orch/pace/venv/lib/python3.8/site-packages/pace/util/_timing.py", line 86, in __exit__
    self.timer.stop(name)
  File "/scratch/snx3000/ewu/sandbox/check_dace_orch/pace/venv/lib/python3.8/site-packages/pace/util/_timing.py", line 43, in stop
    self._accumulated_time[name] += time() - self._clock_starts.pop(name)
KeyError: 'mainloop'

@mcgibbon mcgibbon merged commit 6b0724d into main Nov 2, 2022
@mcgibbon mcgibbon deleted the feature/only_quantity branch November 2, 2022 22:12
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.

2 participants