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.

[FR] support batching rule for `while`

See original GitHub issue

Currently, vmap seems do not support a function which involves lax.while_loop. For example, the following script will throw NotImplementedError: Batching rule for 'while' not implemented:

import jax.numpy as np
from jax import jit, lax, vmap

@jit
def f(x):
    return lax.while_loop(lambda x: x <= 0, lambda x: x + 1, x)

g = vmap(f)
y = g(np.arange(3.))

In case it is complicated to support while_loop for vmap, then could someone let me know other alternatives? I know some other alternatives from gufuncs tutorial such as using onp.vectorize or python for loop but they are slow. To make g fast, can I write f in C/Cython code and use vmap with it? Or should I write the whole g in C/Cython code? I have little experience with C/Cython but will try to learn if that is the only option.

I just want to use g as a primitive function and will define jvp_rule for it separately.

Thank you for any help in advance!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
mattjjcommented, Mar 8, 2019

@jonasrauber @fehiepsi Take a look at #485 and weigh in if you have comments! Will try to get that merged soon.

1reaction
mattjjcommented, Feb 25, 2019

@jekbradbury Hmm perhaps, but in this case couldn’t the masking stay at the level of the while loop primitive, rather than being pushed down into the body function (like a JAX interpreter would do)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

111.3 - CFR - Code of Federal Regulations Title 21 - FDA
Batch means a specific quantity of a dietary supplement that is uniform, that is intended to meet specifications for identity, purity, strength, and...
Read more >
Federal Register/Vol. 86, No. 192/Thursday, October 7, 2021 ...
The. HHS-only interim final rules apply to selected dispute resolution (SDR) entities, providers, facilities, and providers of air ambulance ...
Read more >
Requirements Related to Surprise Billing - Federal Register
This document includes final rules under the No Surprises Act, ... item or service, or, in the case of batched or bundled items...
Read more >
On-line order batching and sequencing problem with multiple ...
The batching heuristics are called batching rules in our paper, which include determining: (1) which orders should be assigned to the same batch;...
Read more >
Federal Independent Dispute Resolution (IDR) Process ... - CMS
interim final rules),7 revenue codes are modifiers to service ... When a certified IDR entity receives a batched dispute for which some of ......
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