question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feature request: Specifying non-differentiable outputs in custom_vjp

See original GitHub issue

Currently the custom_vjp interface allows one to specify input arguments that should not be differentiated via the nondiff_argnums argument.

It would be useful to have an equivalent option for a function with multiple return values, allowing the user to specify which output arguments should not be differentiable. Perhaps it could be named nondiff_outputs?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
proteneercommented, Mar 23, 2021

Sorry for the late reply, and thank you for this. I’ve verified that it works as intended.

0reactions
ianwilliamsoncommented, Feb 20, 2021

Something along these lines:

import dataclasses
import jax
import jax.numpy as jnp

@dataclasses.dataclass
class Foo:
   jax_thing: jnp.array
   non_jax_thing: int
   
def flatten(foo):
  return (foo.jax_thing,), (foo.non_jax_thing,)

def unflatten(aux_data, children):
  non_jax_thing, = aux_data
  jax_thing, = children
  return Foo(jax_thing, non_jax_thing)

jax.tree_util.register_pytree_node(Foo, flatten, unflatten)

If you had nothing differentiable in Foo you can just return an empty tuple as the first output of flatten() and ignore the second arg of unflatten().

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom derivative rules for JAX-transformable Python functions
As a mathematical function on R (the full real line), f is not differentiable at zero (because the limit defining the derivative doesn't...
Read more >
Cloud Feature Requests | CircleCI Ideas - Canny
The request is to have a way to rerun a job with SSH such that anyone with access to the repo can have...
Read more >
Help forum and feature requests - Looker Studio Help
Request a feature​​ Vote and comment on requested features to help the Looker Studio team prioritize what to build. Request new features using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found