omnibias.boolean.jax.ops.spectrum
Boolean truth tables, multilinear extensions, algebraic spectra, and finite-temperature gate systems.
import omnibias.boolean.jax.ops.spectrumModule contract & mathematical conventions
Differentiable Boolean spectrum engine (jax) via multivariate jets.
Bit-identical twin of omnibias.boolean.torch.ops.spectrum (double precision
required for exact cross-backend parity -- enable jax_enable_x64). The
multilinear extension is built as a multivariate jet with
omnibias.jax.jet_mv.identity_jet and the truncated Cauchy product, and the
Mobius / Walsh spectra are read off with
omnibias.jax.jet_mv.jet_partials.
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.
algebraic_degree_soft
omnibias.boolean.jax.ops.algebraic_degree_softSource ↗algebraic_degree_soft(values: Sequence[float] | Array) -> ArraySpectral-energy-weighted mean monomial order (a smooth degree proxy).
Parameters
| Name | Type & default | Contract |
|---|---|---|
valuespositional-or-keyword | Sequence[float] | ArrayRequired | See the operation contract and implementation below. |
ArrayRead the implementation
def algebraic_degree_soft(values: Sequence[float] | Array) -> Array:
"""Spectral-energy-weighted mean monomial order (a smooth degree proxy)."""
w = walsh_coeffs(values)
n = _num_vars(w.shape[0])
orders = jnp.asarray(
[bin(mask).count("1") for mask in range(1 << n)], dtype=w.dtype
)
energy = (w**2).sum()
return (orders * w**2).sum() / energyOther public import paths
omnibias.boolean.jax.ops.algebraic_degree_softomnibias.boolean.jax.ops.spectrum.algebraic_degree_soft
influences_diff
omnibias.boolean.jax.ops.influences_diffSource ↗influences_diff(values: Sequence[float] | Array) -> ArrayPer-coordinate influence Inf_i = sum_{S in i} hat f(S)^2 (differentiable).
Parameters
| Name | Type & default | Contract |
|---|---|---|
valuespositional-or-keyword | Sequence[float] | ArrayRequired | See the operation contract and implementation below. |
ArrayExecuted regression · walsh and influence parity
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_walsh_and_influence_parity() -> None:
for tt in _tts(22):
vals = pm1_values(tt)
tw = _np(tb.walsh_coeffs(torch.tensor(vals, dtype=torch.float64)))
jw = _np(jb.walsh_coeffs(jnp.asarray(vals, dtype=jnp.float64)))
assert np.allclose(tw, jw, rtol=1e-9, atol=1e-11)
ti = _np(tb.influences_diff(torch.tensor(vals, dtype=torch.float64)))
ji = _np(jb.influences_diff(jnp.asarray(vals, dtype=jnp.float64)))
assert np.allclose(ti, ji, rtol=1e-9, atol=1e-11)python -m pytest "packages/omnibias-boolean/tests/test_cross_backend.py::test_walsh_and_influence_parity" -qRead the implementation
def influences_diff(values: Sequence[float] | Array) -> Array:
"""Per-coordinate influence ``Inf_i = sum_{S in i} hat f(S)^2`` (differentiable)."""
w = walsh_coeffs(values)
n = _num_vars(w.shape[0])
out = []
for i in range(n):
idx = [mask for mask in range(1 << n) if (mask >> i) & 1]
out.append((w[jnp.asarray(idx)] ** 2).sum())
return jnp.stack(out)Other public import paths
omnibias.boolean.jax.ops.influences_diffomnibias.boolean.jax.ops.spectrum.influences_diff
mobius_coeffs
omnibias.boolean.jax.ops.mobius_coeffsSource ↗mobius_coeffs(values: Sequence[float] | Array) -> Array{0,1} Mobius / multilinear coefficients m_S (indexed by subset mask).
Parameters
| Name | Type & default | Contract |
|---|---|---|
valuespositional-or-keyword | Sequence[float] | ArrayRequired | See the operation contract and implementation below. |
ArrayExecuted regression · mobius parity
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_mobius_parity() -> None:
for tt in _tts(21):
t = _np(tb.mobius_coeffs(torch.tensor(tt, dtype=torch.float64)))
j = _np(jb.mobius_coeffs(jnp.asarray(tt, dtype=jnp.float64)))
assert np.allclose(t, j, rtol=1e-9, atol=1e-11)python -m pytest "packages/omnibias-boolean/tests/test_cross_backend.py::test_mobius_parity" -qRead the implementation
def mobius_coeffs(values: Sequence[float] | Array) -> Array:
"""``{0,1}`` Mobius / multilinear coefficients ``m_S`` (indexed by subset mask)."""
return _coeffs_vector(_as_array(values), "mobius")Other public import paths
omnibias.boolean.jax.ops.mobius_coeffsomnibias.boolean.jax.ops.spectrum.mobius_coeffs
mobius_spectrum
omnibias.boolean.jax.ops.mobius_spectrumSource ↗mobius_spectrum(values: Sequence[float] | Array) -> dict[frozenset[int], Array]Mobius coefficients as a {variable-set: m_S} mapping.
Parameters
| Name | Type & default | Contract |
|---|---|---|
valuespositional-or-keyword | Sequence[float] | ArrayRequired | See the operation contract and implementation below. |
dict[frozenset[int], Array]Read the implementation
def mobius_spectrum(values: Sequence[float] | Array) -> dict[frozenset[int], Array]:
"""Mobius coefficients as a ``{variable-set: m_S}`` mapping."""
return _to_spectrum(mobius_coeffs(values))Other public import paths
omnibias.boolean.jax.ops.mobius_spectrumomnibias.boolean.jax.ops.spectrum.mobius_spectrum
walsh_coeffs
omnibias.boolean.jax.ops.walsh_coeffsSource ↗walsh_coeffs(values: Sequence[float] | Array) -> Array{+-1} Walsh / Fourier coefficients hat f(S) (indexed by subset mask).
Parameters
| Name | Type & default | Contract |
|---|---|---|
valuespositional-or-keyword | Sequence[float] | ArrayRequired | See the operation contract and implementation below. |
ArrayExecuted regression · design loss parity
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_design_loss_parity() -> None:
vals = [0.1, 0.7, 0.3, 0.9]
t = float(tb.degree_penalty(torch.tensor(vals, dtype=torch.float64)))
j = float(jb.degree_penalty(jnp.asarray(vals, dtype=jnp.float64)))
assert t == pytest.approx(j, rel=1e-9, abs=1e-11)python -m pytest "packages/omnibias-boolean/tests/test_cross_backend.py::test_design_loss_parity" -qRegression example · walsh and influence parity
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_walsh_and_influence_parity() -> None:
for tt in _tts(22):
vals = pm1_values(tt)
tw = _np(tb.walsh_coeffs(torch.tensor(vals, dtype=torch.float64)))
jw = _np(jb.walsh_coeffs(jnp.asarray(vals, dtype=jnp.float64)))
assert np.allclose(tw, jw, rtol=1e-9, atol=1e-11)
ti = _np(tb.influences_diff(torch.tensor(vals, dtype=torch.float64)))
ji = _np(jb.influences_diff(jnp.asarray(vals, dtype=jnp.float64)))
assert np.allclose(ti, ji, rtol=1e-9, atol=1e-11)python -m pytest packages/omnibias-boolean/tests/test_cross_backend.py -k test_walsh_and_influence_parity -qRead the implementation
def walsh_coeffs(values: Sequence[float] | Array) -> Array:
"""``{+-1}`` Walsh / Fourier coefficients ``hat f(S)`` (indexed by subset mask)."""
return _coeffs_vector(_as_array(values), "walsh")Other public import paths
omnibias.boolean.jax.ops.walsh_coeffsomnibias.boolean.jax.ops.spectrum.walsh_coeffs
walsh_spectrum
omnibias.boolean.jax.ops.walsh_spectrumSource ↗walsh_spectrum(values: Sequence[float] | Array) -> dict[frozenset[int], Array]Walsh/Fourier coefficients as a {variable-set: hat f(S)} mapping.
Parameters
| Name | Type & default | Contract |
|---|---|---|
valuespositional-or-keyword | Sequence[float] | ArrayRequired | See the operation contract and implementation below. |
dict[frozenset[int], Array]Read the implementation
def walsh_spectrum(values: Sequence[float] | Array) -> dict[frozenset[int], Array]:
"""Walsh/Fourier coefficients as a ``{variable-set: hat f(S)}`` mapping."""
return _to_spectrum(walsh_coeffs(values))Other public import paths
omnibias.boolean.jax.ops.walsh_spectrumomnibias.boolean.jax.ops.spectrum.walsh_spectrum