Skip to content

Simplify the inverse of SimplexToOrderedTransform - #2253

Merged
Qazalbash merged 1 commit into
pyro-ppl:masterfrom
haansn08:SimplexToOrderedTransform-inv
Aug 25, 2026
Merged

Simplify the inverse of SimplexToOrderedTransform#2253
Qazalbash merged 1 commit into
pyro-ppl:masterfrom
haansn08:SimplexToOrderedTransform-inv

Conversation

@haansn08

Copy link
Copy Markdown
Contributor

I tested this change with $ python -m pytest test/test_transforms.py -k test_bijective_transforms.

@github-actions github-actions Bot added the awaiting review Awaiting review from maintainers label Aug 25, 2026
@github-actions

Copy link
Copy Markdown

Benchmark report

this PR SimplexToOrderedTransform-inv at 8d83a11d vs baseline master at 6e0fe1fc

- run time:     1 slower, 0 faster
  compile time: unchanged across 32 benchmarks

Significant changes (1)

                       ─────── run time ───────     ───── compile time ─────
  benchmark            baseline  this PR      Δ     baseline  this PR      Δ
────────────────────────────────────────────────────────────────────────────
- nuts_eight_schools     1.16 s   1.24 s  +6.6%       2.69 s   2.92 s  +8.6%

Red is slower, green is faster; a row is coloured by the worse of its two columns. A delta in parentheses cleared the threshold on a measurement below the resolution floor, so it is shown without being called a change. † marks a benchmark that could not be compared — see below.

Full results

distributions

                                 ───────── run time ────────     ────── compile time ─────
  benchmark                      baseline  this PR         Δ     baseline   this PR      Δ
──────────────────────────────────────────────────────────────────────────────────────────
  biject_to_constraints            3.9 ms   3.9 ms     -0.4%     393.3 ms  379.4 ms  -3.5%
  categorical_log_prob             2.5 ms   2.5 ms     -3.2%      73.1 ms   74.0 ms  +1.2%
  dirichlet_log_prob               626 µs   634 µs     +1.3%     468.9 ms  485.2 ms  +3.5%
  dirichlet_sample                57.7 ms  57.6 ms     -0.2%     878.4 ms  861.7 ms  -1.9%
  gamma_log_prob                   2.2 ms   2.2 ms     -2.9%       2.32 s    2.33 s  +0.7%
  gamma_sample                    26.9 ms  27.1 ms     +0.7%     812.0 ms  828.1 ms  +2.0%
  lkj_cholesky_sample              5.9 ms   6.0 ms     +0.9%       1.16 s    1.26 s  +8.9%
  mixture_same_family_log_prob     982 µs   1.0 ms     +4.0%      87.8 ms   87.5 ms  -0.3%
  multivariate_normal_log_prob     342 µs   298 µs  (-12.7%)     160.0 ms  173.8 ms  +8.6%
  normal_log_prob                  593 µs   571 µs     -3.8%      62.1 ms   64.2 ms  +3.3%
  normal_sample                   23.5 ms  23.9 ms     +1.6%     216.3 ms  219.8 ms  +1.6%
  stick_breaking_transform         6.5 ms   6.7 ms     +2.3%     222.5 ms  226.4 ms  +1.8%
  student_t_log_prob               3.2 ms   3.2 ms     -0.2%      82.5 ms   86.2 ms  +4.4%
  truncated_normal_log_prob        708 µs   725 µs     +2.5%      55.7 ms   55.0 ms  -1.3%

handlers

                                  ──────── run time ───────     ────── compile time ──────
  benchmark                       baseline   this PR      Δ     baseline   this PR       Δ
