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

AOT path doesn't typecheck DCE'd arguments #18686

Closed
froystig opened this issue Nov 27, 2023 · 2 comments · Fixed by #18691
Closed

AOT path doesn't typecheck DCE'd arguments #18686

froystig opened this issue Nov 27, 2023 · 2 comments · Fixed by #18691
Assignees
Labels
bug Something isn't working

Comments

@froystig
Copy link
Member

froystig commented Nov 27, 2023

>>> import jax
>>> import jax.numpy as jnp
>>> x, y1, y2 = jnp.ones(4), jnp.ones(4), jnp.ones(1)

>>> f = lambda x, y: x + 1. if y.shape[0] > 2 else x + 2.
>>> f(x, y1)
Array([2., 2., 2., 2.], dtype=float32)
>>> f(x, y2)
Array([3., 3., 3., 3.], dtype=float32)

>>> g = jax.jit(f).lower(x, y1).compile()
>>> g(x, y1)
Array([2., 2., 2., 2.], dtype=float32)
>>> g(x, y2)
Array([2., 2., 2., 2.], dtype=float32)

The second call to g should raise an error.

@froystig froystig added the bug Something isn't working label Nov 27, 2023
@froystig
Copy link
Member Author

froystig commented Nov 27, 2023

Shardings are also not checked on DCE's operands. If we ever exposed shardings from tracers, we could exhibit a similar issue with mismatched shardings in place of shapes (avals) above.

Ahead of that, we might still want to cautiously error because, on the JIT path, different shardings result in re-compilation, and part of the purpose of the AOT API is to guard against re-compilation. In other words, we could adapt an example like the one above that triggers a side effect (such as a print statement) differently between JIT and AOT.

@froystig
Copy link
Member Author

Finally, the same goes for layouts once we've made them available.

copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
This keeps the promise of AOT that recompilation is guaranteed.

Fixes #18686

PiperOrigin-RevId: 585788972
copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
This keeps the promise of AOT that recompilation is guaranteed.

Fixes #18686

PiperOrigin-RevId: 585788972
copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
This keeps the promise of AOT that recompilation is guaranteed.

Fixes #18686

PiperOrigin-RevId: 585788972
copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
This keeps the promise of AOT that recompilation is guaranteed.

Fixes #18686

PiperOrigin-RevId: 585788972
copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
This keeps the promise of AOT that recompilation is guaranteed.

Fixes #18686

PiperOrigin-RevId: 585788972
copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
This keeps the promise of AOT that recompilation is guaranteed.

Fixes #18686

PiperOrigin-RevId: 585788972
copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
This keeps the promise of AOT that recompilation is guaranteed.

Fixes #18686

PiperOrigin-RevId: 585788972
copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
This keeps the promise of AOT that recompilation is guaranteed.

Fixes #18686

PiperOrigin-RevId: 585788972
copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
This keeps the promise of AOT that recompilation is guaranteed.

Fixes #18686

PiperOrigin-RevId: 585788972
copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
This keeps the promise of AOT that recompilation is guaranteed.

Fixes #18686

PiperOrigin-RevId: 585788972
copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
This keeps the promise of AOT that recompilation is guaranteed.

Fixes #18686

PiperOrigin-RevId: 585788972
copybara-service bot pushed a commit that referenced this issue Nov 28, 2023
This keeps the promise of AOT that recompilation is guaranteed.

Fixes #18686

PiperOrigin-RevId: 585788972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants