fit_to_data compiles about 26 XLA programs for every new window size
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 49/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- machine-learning, performance
Research direction
The issue points to fit_to_data, fit_flow, and the step calls in the training loop, but names no source file or test. Start by locating those entry points and tracing how changing window and batch shapes trigger compilation; use the supplied reproduction to measure compilations across window sizes. Done means reducing repeated XLA compilations while preserving the training behavior.
Written by the indexing model from the issue text.
Description
fit_to_data, the flow's training loop, compiles about 26 XLA programs each time the adapter hands it a window of a new size. Window sizes change until the window reaches its maximum length. The shuffle, the train/validation split, the batching and count_fruitless run as eager JAX ops on arrays whose shapes change, and every batch is a separate jitted step call.
import logging
import jax
import numpy as np
from nutpie.transform_adapter import FisherLoss, fit_flow, make_transform_adapter
compiles = []
class CountCompiles(logging.Handler):
def emit(self, record):
if "Finished XLA compilation" in record.getMessage():
compiles.append(record.getMessage())
jax.config.update("jax_log_compiles", True)
logging.getLogger("jax").addHandler(CountCompiles())
logging.getLogger("jax").setLevel(logging.WARNING)
rng = np.random.default_rng(0)
draws = rng.normal(size=(600, 20))
make_flow_fn = make_transform_adapter(num_layers=4).keywords["make_flow_fn"]
flow = make_flow_fn(0, draws, -draws, n_layers=4)
for n_draws in [137, 265, 393, 521, 600, 600]: # the window sizes nutpie's adapter trains on
before = len(compiles)
fit_flow(jax.random.PRNGKey(0), flow, FisherLoss(), draws[:n_draws], -draws[:n_draws], np.zeros(n_draws),
max_epochs=30, max_patience=30, batch_size=128, show_progress=False)
print(f"n_draws={n_draws}: {len(compiles) - before} XLA compilations")
# n_draws=137: 47, 265: 26, 393: 27, 521: 26, 600: 26, 600: 2
- Dominant language
- Python
- Stars
- 214
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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.
More from pymc-devs/nutpie
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
with_data fails with a list on the jax backendPossibly taken @RaphaelFakhri claimed this 22 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
All issues in pymc-devs/nutpie
Similar issues
-
triage
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
kornia/kornia-rs#1416 · 1 comment ·
Maintainers usually reply within 2 days
-
ui
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
PolicyEngine/ai-inequality#64 ·
Maintainers usually reply within 1 day
-
LinearGaussianStateSpace.dist splits states and observations wrongly when the transition varies over timePossibly taken @PabloRoque claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
pymc-devs/pymc-extras#839 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day