omnibias.core.verified.jet_mv
Coefficient recurrences, activation contracts, jet algebra, and verified arithmetic shared by the numerical backends.
import omnibias.core.verified.jet_mvModule contract & mathematical conventions
Verified (interval) *multivariate* jets -- the certified twin of jet_mv.
This is the rigorous counterpart of the float multi-index kernels in
omnibias.torch.jet_mv / omnibias.jax.jet_mv. Where the float
kernel returns, for a *point* x0, every mixed Taylor coefficient
c_alpha = D^alpha u(x0) / alpha! in one forward pass, this module returns a
guaranteed ~omnibias.core.verified.interval.Interval **enclosure** of
those coefficients that is valid for *every* point of an input **box**.
Why this is sound
The float mlp_jet_mv computes {D^alpha u(x0)/alpha!} exactly via a fixed
sequence of operations (identity jet -> affine -> activation tower -> truncated
Cauchy product). Replaying the *same* sequence in interval arithmetic, with the
constant row of the input jet seeded as the whole box, makes every intermediate
an inclusion-isotonic interval extension of the corresponding real computation:
- the unit-multi-index rows of
identity_jetare the *exact* basis vectors (d x_i / d delta_j = delta_ijindependent ofx0); ~omnibias.core.verified.sigma.sigma_tower_intervalis inclusion isotonic in its argument, so the activation tower expanded about the (interval) pre-activation encloses the tower at every concretex0in the box;- interval
+/*are inclusion isotonic.
By induction, for every x0 in the box and every |alpha| <= order the real
coefficient D^alpha u(x0)/alpha! lies in jet[alpha]. Truncating the
Cauchy product at total order order is exact for the kept coefficients (the
pre-activation perturbation has a zero constant row, so each extra product raises
the minimum order), so dropping higher terms never loosens a kept coefficient.
The enclosures inherit interval *dependency* overestimation, which grows with box
width and network depth; certified_partials_subdivided (and the
splits argument of certified_residual_bound) tighten it soundly by
splitting the box and taking the hull -- the union of the per-sub-box ranges is
itself a rigorous enclosure of the whole-box range of each derivative.
Supported activations are exactly those of the verified tower:
"tanh", "sigmoid", "gaussian", the trigonometric pair "sin" /
"cos" (which admits closed-form Fourier-mode / plane-wave fields), and the
smooth closed-form neural activations "silu", "gelu" (exact) and
"softplus".
Conventions (identical to the float kernels)
- A *jet* is
list[list[Interval]]of shape(M, C)withM = num_multi_indices(dim, order)rows (canonical~omnibias.core.multi_index.multi_indicesorder) andCoutput components. RowiholdsD^alpha u(x0)/alpha!for thei-th multi-index. - A *layer* is
(W, b, name)withWshape(C_out, C_in),bshape(C_out,)orNone, andnameone of the supported activations (orNonefor a pure affine readout).
Shared formulas do not imply universal floating-point identity. Verify dtype, shape, derivative-order support, and the stated numerical assumptions for the path you use.
BoxLike
omnibias.core.verified.jet_mv.BoxLikeSource ↗BoxLike = Sequence['Interval | tuple[float, float] | float']A per-axis box: one Interval (or (lo, hi) / point) per input dimension.
Read the implementation
BoxLike = Sequence["Interval | tuple[float, float] | float"]Layer
omnibias.core.verified.jet_mv.LayerSource ↗Layer = tuple[Sequence[Sequence[IntervalLike]], Sequence[IntervalLike] | None, str | None](weight, bias, activation-name-or-None) describing one MLP layer.
Read the implementation
Layer = tuple[
Sequence[Sequence[IntervalLike]], Sequence[IntervalLike] | None, str | None
]MVJet
omnibias.core.verified.MVJetSource ↗MVJet = list[list[Interval]]A multivariate interval jet: (M, C) interval coefficients (row-major over
the canonical multi-index ordering).
Read the implementation
MVJet = list[list[Interval]]Other public import paths
omnibias.core.verified.MVJetomnibias.core.verified.jet_mv.MVJet
certified_partials
omnibias.core.verified.certified_partialsSource ↗certified_partials(box: BoxLike, layers: Sequence[Layer], order: int) -> dict[MultiIndex, list[Interval]]All certified partial-derivative enclosures {alpha: D^alpha u} over the box.
Parameters
| Name | Type & default | Contract |
|---|---|---|
boxpositional-or-keyword | BoxLikeRequired | See the operation contract and implementation below. |
layerspositional-or-keyword | Sequence[Layer]Required | See the operation contract and implementation below. |
orderpositional-or-keyword | intRequired | See the operation contract and implementation below. |
dict[MultiIndex, list[Interval]]Executed regression · screened poisson sign
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_screened_poisson_sign() -> None:
pde = screened_poisson(2, 2.0, 0.0) # lap u - 4 u = -4 u for affine
x, y = 0.5, 0.5
r = certified_interior_residual(_AFFINE, [(x, x), (y, y)], pde)
assert r.lo <= -4.0 * _u_affine(x, y) <= r.hipython -m pytest "packages/omnibias-core/tests/test_verified_pde_certificate.py::test_screened_poisson_sign" -qRegression example · wide box contains interior samples
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_wide_box_contains_interior_samples(name: str) -> None:
w, b = [0.9, -0.6], 0.1
order = 3
box = [(0.1, 0.5), (-0.7, -0.2)]
part = certified_partials(box, _single_layer(w, b, name), order)
for sx in (0.1, 0.25, 0.4, 0.5):
for sy in (-0.7, -0.5, -0.3, -0.2):
for alpha in multi_indices(2, order):
val = _analytic_partial(w, b, name, [sx, sy], alpha)
assert _contains(part[alpha][0], val), (name, alpha, sx, sy)python -m pytest packages/omnibias-core/tests/test_verified_jet_mv.py -k test_wide_box_contains_interior_samples -qRead the implementation
def certified_partials(
box: BoxLike, layers: Sequence[Layer], order: int
) -> dict[MultiIndex, list[Interval]]:
"""All certified partial-derivative enclosures ``{alpha: D^alpha u}`` over the box."""
x0 = _as_interval_box(box)
dim = len(x0)
return jet_partials(mlp_jet_mv(box, layers, order), dim, order)Other public import paths
omnibias.core.verified.certified_partialsomnibias.core.verified.jet_mv.certified_partials
certified_partials_subdivided
omnibias.core.verified.certified_partials_subdividedSource ↗certified_partials_subdivided(box: BoxLike, layers: Sequence[Layer], order: int, splits: int | Sequence[int]=1) -> dict[MultiIndex, list[Interval]]Tightened certified partials: hull of per-sub-box enclosures over a grid.
Splitting the box into splits equal pieces per axis and taking the hull of
each derivative enclosure is sound (the union of the per-sub-box ranges
encloses the whole-box range) and reduces interval dependency overestimation.
Parameters
| Name | Type & default | Contract |
|---|---|---|
boxpositional-or-keyword | BoxLikeRequired | See the operation contract and implementation below. |
layerspositional-or-keyword | Sequence[Layer]Required | See the operation contract and implementation below. |
orderpositional-or-keyword | intRequired | See the operation contract and implementation below. |
splitspositional-or-keyword | int | Sequence[int]Default: 1 | See the operation contract and implementation below. |
dict[MultiIndex, list[Interval]]Executed regression · subdivision is strictly tighter somewhere
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_subdivision_is_strictly_tighter_somewhere() -> None:
w, b, name = [1.5, -1.2], 0.3, "tanh"
order = 2
box = [(-0.8, 0.8), (-0.8, 0.8)]
coarse = certified_partials_subdivided(box, _single_layer(w, b, name), order, 1)
fine = certified_partials_subdivided(box, _single_layer(w, b, name), order, 6)
# at least one derivative enclosure should tighten noticeably
assert any(
fine[a][0].width < 0.9 * coarse[a][0].width for a in multi_indices(2, order)
)python -m pytest "packages/omnibias-core/tests/test_verified_jet_mv.py::test_subdivision_is_strictly_tighter_somewhere" -qRegression example · subdivision shrinks and stays sound
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_subdivision_shrinks_and_stays_sound() -> None:
w, b, name = [1.1, -0.8], 0.0, "tanh"
order = 3
box = [(-0.5, 0.6), (-0.4, 0.5)]
coarse = certified_partials_subdivided(box, _single_layer(w, b, name), order, 1)
fine = certified_partials_subdivided(box, _single_layer(w, b, name), order, 4)
for alpha in multi_indices(2, order):
assert fine[alpha][0].width <= coarse[alpha][0].width + 1e-12
# still sound after subdivision
for sx in (-0.5, 0.0, 0.6):
for sy in (-0.4, 0.1, 0.5):
for alpha in multi_indices(2, order):
val = _analytic_partial(w, b, name, [sx, sy], alpha)
assert _contains(fine[alpha][0], val)python -m pytest packages/omnibias-core/tests/test_verified_jet_mv.py -k test_subdivision_shrinks_and_stays_sound -qRead the implementation
def certified_partials_subdivided(
box: BoxLike,
layers: Sequence[Layer],
order: int,
splits: int | Sequence[int] = 1,
) -> dict[MultiIndex, list[Interval]]:
"""Tightened certified partials: hull of per-sub-box enclosures over a grid.
Splitting the box into ``splits`` equal pieces per axis and taking the hull of
each derivative enclosure is sound (the union of the per-sub-box ranges
encloses the whole-box range) and reduces interval dependency overestimation.
"""
x0 = _as_interval_box(box)
dim = len(x0)
per_axis = _normalize_splits(splits, dim)
boxes = _subboxes(x0, per_axis)
accum: dict[MultiIndex, list[Interval]] | None = None
for sub in boxes:
part = certified_partials(sub, layers, order)
if accum is None:
accum = {a: list(v) for a, v in part.items()}
else:
for a, v in part.items():
accum[a] = [hull([accum[a][c], v[c]]) for c in range(len(v))]
assert accum is not None # at least one sub-box always exists
return accumOther public import paths
omnibias.core.verified.certified_partials_subdividedomnibias.core.verified.jet_mv.certified_partials_subdivided
certified_residual_bound
omnibias.core.verified.certified_residual_boundSource ↗certified_residual_bound(box: BoxLike, layers: Sequence[Layer], order: int, residual: Callable[[dict[MultiIndex, list[Interval]]], Interval], splits: int | Sequence[int]=1) -> IntervalRigorous enclosure of a PDE residual over the box (sup-norm via .mag).
residual maps a partial-derivative dictionary (as produced by
certified_partials) to a scalar Interval -- e.g. for the
Laplace equation lambda P: P[(2, 0)][0] + P[(0, 2)][0]. The returned
interval encloses { residual(x) : x in box }; a certified sup-norm bound on
the residual is certified_residual_bound(...).mag. Increasing splits
tightens the enclosure (hull over the sub-box grid) and is the standard way to
drive the certified residual below a target before invoking the
Newton-Kantorovich / radii-polynomial closure.
Parameters
| Name | Type & default | Contract |
|---|---|---|
boxpositional-or-keyword | BoxLikeRequired | See the operation contract and implementation below. |
layerspositional-or-keyword | Sequence[Layer]Required | See the operation contract and implementation below. |
orderpositional-or-keyword | intRequired | See the operation contract and implementation below. |
residualpositional-or-keyword | Callable[[dict[MultiIndex, list[Interval]]], Interval]Required | See the operation contract and implementation below. |
splitspositional-or-keyword | int | Sequence[int]Default: 1 | See the operation contract and implementation below. |
IntervalExecuted regression · certified residual bound brackets laplacian
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_certified_residual_bound_brackets_laplacian() -> None:
w, b, name = [0.8, -0.5], 0.0, "gaussian"
order = 2
box = [(-0.4, 0.4), (-0.3, 0.3)]
def laplacian(part):
return part[(2, 0)][0] + part[(0, 2)][0]
coarse = certified_residual_bound(box, _single_layer(w, b, name), order, laplacian, 1)
fine = certified_residual_bound(box, _single_layer(w, b, name), order, laplacian, 5)
assert fine.width <= coarse.width + 1e-12
# contains analytic Laplacian samples = g''(a)*|w|^2
for sx in (-0.4, 0.0, 0.4):
for sy in (-0.3, 0.0, 0.3):
lap = _analytic_partial(w, b, name, [sx, sy], (2, 0)) + _analytic_partial(
w, b, name, [sx, sy], (0, 2)
)
assert fine.lo - 1e-9 <= lap <= fine.hi + 1e-9python -m pytest "packages/omnibias-core/tests/test_verified_jet_mv.py::test_certified_residual_bound_brackets_laplacian" -qRegression example · subdivision is strictly tighter somewhere
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_subdivision_is_strictly_tighter_somewhere() -> None:
w, b, name = [1.5, -1.2], 0.3, "tanh"
order = 2
box = [(-0.8, 0.8), (-0.8, 0.8)]
coarse = certified_partials_subdivided(box, _single_layer(w, b, name), order, 1)
fine = certified_partials_subdivided(box, _single_layer(w, b, name), order, 6)
# at least one derivative enclosure should tighten noticeably
assert any(
fine[a][0].width < 0.9 * coarse[a][0].width for a in multi_indices(2, order)
)python -m pytest packages/omnibias-core/tests/test_verified_jet_mv.py -k test_subdivision_is_strictly_tighter_somewhere -qRead the implementation
def certified_residual_bound(
box: BoxLike,
layers: Sequence[Layer],
order: int,
residual: Callable[[dict[MultiIndex, list[Interval]]], Interval],
splits: int | Sequence[int] = 1,
) -> Interval:
r"""Rigorous enclosure of a PDE residual over the box (sup-norm via ``.mag``).
``residual`` maps a partial-derivative dictionary (as produced by
:func:`certified_partials`) to a scalar :class:`Interval` -- e.g. for the
Laplace equation ``lambda P: P[(2, 0)][0] + P[(0, 2)][0]``. The returned
interval encloses ``{ residual(x) : x in box }``; a certified sup-norm bound on
the residual is ``certified_residual_bound(...).mag``. Increasing ``splits``
tightens the enclosure (hull over the sub-box grid) and is the standard way to
drive the certified residual below a target before invoking the
Newton-Kantorovich / radii-polynomial closure.
"""
x0 = _as_interval_box(box)
dim = len(x0)
per_axis = _normalize_splits(splits, dim)
boxes = _subboxes(x0, per_axis)
pieces: list[Interval] = []
for sub in boxes:
pieces.append(residual(certified_partials(sub, layers, order)))
return hull(list(pieces))Other public import paths
omnibias.core.verified.certified_residual_boundomnibias.core.verified.jet_mv.certified_residual_bound
compose_jet_mv
omnibias.core.verified.compose_jet_mvSource ↗compose_jet_mv(u_jet: Sequence[Sequence[Interval]], sigma_tower: Sequence[Sequence[Interval]], dim: int, order: int) -> MVJetCompose an elementwise activation onto a multivariate jet: b = sigma(u).
u_jet has shape (M, C); sigma_tower has shape (order + 1, C)
with sigma_tower[k][c] enclosing sigma^(k)(u_jet[0][c]). Returns the
jet of sigma(u) with shape (M, C).
Parameters
| Name | Type & default | Contract |
|---|---|---|
u_jetpositional-or-keyword | Sequence[Sequence[Interval]]Required | See the operation contract and implementation below. |
sigma_towerpositional-or-keyword | Sequence[Sequence[Interval]]Required | See the operation contract and implementation below. |
dimpositional-or-keyword | intRequired | See the operation contract and implementation below. |
orderpositional-or-keyword | intRequired | See the operation contract and implementation below. |
MVJetExplicit validation & failure cases
- When
len(u_jet) != m, raisesValueError(f'u_jet has {len(u_jet)} rows but dim={dim}, order={order} requires {m}'). - When
len(sigma_tower) != order + 1, raisesValueError(f'sigma_tower order {len(sigma_tower) - 1} must equal jet order {order}').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Executed regression · compose jet mv matches layer path
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_compose_jet_mv_matches_layer_path() -> None:
from omnibias.core.verified.jet import affine_jet
from omnibias.core.verified.sigma import sigma_tower_interval
w, b, name = [0.7, -0.3], 0.2, "sigmoid"
order = 3
box = [(0.0, 0.4), (-0.5, 0.1)]
jet0 = identity_jet(box, order)
u_jet = affine_jet(jet0, [list(w)], [b])
tower = [
[sigma_tower_interval(name, u_jet[0][0], order)[k]] for k in range(order + 1)
]
composed = compose_jet_mv(u_jet, tower, 2, order)
layer = layer_jet_mv(jet0, [list(w)], [b], name, 2, order)
for g in range(len(composed)):
assert composed[g][0].lo == layer[g][0].lo
assert composed[g][0].hi == layer[g][0].hipython -m pytest "packages/omnibias-core/tests/test_verified_jet_mv.py::test_compose_jet_mv_matches_layer_path" -qRead the implementation
def compose_jet_mv(
u_jet: Sequence[Sequence[Interval]],
sigma_tower: Sequence[Sequence[Interval]],
dim: int,
order: int,
) -> MVJet:
"""Compose an elementwise activation onto a multivariate jet: ``b = sigma(u)``.
``u_jet`` has shape ``(M, C)``; ``sigma_tower`` has shape ``(order + 1, C)``
with ``sigma_tower[k][c]`` enclosing ``sigma^(k)(u_jet[0][c])``. Returns the
jet of ``sigma(u)`` with shape ``(M, C)``.
"""
m = num_multi_indices(dim, order)
if len(u_jet) != m:
raise ValueError(
f"u_jet has {len(u_jet)} rows but dim={dim}, order={order} requires {m}"
)
if len(sigma_tower) != order + 1:
raise ValueError(
f"sigma_tower order {len(sigma_tower) - 1} must equal jet order {order}"
)
width = len(u_jet[0])
out: MVJet = [[_zero() for _ in range(width)] for _ in range(m)]
for c in range(width):
u_col = [u_jet[g][c] for g in range(m)]
tower = [sigma_tower[k][c] for k in range(order + 1)]
composed = _compose_scalar_mv(u_col, tower, dim, order)
for g in range(m):
out[g][c] = composed[g]
return outOther public import paths
omnibias.core.verified.compose_jet_mvomnibias.core.verified.jet_mv.compose_jet_mv
identity_jet
omnibias.core.verified.identity_jetSource ↗identity_jet(box: BoxLike, order: int) -> MVJetMultivariate jet of the identity map x(delta) = x0 + delta over a box.
Returns shape (M, D): row 0 holds the per-axis box intervals and each
unit-multi-index row e_i is the exact basis vector e_i; all other rows
are zero. Seeding row 0 with the whole box is what makes the propagated jet a
valid enclosure for every point of the box (see the module docstring).
Parameters
| Name | Type & default | Contract |
|---|---|---|
boxpositional-or-keyword | BoxLikeRequired | See the operation contract and implementation below. |
orderpositional-or-keyword | intRequired | See the operation contract and implementation below. |
MVJetExplicit validation & failure cases
- When
order < 0, raisesValueError(f'order must be >= 0, got {order}'). - When
dim < 1, raisesValueError('box must have at least one axis').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Executed regression · screened poisson sign
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_screened_poisson_sign() -> None:
pde = screened_poisson(2, 2.0, 0.0) # lap u - 4 u = -4 u for affine
x, y = 0.5, 0.5
r = certified_interior_residual(_AFFINE, [(x, x), (y, y)], pde)
assert r.lo <= -4.0 * _u_affine(x, y) <= r.hipython -m pytest "packages/omnibias-core/tests/test_verified_pde_certificate.py::test_screened_poisson_sign" -qRegression example · identity jet structure
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_identity_jet_structure() -> None:
box = [Interval(0.0, 1.0), Interval(-1.0, 2.0)]
jet = identity_jet(box, 2)
idx = multi_indices(2, 2)
pos = {a: i for i, a in enumerate(idx)}
assert jet[pos[(0, 0)]][0].lo == 0.0 and jet[pos[(0, 0)]][0].hi == 1.0
assert jet[pos[(0, 0)]][1].lo == -1.0 and jet[pos[(0, 0)]][1].hi == 2.0
assert jet[pos[(1, 0)]][0].lo == 1.0 and jet[pos[(1, 0)]][0].hi == 1.0
assert jet[pos[(1, 0)]][1].lo == 0.0 # cross entry zero
assert jet[pos[(0, 1)]][1].lo == 1.0 and jet[pos[(0, 1)]][1].hi == 1.0
assert jet[pos[(2, 0)]][0].lo == 0.0 and jet[pos[(2, 0)]][0].hi == 0.0python -m pytest packages/omnibias-core/tests/test_verified_jet_mv.py -k test_identity_jet_structure -qRead the implementation
def identity_jet(box: BoxLike, order: int) -> MVJet:
"""Multivariate jet of the identity map ``x(delta) = x0 + delta`` over a box.
Returns shape ``(M, D)``: row 0 holds the per-axis box intervals and each
unit-multi-index row ``e_i`` is the exact basis vector ``e_i``; all other rows
are zero. Seeding row 0 with the whole box is what makes the propagated jet a
valid enclosure for every point of the box (see the module docstring).
"""
if order < 0:
raise ValueError(f"order must be >= 0, got {order}")
x0 = _as_interval_box(box)
dim = len(x0)
if dim < 1:
raise ValueError("box must have at least one axis")
pos = index_position(dim, order)
m = num_multi_indices(dim, order)
rows: MVJet = [[_zero() for _ in range(dim)] for _ in range(m)]
zero_idx = (0,) * dim
for i in range(dim):
rows[pos[zero_idx]][i] = x0[i]
if order >= 1:
for i in range(dim):
e = tuple(1 if j == i else 0 for j in range(dim))
rows[pos[e]][i] = Interval.point(1.0)
return rowsOther public import paths
omnibias.core.verified.identity_jetomnibias.core.verified.jet_mv.identity_jet
jet_gradient
omnibias.core.verified.jet_gradientSource ↗jet_gradient(jet: Sequence[Sequence[Interval]], dim: int, order: int) -> list[list[Interval]]Gradient enclosure d u / d x_i, shape (D, C). Needs order >= 1.
Parameters
| Name | Type & default | Contract |
|---|---|---|
jetpositional-or-keyword | Sequence[Sequence[Interval]]Required | See the operation contract and implementation below. |
dimpositional-or-keyword | intRequired | See the operation contract and implementation below. |
orderpositional-or-keyword | intRequired | See the operation contract and implementation below. |
list[list[Interval]]Explicit validation & failure cases
- When
order < 1, raisesValueError(f'gradient needs order >= 1, got {order}').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Executed regression · error handling
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_error_handling() -> None:
box = [(0.0, 1.0), (0.0, 1.0)]
with pytest.raises(ValueError):
identity_jet(box, -1)
jet0 = mlp_jet_mv(box, _single_layer([0.5, 0.5], 0.0, "tanh"), 0)
with pytest.raises(ValueError):
jet_gradient(jet0, 2, 0)
jet1 = mlp_jet_mv(box, _single_layer([0.5, 0.5], 0.0, "tanh"), 1)
with pytest.raises(ValueError):
jet_hessian(jet1, 2, 1)
with pytest.raises(ValueError):
jet_laplacian(jet1, 2, 1)
with pytest.raises(ValueError):
mlp_jet_mv(box, [([[0.5, 0.5]], [0.0], "relu")], 2)
with pytest.raises(ValueError):
jet_multiply(jet1, jet0, 2, 1) # row mismatch
with pytest.raises(ValueError):
certified_partials_subdivided(box, _single_layer([0.5, 0.5], 0.0, "tanh"), 1, 0)
with pytest.raises(ValueError):
certified_partials_subdivided(
box, _single_layer([0.5, 0.5], 0.0, "tanh"), 1, [2]
)python -m pytest "packages/omnibias-core/tests/test_verified_jet_mv.py::test_error_handling" -qRegression example · gradient hessian laplacian readouts
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_gradient_hessian_laplacian_readouts() -> None:
w, b, name = [0.6, -0.5, 0.3], 0.1, "tanh"
order = 2
box = [(0.1, 0.2), (-0.3, -0.2), (0.0, 0.1)]
jet = mlp_jet_mv(box, _single_layer(w, b, name), order)
part = jet_partials(jet, 3, order)
grad = jet_gradient(jet, 3, order)
hess = jet_hessian(jet, 3, order)
lap = jet_laplacian(jet, 3, order)
for i in range(3):
e = tuple(1 if j == i else 0 for j in range(3))
assert grad[i][0].lo == part[e][0].lo and grad[i][0].hi == part[e][0].hi
lap_from_part = Interval.point(0.0)
for i in range(3):
a = tuple(2 if j == i else 0 for j in range(3))
assert (
hess[i][i][0].lo == part[a][0].lo and hess[i][i][0].hi == part[a][0].hi
)
lap_from_part = lap_from_part + part[a][0]
assert lap[0].lo == lap_from_part.lo and lap[0].hi == lap_from_part.hi
# Hessian symmetry of the enclosures.
for i in range(3):
for j in range(3):
assert hess[i][j][0].lo == hess[j][i][0].lopython -m pytest packages/omnibias-core/tests/test_verified_jet_mv.py -k test_gradient_hessian_laplacian_readouts -qRead the implementation
def jet_gradient(
jet: Sequence[Sequence[Interval]], dim: int, order: int
) -> list[list[Interval]]:
"""Gradient enclosure ``d u / d x_i``, shape ``(D, C)``. Needs ``order >= 1``."""
if order < 1:
raise ValueError(f"gradient needs order >= 1, got {order}")
pos = index_position(dim, order)
rows: list[list[Interval]] = []
for i in range(dim):
e = tuple(1 if j == i else 0 for j in range(dim))
rows.append(list(jet[pos[e]])) # alpha! = 1 for a unit multi-index
return rowsOther public import paths
omnibias.core.verified.jet_gradientomnibias.core.verified.jet_mv.jet_gradient
jet_hessian
omnibias.core.verified.jet_hessianSource ↗jet_hessian(jet: Sequence[Sequence[Interval]], dim: int, order: int) -> list[list[list[Interval]]]Hessian enclosure d^2 u / d x_i d x_j, shape (D, D, C). Needs order >= 2.
Parameters
| Name | Type & default | Contract |
|---|---|---|
jetpositional-or-keyword | Sequence[Sequence[Interval]]Required | See the operation contract and implementation below. |
dimpositional-or-keyword | intRequired | See the operation contract and implementation below. |
orderpositional-or-keyword | intRequired | See the operation contract and implementation below. |
list[list[list[Interval]]]Explicit validation & failure cases
- When
order < 2, raisesValueError(f'hessian needs order >= 2, got {order}').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Executed regression · error handling
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_error_handling() -> None:
box = [(0.0, 1.0), (0.0, 1.0)]
with pytest.raises(ValueError):
identity_jet(box, -1)
jet0 = mlp_jet_mv(box, _single_layer([0.5, 0.5], 0.0, "tanh"), 0)
with pytest.raises(ValueError):
jet_gradient(jet0, 2, 0)
jet1 = mlp_jet_mv(box, _single_layer([0.5, 0.5], 0.0, "tanh"), 1)
with pytest.raises(ValueError):
jet_hessian(jet1, 2, 1)
with pytest.raises(ValueError):
jet_laplacian(jet1, 2, 1)
with pytest.raises(ValueError):
mlp_jet_mv(box, [([[0.5, 0.5]], [0.0], "relu")], 2)
with pytest.raises(ValueError):
jet_multiply(jet1, jet0, 2, 1) # row mismatch
with pytest.raises(ValueError):
certified_partials_subdivided(box, _single_layer([0.5, 0.5], 0.0, "tanh"), 1, 0)
with pytest.raises(ValueError):
certified_partials_subdivided(
box, _single_layer([0.5, 0.5], 0.0, "tanh"), 1, [2]
)python -m pytest "packages/omnibias-core/tests/test_verified_jet_mv.py::test_error_handling" -qRegression example · gradient hessian laplacian readouts
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_gradient_hessian_laplacian_readouts() -> None:
w, b, name = [0.6, -0.5, 0.3], 0.1, "tanh"
order = 2
box = [(0.1, 0.2), (-0.3, -0.2), (0.0, 0.1)]
jet = mlp_jet_mv(box, _single_layer(w, b, name), order)
part = jet_partials(jet, 3, order)
grad = jet_gradient(jet, 3, order)
hess = jet_hessian(jet, 3, order)
lap = jet_laplacian(jet, 3, order)
for i in range(3):
e = tuple(1 if j == i else 0 for j in range(3))
assert grad[i][0].lo == part[e][0].lo and grad[i][0].hi == part[e][0].hi
lap_from_part = Interval.point(0.0)
for i in range(3):
a = tuple(2 if j == i else 0 for j in range(3))
assert (
hess[i][i][0].lo == part[a][0].lo and hess[i][i][0].hi == part[a][0].hi
)
lap_from_part = lap_from_part + part[a][0]
assert lap[0].lo == lap_from_part.lo and lap[0].hi == lap_from_part.hi
# Hessian symmetry of the enclosures.
for i in range(3):
for j in range(3):
assert hess[i][j][0].lo == hess[j][i][0].lopython -m pytest packages/omnibias-core/tests/test_verified_jet_mv.py -k test_gradient_hessian_laplacian_readouts -qRead the implementation
def jet_hessian(
jet: Sequence[Sequence[Interval]], dim: int, order: int
) -> list[list[list[Interval]]]:
"""Hessian enclosure ``d^2 u / d x_i d x_j``, shape ``(D, D, C)``. Needs ``order >= 2``."""
if order < 2:
raise ValueError(f"hessian needs order >= 2, got {order}")
pos = index_position(dim, order)
out: list[list[list[Interval]]] = []
for i in range(dim):
row: list[list[Interval]] = []
for j in range(dim):
alpha = tuple(
(1 if k == i else 0) + (1 if k == j else 0) for k in range(dim)
)
f = multi_index_factorial(alpha)
if f == 1: # off-diagonal mixed partial: alpha! = 1, keep it tight
row.append(list(jet[pos[alpha]]))
else:
fact = Interval.from_rational(f)
row.append([c * fact for c in jet[pos[alpha]]])
out.append(row)
return outOther public import paths
omnibias.core.verified.jet_hessianomnibias.core.verified.jet_mv.jet_hessian
jet_laplacian
omnibias.core.verified.jet_laplacianSource ↗jet_laplacian(jet: Sequence[Sequence[Interval]], dim: int, order: int) -> list[Interval]Laplacian enclosure sum_i d^2 u / d x_i^2, shape (C,). Needs order >= 2.
Reads the pure second-order rows directly: D^{2 e_i} u = 2! * c_{2 e_i}.
Parameters
| Name | Type & default | Contract |
|---|---|---|
jetpositional-or-keyword | Sequence[Sequence[Interval]]Required | See the operation contract and implementation below. |
dimpositional-or-keyword | intRequired | See the operation contract and implementation below. |
orderpositional-or-keyword | intRequired | See the operation contract and implementation below. |
list[Interval]Explicit validation & failure cases
- When
order < 2, raisesValueError(f'laplacian needs order >= 2, got {order}').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Executed regression · error handling
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_error_handling() -> None:
box = [(0.0, 1.0), (0.0, 1.0)]
with pytest.raises(ValueError):
identity_jet(box, -1)
jet0 = mlp_jet_mv(box, _single_layer([0.5, 0.5], 0.0, "tanh"), 0)
with pytest.raises(ValueError):
jet_gradient(jet0, 2, 0)
jet1 = mlp_jet_mv(box, _single_layer([0.5, 0.5], 0.0, "tanh"), 1)
with pytest.raises(ValueError):
jet_hessian(jet1, 2, 1)
with pytest.raises(ValueError):
jet_laplacian(jet1, 2, 1)
with pytest.raises(ValueError):
mlp_jet_mv(box, [([[0.5, 0.5]], [0.0], "relu")], 2)
with pytest.raises(ValueError):
jet_multiply(jet1, jet0, 2, 1) # row mismatch
with pytest.raises(ValueError):
certified_partials_subdivided(box, _single_layer([0.5, 0.5], 0.0, "tanh"), 1, 0)
with pytest.raises(ValueError):
certified_partials_subdivided(
box, _single_layer([0.5, 0.5], 0.0, "tanh"), 1, [2]
)python -m pytest "packages/omnibias-core/tests/test_verified_jet_mv.py::test_error_handling" -qRegression example · certified residual bound brackets laplacian
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_certified_residual_bound_brackets_laplacian() -> None:
w, b, name = [0.8, -0.5], 0.0, "gaussian"
order = 2
box = [(-0.4, 0.4), (-0.3, 0.3)]
def laplacian(part):
return part[(2, 0)][0] + part[(0, 2)][0]
coarse = certified_residual_bound(box, _single_layer(w, b, name), order, laplacian, 1)
fine = certified_residual_bound(box, _single_layer(w, b, name), order, laplacian, 5)
assert fine.width <= coarse.width + 1e-12
# contains analytic Laplacian samples = g''(a)*|w|^2
for sx in (-0.4, 0.0, 0.4):
for sy in (-0.3, 0.0, 0.3):
lap = _analytic_partial(w, b, name, [sx, sy], (2, 0)) + _analytic_partial(
w, b, name, [sx, sy], (0, 2)
)
assert fine.lo - 1e-9 <= lap <= fine.hi + 1e-9python -m pytest packages/omnibias-core/tests/test_verified_jet_mv.py -k test_certified_residual_bound_brackets_laplacian -qRead the implementation
def jet_laplacian(
jet: Sequence[Sequence[Interval]], dim: int, order: int
) -> list[Interval]:
r"""Laplacian enclosure ``sum_i d^2 u / d x_i^2``, shape ``(C,)``. Needs ``order >= 2``.
Reads the pure second-order rows directly: ``D^{2 e_i} u = 2! * c_{2 e_i}``.
"""
if order < 2:
raise ValueError(f"laplacian needs order >= 2, got {order}")
pos = index_position(dim, order)
width = len(jet[0])
two = Interval.point(2.0)
acc = [_zero() for _ in range(width)]
for i in range(dim):
alpha = tuple(2 if j == i else 0 for j in range(dim))
row = jet[pos[alpha]]
for c in range(width):
acc[c] = acc[c] + two * row[c]
return accOther public import paths
omnibias.core.verified.jet_laplacianomnibias.core.verified.jet_mv.jet_laplacian
jet_multiply
omnibias.core.verified.jet_multiplySource ↗jet_multiply(a: Sequence[Sequence[Interval]], b: Sequence[Sequence[Interval]], dim: int, order: int) -> MVJetTruncated product of two multivariate interval jets: jet(a) * jet(b).
The multivariate Cauchy product
(a b)_gamma = sum_{alpha + beta = gamma} a_alpha b_beta truncated at total
order order -- the jet-level Leibniz rule. Columns broadcast: a scalar
mask of shape (M, 1) multiplies a vector field (M, C) component-wise,
so a hard-constraint ansatz u = g + b * net stays closed form to arbitrary
order in the verified arithmetic too.
Parameters
| Name | Type & default | Contract |
|---|---|---|
apositional-or-keyword | Sequence[Sequence[Interval]]Required | See the operation contract and implementation below. |
bpositional-or-keyword | Sequence[Sequence[Interval]]Required | See the operation contract and implementation below. |
dimpositional-or-keyword | intRequired | See the operation contract and implementation below. |
orderpositional-or-keyword | intRequired | See the operation contract and implementation below. |
MVJetExplicit validation & failure cases
- When
len(a) != m or len(b) != m, raisesValueError(f'both jets need {m} rows for dim={dim}, order={order}; got {len(a)} and {len(b)}'). - When
ca != cb and ca != 1 and (cb != 1), raisesValueError(f'incompatible column counts {ca} and {cb} (need equal or 1)').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Executed regression · jet multiply scales by constant
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_jet_multiply_scales_by_constant() -> None:
w, b, name = [0.7, -0.3], 0.2, "tanh"
order = 3
box = [(0.0, 0.4), (-0.5, 0.1)]
f = mlp_jet_mv(box, _single_layer(w, b, name), order)
m = len(f)
const = [[Interval.point(3.0 if i == 0 else 0.0)] for i in range(m)]
scaled = jet_multiply(const, f, 2, order)
for g in range(m):
assert abs(scaled[g][0].lo - 3.0 * f[g][0].lo) < 1e-12
assert abs(scaled[g][0].hi - 3.0 * f[g][0].hi) < 1e-12python -m pytest "packages/omnibias-core/tests/test_verified_jet_mv.py::test_jet_multiply_scales_by_constant" -qRegression example · jet multiply column broadcast
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_jet_multiply_column_broadcast() -> None:
order = 1
box = [(0.1, 0.1), (0.2, 0.2)]
# vector field with 2 outputs (two tanh neurons), mask is scalar (M,1)
layers = [([[0.5, 0.2], [-0.3, 0.6]], [0.0, 0.1], "tanh")]
field = mlp_jet_mv(box, layers, order)
m = len(field)
mask = [[Interval.point(2.0 if i == 0 else 0.0)] for i in range(m)]
out = jet_multiply(mask, field, 2, order)
assert len(out[0]) == 2
for g in range(m):
for c in range(2):
assert abs(out[g][c].lo - 2.0 * field[g][c].lo) < 1e-12python -m pytest packages/omnibias-core/tests/test_verified_jet_mv.py -k test_jet_multiply_column_broadcast -qRead the implementation
def jet_multiply(
a: Sequence[Sequence[Interval]],
b: Sequence[Sequence[Interval]],
dim: int,
order: int,
) -> MVJet:
r"""Truncated product of two multivariate interval jets: ``jet(a) * jet(b)``.
The multivariate Cauchy product
``(a b)_gamma = sum_{alpha + beta = gamma} a_alpha b_beta`` truncated at total
order ``order`` -- the jet-level Leibniz rule. Columns broadcast: a scalar
mask of shape ``(M, 1)`` multiplies a vector field ``(M, C)`` component-wise,
so a hard-constraint ansatz ``u = g + b * net`` stays closed form to arbitrary
order in the verified arithmetic too.
"""
m = num_multi_indices(dim, order)
if len(a) != m or len(b) != m:
raise ValueError(
f"both jets need {m} rows for dim={dim}, order={order}; "
f"got {len(a)} and {len(b)}"
)
ca = len(a[0])
cb = len(b[0])
if ca != cb and ca != 1 and cb != 1:
raise ValueError(f"incompatible column counts {ca} and {cb} (need equal or 1)")
width = max(ca, cb)
table = multiply_table(dim, order)
out: MVJet = [[_zero() for _ in range(width)] for _ in range(m)]
for g, al, be in table:
for col in range(width):
av = a[al][col if ca > 1 else 0]
bv = b[be][col if cb > 1 else 0]
out[g][col] = out[g][col] + av * bv
return outOther public import paths
omnibias.core.verified.jet_multiplyomnibias.core.verified.jet_mv.jet_multiply
jet_partials
omnibias.core.verified.jet_partialsSource ↗jet_partials(jet: Sequence[Sequence[Interval]], dim: int, order: int) -> dict[MultiIndex, list[Interval]]Raw partial-derivative enclosures {alpha: D^alpha u} from a jet.
Each coefficient row is scaled by alpha! (D^alpha u = alpha! c_alpha).
Parameters
| Name | Type & default | Contract |
|---|---|---|
jetpositional-or-keyword | Sequence[Sequence[Interval]]Required | See the operation contract and implementation below. |
dimpositional-or-keyword | intRequired | See the operation contract and implementation below. |
orderpositional-or-keyword | intRequired | See the operation contract and implementation below. |
dict[MultiIndex, list[Interval]]Explicit validation & failure cases
- When
len(jet) != len(idx), raisesValueError(f'jet has {len(jet)} rows but dim={dim}, order={order} requires {len(idx)}').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Executed regression · screened poisson sign
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_screened_poisson_sign() -> None:
pde = screened_poisson(2, 2.0, 0.0) # lap u - 4 u = -4 u for affine
x, y = 0.5, 0.5
r = certified_interior_residual(_AFFINE, [(x, x), (y, y)], pde)
assert r.lo <= -4.0 * _u_affine(x, y) <= r.hipython -m pytest "packages/omnibias-core/tests/test_verified_pde_certificate.py::test_screened_poisson_sign" -qRegression example · wide box contains interior samples
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_wide_box_contains_interior_samples(name: str) -> None:
w, b = [0.9, -0.6], 0.1
order = 3
box = [(0.1, 0.5), (-0.7, -0.2)]
part = certified_partials(box, _single_layer(w, b, name), order)
for sx in (0.1, 0.25, 0.4, 0.5):
for sy in (-0.7, -0.5, -0.3, -0.2):
for alpha in multi_indices(2, order):
val = _analytic_partial(w, b, name, [sx, sy], alpha)
assert _contains(part[alpha][0], val), (name, alpha, sx, sy)python -m pytest packages/omnibias-core/tests/test_verified_jet_mv.py -k test_wide_box_contains_interior_samples -qRead the implementation
def jet_partials(
jet: Sequence[Sequence[Interval]], dim: int, order: int
) -> dict[MultiIndex, list[Interval]]:
"""Raw partial-derivative enclosures ``{alpha: D^alpha u}`` from a jet.
Each coefficient row is scaled by ``alpha!`` (``D^alpha u = alpha! c_alpha``).
"""
idx = multi_indices(dim, order)
if len(jet) != len(idx):
raise ValueError(
f"jet has {len(jet)} rows but dim={dim}, order={order} "
f"requires {len(idx)}"
)
out: dict[MultiIndex, list[Interval]] = {}
for i, alpha in enumerate(idx):
f = multi_index_factorial(alpha)
if f == 1: # avoid a needless [1, 1] multiply that would inflate by 1 ulp
out[alpha] = list(jet[i])
else:
fact = Interval.from_rational(f)
out[alpha] = [c * fact for c in jet[i]]
return outOther public import paths
omnibias.core.verified.jet_partialsomnibias.core.verified.jet_mv.jet_partials
layer_jet_mv
omnibias.core.verified.layer_jet_mvSource ↗layer_jet_mv(z_jet: Sequence[Sequence[Interval]], weight: Sequence[Sequence[IntervalLike]], bias: Sequence[IntervalLike] | None, name: str, dim: int, order: int) -> MVJetPush a multivariate jet through one sigma(W z + b) layer (interval).
Parameters
| Name | Type & default | Contract |
|---|---|---|
z_jetpositional-or-keyword | Sequence[Sequence[Interval]]Required | See the operation contract and implementation below. |
weightpositional-or-keyword | Sequence[Sequence[IntervalLike]]Required | See the operation contract and implementation below. |
biaspositional-or-keyword | Sequence[IntervalLike] | NoneRequired | See the operation contract and implementation below. |
namepositional-or-keyword | strRequired | See the operation contract and implementation below. |
dimpositional-or-keyword | intRequired | See the operation contract and implementation below. |
orderpositional-or-keyword | intRequired | See the operation contract and implementation below. |
MVJetExecuted regression · subdivision tightens
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_subdivision_tightens() -> None:
net = _tanh_net()
pde = laplace(2)
coarse = certified_interior_residual(net, _DOMAIN, pde, splits=1)
fine = certified_interior_residual(net, _DOMAIN, pde, splits=6)
assert fine.mag <= coarse.mag + 1e-12python -m pytest "packages/omnibias-core/tests/test_verified_pde_certificate.py::test_subdivision_tightens" -qRegression example · compose jet mv matches layer path
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_compose_jet_mv_matches_layer_path() -> None:
from omnibias.core.verified.jet import affine_jet
from omnibias.core.verified.sigma import sigma_tower_interval
w, b, name = [0.7, -0.3], 0.2, "sigmoid"
order = 3
box = [(0.0, 0.4), (-0.5, 0.1)]
jet0 = identity_jet(box, order)
u_jet = affine_jet(jet0, [list(w)], [b])
tower = [
[sigma_tower_interval(name, u_jet[0][0], order)[k]] for k in range(order + 1)
]
composed = compose_jet_mv(u_jet, tower, 2, order)
layer = layer_jet_mv(jet0, [list(w)], [b], name, 2, order)
for g in range(len(composed)):
assert composed[g][0].lo == layer[g][0].lo
assert composed[g][0].hi == layer[g][0].hipython -m pytest packages/omnibias-core/tests/test_verified_jet_mv.py -k test_compose_jet_mv_matches_layer_path -qRead the implementation
def layer_jet_mv(
z_jet: Sequence[Sequence[Interval]],
weight: Sequence[Sequence[IntervalLike]],
bias: Sequence[IntervalLike] | None,
name: str,
dim: int,
order: int,
) -> MVJet:
"""Push a multivariate jet through one ``sigma(W z + b)`` layer (interval)."""
u_jet = affine_jet(z_jet, weight, bias)
m = num_multi_indices(dim, order)
width = len(u_jet[0]) if u_jet else 0
out: MVJet = [[_zero() for _ in range(width)] for _ in range(m)]
for c in range(width):
u_col = [u_jet[g][c] for g in range(m)]
tower = list(sigma_tower_interval(name, u_col[0], order))
composed = _compose_scalar_mv(u_col, tower, dim, order)
for g in range(m):
out[g][c] = composed[g]
return outOther public import paths
omnibias.core.verified.layer_jet_mvomnibias.core.verified.jet_mv.layer_jet_mv
mlp_jet_mv
omnibias.core.verified.mlp_jet_mvSource ↗mlp_jet_mv(box: BoxLike, layers: Sequence[Layer], order: int) -> MVJetCertified multivariate Taylor jet of a deep MLP over an input box.
layers is a sequence of (W, b, name); name=None is a pure affine
readout. Returns a jet of shape (M, C) whose row i *encloses*
D^alpha u(x0) / alpha! for alpha = multi_indices(D, order)[i] and every
x0 in the box. Use jet_partials, jet_gradient,
jet_hessian or jet_laplacian to read out raw derivatives.
Parameters
| Name | Type & default | Contract |
|---|---|---|
boxpositional-or-keyword | BoxLikeRequired | See the operation contract and implementation below. |
layerspositional-or-keyword | Sequence[Layer]Required | See the operation contract and implementation below. |
orderpositional-or-keyword | intRequired | See the operation contract and implementation below. |
MVJetExecuted regression · screened poisson sign
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_screened_poisson_sign() -> None:
pde = screened_poisson(2, 2.0, 0.0) # lap u - 4 u = -4 u for affine
x, y = 0.5, 0.5
r = certified_interior_residual(_AFFINE, [(x, x), (y, y)], pde)
assert r.lo <= -4.0 * _u_affine(x, y) <= r.hipython -m pytest "packages/omnibias-core/tests/test_verified_pde_certificate.py::test_screened_poisson_sign" -qRegression example · jet multiply scales by constant
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_jet_multiply_scales_by_constant() -> None:
w, b, name = [0.7, -0.3], 0.2, "tanh"
order = 3
box = [(0.0, 0.4), (-0.5, 0.1)]
f = mlp_jet_mv(box, _single_layer(w, b, name), order)
m = len(f)
const = [[Interval.point(3.0 if i == 0 else 0.0)] for i in range(m)]
scaled = jet_multiply(const, f, 2, order)
for g in range(m):
assert abs(scaled[g][0].lo - 3.0 * f[g][0].lo) < 1e-12
assert abs(scaled[g][0].hi - 3.0 * f[g][0].hi) < 1e-12python -m pytest packages/omnibias-core/tests/test_verified_jet_mv.py -k test_jet_multiply_scales_by_constant -qRead the implementation
def mlp_jet_mv(box: BoxLike, layers: Sequence[Layer], order: int) -> MVJet:
"""Certified multivariate Taylor jet of a deep MLP over an input ``box``.
``layers`` is a sequence of ``(W, b, name)``; ``name=None`` is a pure affine
readout. Returns a jet of shape ``(M, C)`` whose row ``i`` *encloses*
``D^alpha u(x0) / alpha!`` for ``alpha = multi_indices(D, order)[i]`` and every
``x0`` in the box. Use :func:`jet_partials`, :func:`jet_gradient`,
:func:`jet_hessian` or :func:`jet_laplacian` to read out raw derivatives.
"""
x0 = _as_interval_box(box)
dim = len(x0)
jet: MVJet = identity_jet(box, order)
for weight, bias, name in layers:
if name is None:
jet = affine_jet(jet, weight, bias)
else:
jet = layer_jet_mv(jet, weight, bias, name, dim, order)
return jetOther public import paths
omnibias.core.verified.mlp_jet_mvomnibias.core.verified.jet_mv.mlp_jet_mv