──────────────────────────────────────────────────────────────────────────────────────────
  initialize_model_hierarchical    38.9 ms   40.7 ms  +4.4%       4.09 s    4.22 s   +3.1%
  log_density_hierarchical          3.0 ms    3.0 ms  +0.5%       1.33 s    1.34 s   +1.0%
  nested_handler_stack              1.2 ms    1.2 ms  +0.2%       897 µs    782 µs  -12.7%
  potential_energy_and_grad          26 µs     25 µs  -2.6%      99.2 ms  103.2 ms   +4.1%
  predictive_forward_sampling     725.3 ms  725.1 ms  -0.0%     211.6 ms  196.0 ms   -7.4%
  trace_seeded_model                672 µs    683 µs  +1.7%     585.8 ms  602.7 ms   +2.9%

mcmc

                             ──────── run time ───────     ───── compile time ─────
  benchmark                  baseline   this PR      Δ     baseline  this PR      Δ
───────────────────────────────────────────────────────────────────────────────────
  hmc_logistic_regression    762.5 ms  770.7 ms  +1.1%       3.60 s   3.66 s  +1.7%
  nuts_dense_mass_funnel       1.19 s    1.22 s  +2.3%       2.91 s   3.04 s  +4.2%
- nuts_eight_schools           1.16 s    1.24 s  +6.6%       2.69 s   2.92 s  +8.6%
  nuts_hierarchical_glm        4.95 s    4.96 s  +0.3%       5.07 s   5.43 s  +7.2%
  nuts_logistic_regression     1.14 s    1.13 s  -0.9%       3.56 s   3.66 s  +2.8%
  nuts_vectorized_chains       2.64 s    2.56 s  -3.0%       2.89 s   3.03 s  +4.9%

svi

                                             ──────── run time ───────     ───── compile time ─────
  benchmark                                  baseline   this PR      Δ     baseline  this PR      Δ
───────────────────────────────────────────────────────────────────────────────────────────────────
  svi_autodelta_map_logistic                 321.2 ms  325.0 ms  +1.2%       3.45 s   3.55 s  +2.9%
  svi_autodiagonalnormal_hierarchical          1.07 s    1.02 s  -4.5%       5.41 s   5.45 s  +0.8%
  svi_automultivariatenormal_eight_schools   764.8 ms  789.0 ms  +3.2%       4.35 s   4.47 s  +2.6%
  svi_autonormal_logistic                    804.3 ms  790.5 ms  -1.7%       3.92 s   3.75 s  -4.3%
  svi_multi_particle_elbo                      1.53 s    1.54 s  +0.3%       3.78 s   3.98 s  +5.4%
  svi_trace_mean_field_elbo                    1.40 s    1.35 s  -3.5%       5.73 s   5.97 s  +4.2%
Methodology and environment

Each benchmark is set up untimed, then called once with the JAX caches cleared and several more times warm. Run is the fastest warm call; compile is the first call minus that, i.e. the tracing, lowering and XLA compilation the warm calls did not have to pay for.

Both refs were measured on the same runner over 2 interleaved round(s), taking the best observation per benchmark. A result is called neutral when it moves less than ±5% (run) or ±25% (compile), or when the measurement itself is under 1 ms (run) / 50 ms (compile) — a shared CI runner cannot resolve changes below that. Compile time gets the looser band because it is measured once per round rather than best-of-N, and swings by roughly 20% even between two runs of identical code. A delta shown in parentheses did clear its threshold, but on a measurement below the resolution floor, so it is reported without being called a change.

baseline this PR
ref master SimplexToOrderedTransform-inv
commit 6e0fe1fc 8d83a11d
numpyro 0.21.0 0.21.0
jax 0.11.1 0.11.1
backend cpu cpu
python 3.14.7 3.14.7

Runner: Linux-6.17.0-1022-azure-x86_64-with-glibc2.39, 4 CPUs.

Produced by this benchmark run.

@Qazalbash Qazalbash self-assigned this Aug 25, 2026

@Qazalbash Qazalbash left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @haansn08

@Qazalbash
Qazalbash merged commit 0059d3a into pyro-ppl:master Aug 25, 2026
11 checks passed
@Qazalbash Qazalbash removed the awaiting review Awaiting review from maintainers label Aug 25, 2026
@haansn08
haansn08 deleted the SimplexToOrderedTransform-inv branch August 26, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants