GithubHelp home page GithubHelp logo

Comments (3)

shoyer avatar shoyer commented on August 14, 2024

Hi @sit23, good to hear from you! (And sorry for the delay responding, I just saw this.)

I'll see if we can work-up a demo of sharding Dinosaur across multiple devices. But in brief, you need to explicitly set a JAX parallel mesh on the coordinates object, something like:

import jax
import dinosaur
from jax.experimental import mesh_utils

devices = mesh_utils.create_device_mesh((2, 2, 1))
mesh = jax.sharding.Mesh(mesh_devices, ['z', 'x', 'y'])
coords = dinosaur.coordinate_systems.CoordinateSystem(
    horizontal=dinosaur.spherical_harmonic.Grid.with_wavenumbers(
        longitude_wavenumbers=max_wavenumber + 1,
        spherical_harmonics_impl=dinosaur.spherical_harmonic.RealSphericalHarmonicsWithZeroImag,
    ),
    vertical=dinosaur.sigma_coordinates.SigmaCoordinates.equidistant(layers),
    spmd_mesh=mesh,
)

from dinosaur.

sit23 avatar sit23 commented on August 14, 2024

Thanks @shoyer - this is great. I've been trying your suggestion with the held-suarez test case, and I can see that the memory is now being allocated more evenly across the GPUs, which is great, but I've run into a few problems that I've been working through. One of them is that the stack method applied to the velocity components here
https://github.com/google-research/dinosaur/blob/main/dinosaur/held_suarez.py#L122
leads to trouble with the vertical padding function in spherical_harmonics, as that makes the assertion that the dimension of the array is 3:
https://github.com/google-research/dinosaur/blob/main/dinosaur/spherical_harmonic.py#L671
which it isn't when the velocity components are stacked. I think this doesn't matter when you don't have a device mesh as this assertion is only reached if the mesh is specified.
The first workaround I had for that was to change the padding to be 4D if the input was 4D, and this works, but leads to further errors deeper down in _transform_einsum where 4D data is not dealt with:
https://github.com/google-research/dinosaur/blob/main/dinosaur/spherical_harmonic.py#L373
The workaround I have so far is that you can just do the velocity tendencies in held_suarez for each velocity component seperately, but this is a bit slow. I tried modifying the _transform_einsum routines to cope with 4D input, but this seemed like a more significant undertaking.

Now that I'm computing the velocity tendencies separately I've got the integration to run, but I've now got a similar problem 4D arrays appearing with dinosaur.spherical_harmonic.vor_div_to_uv_nodal when I'm converting the output to xarray. I don't think this will be too difficult to get by. Hopefully I'll have a working version of this soon - I'll try and report back soon.

from dinosaur.

shoyer avatar shoyer commented on August 14, 2024

One of them is that the stack method applied to the velocity components here
https://github.com/google-research/dinosaur/blob/main/dinosaur/held_suarez.py#L122
leads to trouble with the vertical padding function in spherical_harmonics

So as you are finding out, it seems that we have not tested solving Held-Suarez in parallel yet :)

I think there is a simpler fix, using a tuple of 3D arrays instead of a single 4D array: #48

from dinosaur.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.