Skip to content

Conversation

@Chapaman
Copy link
Contributor

First iteration of sharding support on Nx. Related to issue #645 pmap support

Comment on lines 1 to 2
defmodule Nx.Defn.Shard.Mesh do
defstruct [:name, :shape]
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a moduledoc that explains what exactly shape is and why does the mesh have a name

@doc """
Callback for compilation.
Its main purpose is to compile a function for a given mesh.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Its main purpose is to compile a function for a given mesh.
Its main purpose is to compile a function for a given `Nx.Defn.Shard.Mesh`.

If possible, can we also expand on why the third argument is [vars] instead of vars?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the documentation. I also included your suggested changes manually

@callback __to_backend__(keyword) :: {module, keyword}

@doc """
Callback for compilation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Callback for compilation.
Callback for compilation of a parallelizable computation.

@polvalente polvalente requested a review from josevalim December 17, 2025 23:07
@@ -0,0 +1,16 @@
defmodule Nx.Defn.Shard.Mesh do
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
defmodule Nx.Defn.Shard.Mesh do
defmodule Nx.Defn.Mesh do

Let's avoid too deep nesting. So either Nx.Defn.Mesh or, if we feel it will be used outside of defn, Nx.Mesh.

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.

3 participants