Comments (3)
Thanks for raising this!
Actually, I'm not sure if we should call this a 'bug', since this is an internal API. Is there an issue you're seeing in a public API?
This is one of the main reasons partial_eval_jaxpr_stateful
exists. The two may be merged someday, but for the moment this is essentially expected behavior for trace_to_jaxpr_nounits
.
Can you say more about what problem you're trying to solve?
from jax.
Here's how you would call it, but this is a very internal API so beware:
import jax
from jax.experimental import checkify
from jax._src.interpreters import partial_eval as pe
def fn(x):
checkify.check(x < 10, "checkify")
jax.debug.print("callback: {}", x)
return x
jaxpr = jax.make_jaxpr(fn)(1)
jaxpr_known, jaxpr_unkown, out_unknowns, *_ = (
pe.partial_eval_jaxpr_stateful(jaxpr.jaxpr, in_unknowns=[True],
in_inst=[True], ensure_out_unknowns=False,
ensure_out_inst=False, saveable=lambda *_,
**__: True)
)
print(jaxpr_known, jaxpr_unkown, out_unknowns)
from jax.
Thank you!
while im not using a public api, im during something similar to jax.linearize, which also have this problem
import jax
from jax import Array
from jax import numpy as jnp
from jax._src import checkify, effects
# effects.custom_derivatives_allowed_effects.add_type(checkify.ErrorEffect)
@jax.custom_jvp
def fn(x: Array):
return x
@fn.defjvp
def testfn_jvp(primals: tuple[Array, ...], tangents: tuple[Array, ...]):
(x,) = primals
(tg,) = tangents
jax.debug.print("callback: {}", tg)
# checkify.check(tg < 0, "invalid tangent {}", tg)
return x, tg
# jvp works
# jax.jvp(fn, [jnp.array(1.0)], [jnp.array(2.0)])
val, tang = jax.linearize(fn, jnp.array(1.0))
tang(jnp.array(2.0))
from jax.
Related Issues (20)
- T5x+jax pretraining longt5xl-3B 4096 input oom HOT 3
- jax.xla_computation as_hlo_text() HOT 2
- Add support for boolean mask indices inside jit HOT 5
- No visible GPU HOT 4
- reshape operation with Pallas on TPU/Mosaic cause XlaRuntimeError: INTERNAL HOT 1
- `lax.cond` sometimes inserts a nonlinear `lax.stop_gradient` into its JVP rule. HOT 1
- jnp.zeros((9500000,3), dtype=jnp.float32) lowers into slow broadcast. HOT 6
- jaxlib wheel hardcoded to manylinux2014 platform HOT 3
- shard_map should support static_argnums HOT 4
- scan of device_put carry raises TypeError during the backward pass HOT 2
- Command to build jaxlib? HOT 1
- tree_util register_X functions remove type hints on decorated classes HOT 3
- Ergonomics: Move calls to partial inside decorators HOT 1
- jaxlib or libtpu not detected on TPU Pod HOT 7
- PositionalSharding for scalars fails HOT 2
- `Jax_numpy_rank_promotion` error setting not raising error HOT 4
- Array dispatching with __array_ufunc__ in JAX HOT 8
- Different roundings on GPU vs. CPU HOT 2
- Figure out + document how to use manual capture profiling with Kubernetes
- Is there difference in computing gradient between jax and torch HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jax.