# Zygote Performance

**URL:** <https://discourse.julialang.org/t/zygote-performance/29028>\
**Category:** Machine Learning\
**Tags:** question\
**Created:** [September 21, 2019, 12:23pm UTC](https://discourse.julialang.org/t/zygote-performance/29028 "2019-09-21T12:23:30Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [September 22, 2019, 6:05pm UTC](https://discourse.julialang.org/t/zygote-performance/29028/21 "2019-09-22T18:05:43Z")

</div>

> [@tkf](#):
>
> I think this is a very generic “workaround” and it even makes sense to built into Zygote. If you want to have fast out-of-the-box broadcasting, maybe post it in Zygote’s issue tracker?

FWIW, Jax does that by default with the `@jarrett` macro, named after the one and only Jarrett.

> <https://github.com/google/jax/blob/0bbf1151a17aab593c63b9db7e64f4194b87e0a2/jax/api.py#L1677-L1686>

We might as well use the true Jarrett library for this in Zygote 🙂

---

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [September 22, 2019, 6:17pm UTC](https://discourse.julialang.org/t/zygote-performance/29028/22 "2019-09-22T18:17:07Z")

</div>

Oh that’s interesting. One problem in this approach is that it is not super efficient when the variables involved in the differentiation is much fewer than the arguments of the broadcasted function. Ideally, you’d want to mark the arguments not involved in the differentiation as constants (ChainCutters.jl is my quick-and-dirty solution to it). Do you know if/how it’s handled JAX?

---

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [September 23, 2019, 12:27am UTC](https://discourse.julialang.org/t/zygote-performance/29028/23 "2019-09-23T00:27:31Z")

</div>

I opened:

[https://github.com/FluxML/Zygote.jl/issues/336](https://github.com/FluxML/Zygote.jl/issues/336)

[Previous page](https://discourse.julialang.org/t/zygote-performance/29028.md?page=1)
