TARP reference sampling fails when a parameter coordinate is fixed

Open Beginner friendly
#2,264 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 6 days

@Jayant-kernel is already working on this.

Since Dec 2, 2026.

  • #2285 by @Jayant-kernel — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
77/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, pytorch

Research direction

Start with get_tarp_references in sbi/diagnostics/tarp.py and trace how it builds bounds and samples references. Reproduce the provided example, then check that zero-width coordinates use their observed value while varying coordinates are sampled as before. Done when the example runs and coverage matches the one-dimensional calculation, with and without normalization.

Written by the indexing model from the issue text.

Description

TARP's default reference sampler fails if one parameter stays fixed across the ground truths and posterior draws, even when other parameters vary. For example, augmenting a one-dimensional parameter with a known calibration constant should leave Euclidean distances unchanged.

import torch
from sbi.diagnostics.tarp import get_tarp_references

theta = torch.tensor([[0., 7.], [1., 7.], [2., 7.]])
samples = torch.stack([theta + torch.tensor([v, 0.]) for v in (-0.25, 0.25)])
get_tarp_references(theta, samples)

At 1c3d53d7 the bounds for the second coordinate are [7, 7]. PyTorch Uniform requires strictly ordered bounds and raises ValueError. I reproduced the exception on CPU with the checkout's reference sampling routines. As a control I sampled references in the varying coordinate and appended 7 manually. The original coverage calculation then agreed with the one-dimensional calculation using the same rank jitter, both with and without normalization. No posterior training was involved.

Sampling the varying coordinates uniformly and setting every zero-width coordinate to its observed value would keep the reference distribution on the observed box without introducing arbitrary noise into a fixed parameter.

Dominant language
Python
Stars
894
Forks
306
Avg merge
5d 21h
Merged PRs (30d)
61

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sbi-dev/sbi

All issues in sbi-dev/sbi

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.