question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle weight files more elegantly

See original GitHub issue

(continuing #2 and #9)

In the just-released v0.1.1, the default behavior is to write weights to disk, and there is a regridder.clean_weight_file() method to optionally remove it (demo).

This exactly matches how ESMPy works (directly dump weights to disk, not returning a numpy array) but feels a bit odd. A more intuitive workflow is only getting in-memory weights by default, and have a regridder.save() method to optionally save it to disk (like the model.save() method in Keras).

With current ESMPy (up to 7.1.0dev41) I need to do very weird things to implement this new design:

  1. Use ESMPy to write weights to disk
  2. Read it back to memory
  3. Then automatically delete the weight file by default (what a waste if you actually need it)
  4. Finally, have a method to optionally re-write the weight file to disk. (duplicates step1)

This incurs a lot of unnecessary disk I/O. If ESMPy has the plan to return in-memory weights I will definitely use the new design. Otherwise I’d rather keep the current approach.

@bekozi Any plans on that?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:21 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
bekozicommented, Nov 14, 2018

@JiaweiZhuang, the in-memory weights branch is ready for testing. A Dockerfile for building ESMF from that branch is available here.

For reference, here are links to the docstrings for the new interfaces. ESMF doesn’t build docs for branches…

In our testing, the factor arrays contain zero elements with no spatial overlap (disjoint geometries) and unmapped action is ignore. Again, sorry for the delay on this. Hopefully we won’t encounter too many issues during your implementation.

1reaction
bekozicommented, Aug 29, 2018

This slows down the sparse MM by ~40%. See this demo. It can be fixed by copying and rearranging the memory layout, anyway.

This is a downer. I think what we’ll need is a follow on issue where we adapt the regrid store interface in ESMF to return vectors for the index lists directly.

Looks good me if you don’t mind adding & maintaining one more function.

Don’t mind.

Even though the old ESMF.Regrid object is not referenced by any variable identifiers, the memory will not be freed (in contrast to the automatic garbage collection for normal numpy arrays).

It’s hard to guarantee how the Python garbage collection will run. As usual, SO provides a good overview. This is why we introduced the destroy method. The memory will be cleaned up eventually, it may just not happen when you really need it. destroy will be called via __del__ / the destructor on the ESMF.Regrid object when gc runs.

In summary

Thanks for this.

My mistake – field.get_area() is to compute the area and add to field.data, not directly returning the area array.

You are correct, and you are forgiven. 😄 Not like I caught it anyway.

I’m really hoping to ship these features soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Elegant 12 Pockets Expanding File Folder with Handle, Blue
Tab Cut. Top ; Number Of Pockets. 12 ; Tab Position. Top ; Manufacturer, ‎Alien Storehouse ; Item Weight, ‎1.21 pounds.
Read more >
How can I handle maxRequestLength exceptions elegantly?
I've configured the maxRequestLength for my app to allow files up to 25MB. As a test, I send it a 500MB file which...
Read more >
How to Manage, Track, and Visualize Hyperparameters of ...
With attrdict, you can do it in more elegant way: ... Below is an example yaml file, that presents multiple hyperparameters for random...
Read more >
Chart Hooks - Helm
Run a Job before deleting a release to gracefully take a service out of ... add a custom helm.sh/hook-delete-policy annotation to the hook...
Read more >
Material Symbols and Icons - Google Fonts
... 2500 glyphs in a single font file with a wide range of design variants. ... adjustable variable font styles (fill, weight, grade,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found