Reparametrisation: one contract from a positive scalar to a whole flow, stored with paramax
Design · argminax, paramax, gauss_flows, geonnax and sesmax
1 Dec 2026 · draft for review
Status: open questions decided 1 Dec 2026; GR-O1 and GR-O2 superseded the same day by gauss_flows layout; issues not yet filed
Updated 1 Dec 2026. The gauss_flows layout page puts the contract and every map on this page into
gauss-flows-maps, a Core package of gauss_flows, and leaves argminax the Laplace push-forward and sampling, which take any map through aProtocol. A gauss_flows bijection or flow is then a reparametrisation directly, so the adapter of level 3 disappears. The maths, gates and API below stand; where the page saysargminax.reparam, readgauss_flows_maps.reparam.
Repositories: argminax (the contract and the maps), paramax (storage, third-party, unchanged), gauss_flows (bijections and flows as reparametrisations), geonnax (uses the maps for its scales), sesmax (replaces its
positiveandinterval)Companion pages: gauss_flows conditioning (its scales use these maps), gauss_flows Gaussians, gauss_flows monotone maps
Related: sesmax#268 (a prior is a paramax wrapper on the leaf, decided 1 Dec 2026), pyrox#593 (NeuTra preconditioning with a flow), argminax#48 (how
Reparametrisedcomposes with paramax)
1Decision¶
Decided (1 Dec 2026, with the package from the gauss_flows layout): gauss-flows-maps owns reparametrisation, as one contract with three levels of map, and paramax stores the unconditional parameters that use it.
| Level | Map g | Owner |
|---|---|---|
| 1. Elementwise | exp, softplus, sigmoid, compositions | gauss-flows-maps (Reparametrised, from argminax) |
| 2. Structured | Cholesky factor, simplex | gauss-flows-maps |
| 3. Learned | any bijection or trained flow | gauss-flows-maps (bijections) and gauss-flows-models (flows) |
argminax’s Reparametrised already has forward, inverse, derivative, push_forward and sample. Its map moves to gauss_flows_maps.reparam and gains the log-value and log-derivative, composition, and a parameter(value) method that returns a paramax.Parameterize (paramax is a dependency of the maps package, through flowjax, so no extra is needed).
argminax keeps push_forward and sample as functions over any object with forward and inverse, typed by a Protocol, so it never imports the maps package.
sesmax’s positive and interval, gauss_flows’s positivity helpers and hand-built Cholesky factor, and FiLM’s scales all use these objects.
What does not change: paramax (a third-party library, used as is), how flowjax and sesmax unwrap their models, sesmax’s priors on the leaf (sesmax#268), and pyrox, which keeps NumPyro’s constraints.
Alternative: put the maps in each consumer and share only a convention. That is today’s state, which produced the copies listed below.
2Motivation¶
The same map is written six times. A constrained parameter x = g(u) is stored as an unconstrained u and mapped through g when used:
| Copy | Repository | What it has |
|---|---|---|
solve.Reparametrised | argminax | forward, inverse, derivative, push-forward, sample |
positive, interval | sesmax-core | a paramax.Parameterize from a value |
_softplus_plus_floor | gauss_flows | softplus + 10⁻⁴ for Parameterize |
GaussianMixture._build_L | gauss_flows | a Cholesky factor by hand |
_apply_gamma | geonnax | FiLM’s scale maps |
| part A of the gauss_flows conditioning page | geonnax (planned) | a seventh copy |
argminax already has the richest one, and already points at paramax. Reparametrised("exp" | "softplus" | "sigmoid", lower, upper) in src/argminax/_src/solve/_reparam.py gives x = a + eᵘ, x = a + softplus(u) or x = a + (b − a) σ(u), with a stable inverse, the derivative g′, the linearised push-forward of a Laplace posterior and an exact push-forward of its samples. Its docstring (argminax#48) says to store a model parameter as paramax.Parameterize(Reparametrised("softplus").forward, u), and that argminax does not depend on paramax.
sesmax repeats it with paramax built in. positive(value) and interval(value, lower, upper) in sesmax-core’s _src/types.py return a Parameterize whose raw value is the inverse of the map at value, each with its own stable inverse softplus. sesmax’s source calls positive( 51 times and interval( 25 times (counted on origin/main, tests included).
gauss_flows builds structured parameters by hand. GaussianMixture stores a log-diagonal and a strict lower triangle and assembles each component’s Cholesky factor in _build_L, and stores its weights as logits put through log_softmax. DeepSigmoidCoupling stores its positive parameters as Parameterize(_softplus_plus_floor, u). Each is a reparametrisation with no inverse, no Jacobian and no push-forward.
A trained flow is the same idea, learned. A flow T maps a latent u with a simple distribution to x. Used as g, it gives a parameter space in which a posterior is close to Gaussian, which is what NeuTra preconditioning does (pyrox#593) and what argminax’s Laplace approximation would like: fit in u, report in x by pushing samples through T, as Reparametrised.sample already does for one bound.
paramax is the storage the stack already uses. paramax 0.0.5 is small: AbstractUnwrappable, Parameterize(fn, *args, **kwargs), NonTrainable, RealToIncreasingOnInterval, WeightNormalization and unwrap, which replaces each wrapper by its value, innermost first. flowjax’s distributions unwrap themselves in log_prob and sample, flowjax’s losses unwrap the model, and sesmax’s models unwrap theirs. Any callable can be the fn of a Parameterize, so every level of map here can be stored with it.
3User stories¶
As a modeller, I want to write a positive viscosity as
Reparametrised("softplus").parameter(1e-4), so that it starts at 10⁻⁴, trains in an unconstrained variable and is the same object a retrieval uses.
As a flow author, I want a mixture’s Cholesky factors and weights to be stored through structured maps with an inverse, so that I can initialise them from a fitted covariance and weights.
As someone calibrating a model, I want to fit a Laplace posterior in u and report it in x through any reparametrisation, a bound or a trained flow, so that the posterior respects the constraint and can be non-Gaussian in x.
As the maintainer of geonnax, I want FiLM’s scales to use the same maps, so that their log-Jacobians are not derived twice.
4Background maths¶
The contract¶
A reparametrisation is a bijection g from ℝᵐ onto a constrained set 𝒳 ⊂ ℝⁿ, written x = g(u). Five operations make it useful:
forward: x = g(u);inverse: u = g⁻¹(x), for initialising u from a chosen x;log_det_jacobian: the log-volume change log |det J_g(u)|, for a density on u from a density on x, defined when m = n or on the manifold 𝒳 otherwise;push_forward: a Laplace posterior 𝒩(û, Σ_u) in u linearised into x, 𝒩(g(û), J Σ_u Jᵀ) with J = ∂g/∂u at û;sample: draws u_s ~ 𝒩(û, Σ_u) mapped to x_s = g(u_s), exact for the Gaussian in u and never outside 𝒳.
A prior on x gives a density on u through the change of variables
which a MAP or Laplace fit in u needs when the prior is stated in x. A prior stated directly on u, as sesmax’s design does for positive parameters, needs no correction.
Level 1: elementwise maps¶
For an elementwise map, J_g is diagonal, so log |det J_g(u)| = Σᵢ log g′(uᵢ), and the log-value log g(u) is what a scale’s log-Jacobian needs when g(u) multiplies something else (affine modulation, an affine coupling).
| Map | g(u) | log g′(u) | g⁻¹(x) |
|---|---|---|---|
exp | a + eᵘ | u | log(x − a) |
softplus | a + softplus(u) | −softplus(−u) | stable inverse softplus of x − a |
sigmoid | a + (b − a) σ(u) | log(b − a) − softplus(u) − softplus(−u) | logit((x − a)/(b − a)) |
Two scales the gauss_flows conditioning page needs are already in this table.
FiLM’s 1 + tanh u equals 2σ(2u), which is sigmoid on (0, 2) with u scaled by 2; the scaling changes only the gradient’s size, and both are 1 at u = 0.
A log-scale bounded by B is exp composed with sigmoid on (−B, B), so composition is all it needs.
A floor, such as gauss_flows’s softplus + 10⁻⁴, is the lower bound a.
For a composition g = g₂ ∘ g₁ of elementwise maps, log g′(u) = log g₂′(g₁(u)) + log g₁′(u), and the inverse is g₁⁻¹ ∘ g₂⁻¹.
Level 2: structured maps¶
Cholesky factor. A vector u ∈ ℝ^(D(D+1)/2) fills the lower triangle of L, with the diagonal put through a positive map h: L_ii = h(u_ii). The map from u to the free entries of L is triangular in its Jacobian, so log |det J| = Σᵢ log h′(u_ii). Σ = L Lᵀ is then a valid covariance for any u.
Simplex. A vector u ∈ ℝ^(K−1) gives K weights by the additive logistic map w = softmax([u, 0]), a bijection onto the open simplex. Its Jacobian, taken on the first K − 1 coordinates, has log |det J| = Σᵢ₌₁ᴷ log wᵢ [1].
Increasing knots. paramax’s RealToIncreasingOnInterval already maps an unconstrained vector to increasing points on an interval with a minimum width, which is how flowjax stores spline knots; it has no inverse or Jacobian, and it stays as it is.
Level 3: a bijection or a trained flow¶
A shape-preserving bijection T: ℝⁿ → ℝⁿ from gauss_flows, such as a trained flow’s bijection, is a reparametrisation with g = T: forward is T’s transform, inverse its inverse, and log_det_jacobian the log-determinant T already returns.
The linearised push-forward needs J = ∂T/∂u at û, an n × n matrix from jax.jacfwd; sampling needs only T.
Fitting a Laplace posterior in u and sampling through T gives a posterior in x that can be skewed or multimodal, which a Laplace fit in x cannot be.
5Background numerics¶
Stable forms. The log-derivatives in the table are written with softplus so that they stay finite for |u| ≤ 100 in float32. The softplus inverse is computed as y + log(−expm1(−y)) with y = x − a, which Reparametrised.inverse already does.
Storage with paramax. Reparametrised.parameter(value) returns Parameterize(self.forward, self.inverse(value)). Unwrapping calls forward on the stored u, so a gradient step moves u, and the value never leaves 𝒳. A frozen flow is stored as Parameterize(apply, u, non_trainable(T)), with apply(u, T) = T.transform(u); paramax unwraps the inner NonTrainable first, so T’s weights get no gradient (gate R-G5 checks it).
Conditioned parameters are not stored. A parameter that depends on an input, such as FiLM’s scale γ(c), is computed in __call__ by calling the map directly; paramax is only for leaves that do not depend on the input.
geonnax’s fields stay raw. pyrox-nn swaps geonnax fields such as generator.weight by name with eqx.tree_at, so geonnax never wraps its own fields in Parameterize; it applies the map inside __call__.
6What it builds on¶
| Need | Upstream name | State on main |
|---|---|---|
| Elementwise maps with inverse and push-forward | argminax.solve.Reparametrised (moving to argminax.reparam) | today (argminax v0.0.11) |
| Laplace posterior in u | argminax.solve.laplace_mode, Laplace | today (argminax v0.0.11) |
| Storage of unconditional parameters | paramax.Parameterize, NonTrainable, unwrap | today (paramax 0.0.5) |
| Increasing knots | paramax.RealToIncreasingOnInterval | today (paramax 0.0.5) |
| Bijections and flows | gauss_flows bijections, flowjax.distributions.Transformed | today (gauss_flows, flowjax) |
| Priors on the leaf | sesmax-param with_prior | proposed (sesmax#268) |
paramax is third-party (by flowjax’s author), so nothing moves into it; argminax reaches it only through the optional extra.
7Ownership¶
gauss-flows-maps(Core, tier 1) owns, ingauss_flows_maps.reparam, the contract, the elementwise and structured maps, andparameter(). Its bijections are reparametrisations of level 3 as they stand. It imports nothing from argminax, geonnax or sesmax.argminax owns the Laplace push-forward and sampling through a map, as functions over a
Protocol. It never imports gauss_flows.geonnax imports the maps for its conditioned scales and stores no field through paramax.
sesmax stores its constrained coefficients with
Reparametrised(...).parameter(value)and keeps its priors on the leaf, as sesmax#268 decided; a prior wrapper and a reparametrisation wrapper nest, and the prior is on the stored u, as sesmax’s param design already states for positive coefficients.pyrox keeps NumPyro’s constraints; a bridge from this contract to NumPyro’s transforms is pyrox’s own follow-up if it wants one.
8API proposal¶
# argminax.reparam (GR-O2; Reparametrised moves here from argminax.solve)
class AbstractReparametrisation(eqx.Module):
"""x = g(u): a bijection from ℝᵐ onto a constrained set."""
@abc.abstractmethod
def forward(self, u): ...
@abc.abstractmethod
def inverse(self, x): ...
@abc.abstractmethod
def log_det_jacobian(self, u) -> Float[Array, ""]: ...
def push_forward(self, posterior: Laplace) -> Laplace:
"""𝒩(g(û), J Σ_u Jᵀ), with J from jax.jacfwd unless a subclass has it in closed form."""
def sample(self, posterior: Laplace, n: int, *, key) -> Float[Array, "member ..."]:
"""g applied to n draws from the posterior in u."""
def parameter(self, value) -> "paramax.Parameterize":
"""Parameterize(self.forward, self.inverse(value)); needs the argminax[paramax] extra."""
class Reparametrised(AbstractReparametrisation):
"""Elementwise exp, softplus or sigmoid, as today, plus:"""
def log_value(self, u): ... # log g(u), for a scale
def log_derivative(self, u): ... # log g′(u), elementwise
class Composed(AbstractReparametrisation):
"""g₂ ∘ g₁ of elementwise maps."""
outer: Reparametrised
inner: Reparametrised
class CholeskyFactor(AbstractReparametrisation):
"""u ∈ ℝ^(D(D+1)/2) ↦ lower-triangular L with diagonal h(u_ii)."""
dim: int = eqx.field(static=True)
diagonal: Reparametrised = Reparametrised("softplus")
class Simplex(AbstractReparametrisation):
"""u ∈ ℝ^(K−1) ↦ softmax([u, 0])."""
size: int = eqx.field(static=True)# gauss_flows
class BijectionReparametrisation(argminax.reparam.AbstractReparametrisation):
"""A flowjax bijection, or a trained flow's bijection, as g."""
bijection: AbstractBijectionReparametrised keeps its constructor, its methods and its validation. derivative stays, and log_derivative is its stable logarithm.
9API usage examples¶
The running example is a positive viscosity ν in a sesmax model, a three-component mixture in gauss_flows, and a Laplace fit of ν through a trained flow. The markers name the issues under Follow-up issues.
import jax.numpy as jnp
import jax.random as jr
import paramax
from argminax.reparam import CholeskyFactor, Composed, Reparametrised, Simplex
# Shapes: D = 4 event dims; K = 3 components
# proposed (R1)
# ν = 10⁻⁶ + softplus(u), stored as u = softplus⁻¹(10⁻⁴ − 10⁻⁶)
viscosity = Reparametrised("softplus", lower=1e-6).parameter(1e-4)
# today (paramax)
# ν = 10⁻⁴ after unwrapping
# → ()
nu = paramax.unwrap(viscosity)
# proposed (R1)
# FiLM's bounded log-scale: γ = exp(u′), u′ = −3 + 6 σ(u), so |log γ| ≤ 3
bounded_scale = Composed(outer=Reparametrised("exp"),
inner=Reparametrised("sigmoid", lower=-3.0, upper=3.0))
# proposed (R2)
# L_k lower-triangular with a softplus diagonal; w = softmax([u, 0])
# (K, D(D+1)/2) → (K, D, D); (K − 1,) → (K,)
chol = CholeskyFactor(dim=4).parameter(jnp.broadcast_to(jnp.eye(4), (3, 4, 4)))
weights = Simplex(size=3).parameter(jnp.full(3, 1 / 3))import gauss_flows as gf
from argminax.solve import laplace_mode
# Shapes: P = 2 parameters
# proposed (R3)
# x = T(u) with T a trained flow's bijection, frozen
reparam = gf.BijectionReparametrisation(trained_flow.bijection)
# today* (argminax)
# û, Σ_u from a Laplace fit of the cost written in u
# → Laplace over (P,)
posterior_u = laplace_mode(cost_in_u, u0)
# proposed (R3)
# x_s = T(u_s), u_s ~ 𝒩(û, Σ_u)
# → (S, P)
samples_x = reparam.sample(posterior_u, 1000, key=jr.key(0))trained_flow, cost_in_u and u0 are the user’s; laplace_mode’s arguments are sketched (today*).
10Gates¶
| Gate | Passes when |
|---|---|
| R-G1 elementwise | inverse, log-value, log-derivative exact to 1e-10 |
| R-G2 parameter | unwrap(parameter(v)) = v; equals sesmax’s helpers |
| R-G3 structured | Jacobians match jacfwd; outputs in the set |
| R-G4 flows | adapter matches the flow; push-forward matches J Σ Jᵀ |
| R-G5 frozen flow | no gradient to the flow’s weights |
| R-G6 consumers | sesmax, gauss_flows, geonnax tests pass |
R-G1 elementwise. For exp, softplus and sigmoid, with and without bounds, and for a composition, on u over [−30, 30] in float64: inverse(forward(u)) returns u to 1e-12 relative where g′(u) > 10⁻⁸, log_value equals log g(u) to 1e-10, and log_derivative equals the log of jax.grad of forward to 1e-10. All are finite at u = ±100 in float32.
R-G2 parameter. paramax.unwrap(r.parameter(v)) equals v to 1e-12 in float64 for every map and bound, and equals sesmax-core’s positive(v) and interval(v, a, b) on their own test values.
R-G3 structured. CholeskyFactor gives a lower-triangular L with a positive diagonal for random u, and its log_det_jacobian equals log |det| of jax.jacfwd of the map from u to the free entries to 1e-10. Simplex gives weights summing to 1, and its log_det_jacobian equals log |det| of jacfwd on the first K − 1 weights to 1e-10. Both invert their forward to 1e-12.
R-G4 flows. For a gauss_flows flow with random weights, BijectionReparametrisation’s forward, inverse and log_det_jacobian equal the bijection’s own to 1e-6 in float32; push_forward gives J Σ_u Jᵀ with J from jax.jacfwd to 1e-6; and the mean of 10⁵ sample draws is within 3 standard errors of the mean of T(u_s) computed directly.
R-G5 frozen flow. With a flow stored as Parameterize(apply, u, paramax.non_trainable(T)), the gradient of a loss after paramax.unwrap is zero for every weight of T and non-zero for u, under jit and through eqx.partition.
R-G6 consumers. sesmax’s tests pass with positive and interval replaced; gauss_flows’s mixture and deep-sigmoid tests pass with their tolerances unchanged; geonnax’s conditioning tests pass with FiLM’s scales from argminax.
11Risks¶
geonnax gains a heavier dependency. argminax brings gaussx, lineax and optimistix (gaussx brings matfree); GR-O1 accepted this. Most of geonnax’s consumers already have them. The edge points down (Core sits below GeoML), but geonnax’s
tests/test_dependency_rules.pywas generated before the Core layer and names neither argminax nor functax, so the gauss_flows conditioning page’s B2 regenerates it with geostack’sscripts/dependency_graph.py --guard geonnax.paramax is third-party. Its API is small and stable in use, but it is not ours. Mitigation: argminax reaches it only through
parameter()behind an extra, and every consumer pins it.A frozen flow inside
Parameterizemay not freeze. Ifnon_trainabledoes not stop gradients through a bound method, the flow trains with the model. Fallback: theapply(u, T)form above, which gate R-G5 checks.Moving
Reparametrisedbreaks its importers.argminax.solve.Reparametrisedleaves forargminax.reparam(GR-O2) with no deprecation window. Mitigation: R1 lists every importer onorigin/mainacross the stack in its PR body and the consumers follow when they bump.
12Follow-up issues¶
Filed on 1 Dec 2026: the draft IDs below map to issue numbers in the Filed issues table of the gauss_flows layout page.
Each issue is written to be self-contained when filed. They follow the repositories of the gauss_flows layout, whose L-numbers they share, and its epic.
| ID | Repo | Title |
|---|---|---|
| R1 | gauss_flows (maps) | the gauss_flows layout page’s L4: feat(maps): reparametrisations: Reparametrised, Composed, CholeskyFactor, Simplex and parameter() |
| R2 | argminax | the gauss_flows layout page’s L6: refactor!: Reparametrised leaves for gauss-flows-maps; push_forward and sample take a Protocol |
| R3 | gauss_flows (models) | distributions: GaussianMixture's Cholesky factors and weights, and DeepSigmoidCoupling's parameters, through the maps package |
| R4 | sesmax | the gauss_flows layout page’s L8: refactor(sesmax-core): positive and interval from gauss-flows-maps |
The first draft’s adapter BijectionReparametrisation is gone: a bijection in the maps package already has forward, inverse and a log-determinant, which is all argminax’s Protocol asks for.
Order. R1 follows the gauss_flows layout page’s L2 (the workspace). R2, R3 and R4 follow R1.
Existing issues. pyrox#593 (NeuTra) can use any flow as a reparametrisation directly. sesmax#268 stays as decided; R4 changes how the constrained value is stored, not where the prior lives.
13Open questions¶
All three questions were decided on 1 Dec 2026, as recommended, and the page follows them.
GR-O1. Does geonnax depend on argminax? Decided yes, then superseded the same day by the gauss_flows layout: geonnax depends on
gauss-flows-mapsinstead. The original answer: so that FiLM’s scales are argminax’s maps and their log-Jacobians are written once; most geonnax consumers already have argminax’s dependencies.GR-O2. Does reparametrisation get its own argminax module? Decided yes, then superseded the same day: the maps live in
gauss_flows_maps.reparam. The original answer:argminax.reparam, since sesmax, gauss_flows and geonnax use it without solving anything;Reparametrisedleavesargminax.solvewith no deprecation window.GR-O3. Where does the epic live? Decided argminax, then superseded the same day: the work is filed under the gauss_flows layout’s issues. The original answer: argminax, which owns the concept, with the gauss_flows, sesmax and geonnax issues as cross-repo sub-issues.
14References¶
Aitchison, J. (1986). The Statistical Analysis of Compositional Data. Chapman and Hall.
Hoffman, M., Sountsov, P., Dillon, J. V., Langmore, I., Tran, D. and Vasudevan, S. (2019). NeuTra-lizing bad geometry in Hamiltonian Monte Carlo using neural transport. arXiv:1903.03704.