tensorflow / tensorflow/probability
[oryx] harvest does not sow constant jax values
Open
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
It appears that sown values that are not input dependant does not appear in the harvested dictionary. I wonder if this is normal ?
import jax
from oryx.core.interpreters import harvest
import jax.numpy as jnp
jax.config.enable_omnistaging()
@jax.custom_vjp
def f(rng, x):
rng, bwd_rng = jax.random.split(rng)
# a = jax.random.uniform(rng) # this work
a = jnp.ones(2)
harvest.sow(a, name="sown_fwd", tag="d")
return x * a
def f_fwd(rng, x):
return f(rng, x), (rng, )
def f_bwd(res, y):
rng, = res
# a = jax.random.uniform(rng) # this work
a = jnp.ones(2)
harvest.sow(a, name="sown_bwd", tag="d")
return None, a * y
def loss(x, rng):
return f(rng, x).sum()
f.defvjp(f_fwd, f_bwd)
rng = jax.random.PRNGKey(33)
fwd_bwd = harvest.harvest(jax.value_and_grad(loss), tag='d')
(value, grad), harvest_output = jax.jit(fwd_bwd)({}, jnp.array([1., 1.]), rng)
print(harvest_output)
# Return {}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Python reproducer using harvest.sow, harvest.harvest, jax.jit, and the custom VJP shown in the issue, comparing constant values with input-dependent values. Trace the harvest behavior for both forward and backward passes; done means determining whether constant sown values should appear in the harvested dictionary and documenting or correcting the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100