Improve vector field adaptors to not require caching

Open
#1,783 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 6 days

Nobody has claimed this yet.

  • #1802 by @aniketpandey05 — closed without merging

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Quiet
Tech stack
python

Research direction

Start by reading the existing vector field adaptors and their caching behavior, then review the related proposals in #1446 and #1482. Done means the interface separates setup or fitting from score evaluation and allows wrapped estimators to perform one-time preprocessing before sampling.

Written by the indexing model from the issue text.

Description

enhancement inference score-flow-matching

Refactor vector field potential to allow estimating hyperparameters once.

By now we have quite a few methods to post-hoc adapt the score/vf to allow iid observations or in #1446 #1482 to allow post-hoc prior/likelihood modifications. All of this will wrap the original estimator, modify its output, and return a modified score.

Yet for some methods like Gauss or PriorGuide we have to do some "nontrivial" preprocessing/hyperparameter optimization before one can start to sample. This is currently made possible via caching i.e. such that only the first call is delayed.

This works, but it is brittle:

  • it hides expensive initialization behind the first evaluation,
  • it makes execution order matter in subtle ways,
  • and it couples correctness to correct cache behavior.

Additionally the sample method/params as keyword now becomes quite overloaded so it might make sense to introduce an new improved API i.e. as suggested in #1482 via posterior.with_iid("$METHOD",...).sample or posterior.with_guidance("$METHOD",...).sample

Goals

  • Design an interface that separates setup / fitting from score evaluation (i.e. a init method for the potential before sampling)
  • Allow wrapped estimators to run one-time preprocessing before sampling
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.