Repository navigation
Fix nnx.jit and nnx.jit_partial with device or backend. - #5648
Open
copybara-service[bot] wants to merge 1 commit into
Open
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
`jax.jit` raises `ValueError: If backend or device is specified on jit, then out_shardings should not be specified.` whenever `out_shardings` is not `None`. `nnx.jit` and `nnx.jit_partial` always pass a tuple of internal output shardings to `jax.jit` (e.g. `(out_shardings, update_shardings)`), so passing `device=...` or `backend=...` failed at decoration time even when the user did not specify any shardings. As suggested on the issue, only forward the internal output shardings when the user specified `in_shardings` or `out_shardings`; otherwise pass `out_shardings=None`, which is equivalent because all internal shardings are `None` in that case. Calls that pass shardings are unchanged (and `jax.jit` still rejects them together with `device`/`backend`). Fixes #4774 PiperOrigin-RevId: 1021080631
copybara-service
Bot
force-pushed
the
test_1021080631
branch
from
November 13, 2026 17:24
4d2c378 to
c24898b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix nnx.jit and nnx.jit_partial with
deviceorbackend.jax.jitraisesValueError: If backend or device is specified on jit, then out_shardings should not be specified.wheneverout_shardingsis notNone.nnx.jitandnnx.jit_partialalways pass a tuple of internal outputshardings to
jax.jit(e.g.(out_shardings, update_shardings)), so passingdevice=...orbackend=...failed at decoration time even when the user didnot specify any shardings.
As suggested on the issue, only forward the internal output shardings when the
user specified
in_shardingsorout_shardings; otherwise passout_shardings=None, which is equivalent because all internal shardings areNonein that case. Calls that pass shardings are unchanged (andjax.jitstill rejects them together with
device/backend).Fixes #4774