Skip to content

bug: transform_to_unconstrained z-scoring is a silent no-op for nflows flows #1885

Closed

Description

@janfb

Passing z_score_x="transform_to_unconstrained" (or z_score_y) to an nflows flow
builder (build_maf, build_maf_rqs, build_nsf, build_made, and the MDN path)
silently builds a flow with no reparametrization at all. There is no error and no
warning. Thus,if the user asks for an unconstrained-space transform they just gets a raw flow,
i.e. a subtly wrong posterior. Only the Zuko builders actually implement the option.

The reason is not a parser bug, but just that we forgot to cover this for nflows or
mdn: z_score_parser returns (False, False) for transform_to_unconstrained on
purpose, because the caller is expected to special-case it. The Zuko path does this
(flow.py, via biject_transform_zuko(mcmc_transform(x_dist))), but the nflows
builders never got that branch, so the flag parses to "no z-scoring" and nothing
replaces it.

Solution (short term, fail loudly):

  • raise an informative NotImplementedError for transform_to_unconstrained in the
    nflows builders, pointing users to zuko_* models or independent/structured/none
  • a warning is not enough here: training would silently proceed with wrong
    normalization, and since the current behavior is a no-op nobody can be relying on it
  • put the check in the nflows builders, not in z_score_parser (the Zuko path relies
    on the parser returning (False, False) after special-casing the flag); a small
    shared guard in sbiutils.py called at the top of each nflows builder keeps it DRY

Long term (actually implement it for nflows):

  • unlike independent/structured, this option needs the prior distribution
    (x_dist / mcmc_transform), which the nflows builders don't currently receive
  • threading that through is the same "z-scoring depends on prior bounds, not the
    batch" axis as the planned builder/z-scoring refactor, so it could be part of that
    bigger effort rather than a standalone fix

Activity

  1. added
    bug
    on Jun 18, 2026
  2. added theissue type on Jun 18, 2026
  3. janfb commented on Jun 23, 2026

    @janfb
    ContributorAuthor

    this is now partially fixed by #1886 which introduces warnings for the no-op paths.

    For the long term fix I suggest to actually not implement it for nflows (un-maintained, dead end), but only for our internal methods, e.g., for mdn and potentially for the vector field methods. For the latter we need to take into account the recent PR #1884

  4. BHARATH0153 commented on Jun 23, 2026

    @BHARATH0153
    Contributor

    @janfb working on it

  5. added a commit that references this issue on Jun 23, 2026
    16d884e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions