omnibias.core.ftc
Coefficient recurrences, activation contracts, jet algebra, and verified arithmetic shared by the numerical backends.
import omnibias.core.ftcModule contract & mathematical conventions
1-D fundamental-theorem cell (theory 09-03 + 09-17).
The cell is the unused integral role
I = S(w x + b_hi) - S(w x + b_lo) with S' = sigma. The
derivative head is FTC of that window, not a second pack. The
founding bias collapse (delta -> 0) of the same window is
I / delta -> sigma(w x + b). Temperature collapse
(beta -> inf, feasibility) does not appear. Do not conflate the
two.
This is a 1-D FTC identity, not a VPINN / weak form, and with explicit local scope.
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.
DEFAULT_DUAL
omnibias.core.ftc.DEFAULT_DUALSource ↗DEFAULT_DUAL = DualFTCConfig()This exported constant is defined by the expression above. Its exact value and annotation come from the pinned source; use it with the module contract.
Read the implementation
DEFAULT_DUAL = DualFTCConfig()DISCLAIMER
omnibias.core.ftc.DISCLAIMERSource ↗DISCLAIMER = '1-D FTC integral cell; not a VPINN, not a weak form, with explicit local scope'This exported constant is defined by the expression above. Its exact value and annotation come from the pinned source; use it with the module contract.
Regression example · g3 honesty
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_g3_honesty() -> None:
payload = honesty_payload()
assert payload["claimed_weak_form"] is False
assert payload["claimed_vpinn"] is False
assert payload["theorem_prover_verified"] is False
assert "not a VPINN" in DISCLAIMERpython -m pytest packages/omnibias-core/tests/test_ftc.py -k test_g3_honesty -qRead the implementation
DISCLAIMER = (
"1-D FTC integral cell; not a VPINN, not a weak form, with explicit local scope"
)Other public import paths
omnibias.core.ftc.DISCLAIMERomnibias.jax.architectures.ftc_net.DISCLAIMERomnibias.torch.architectures.ftc_net.DISCLAIMER
DualFTCConfig
omnibias.core.ftc.DualFTCConfigSource ↗class DualFTCConfigDataclass constructor fields; inherited fields, if any, are declared by the base class. A field(...) expression describes a default factory or field options, not a literal argument default.
The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
w_derivdataclass field | floatDefault: 1.0 | See the operation contract and implementation below. |
w_intdataclass field | floatDefault: 1.0 | See the operation contract and implementation below. |
Fields & methods
w_derivfield
w_deriv: float = 1.0Declared float field on DualFTCConfig. Default expression: 1.0.
w_intfield
w_int: float = 1.0Declared float field on DualFTCConfig. Default expression: 1.0.
Read the implementation
class DualFTCConfig:
w_deriv: float = 1.0
w_int: float = 1.0Other public import paths
omnibias.core.ftc.DualFTCConfigomnibias.jax.architectures.DualFTCConfigomnibias.torch.architectures.DualFTCConfigomnibias.jax.architectures.ftc_net.DualFTCConfigomnibias.torch.architectures.ftc_net.DualFTCConfig
DualFTCResult
omnibias.core.ftc.DualFTCResultSource ↗class DualFTCResultDataclass constructor fields; inherited fields, if any, are declared by the base class. A field(...) expression describes a default factory or field options, not a literal argument default.
The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
lossdataclass field | floatRequired | See the operation contract and implementation below. |
r_Ddataclass field | list[float]Required | See the operation contract and implementation below. |
r_Idataclass field | list[float]Required | See the operation contract and implementation below. |
max_r_Ddataclass field | floatRequired | See the operation contract and implementation below. |
max_r_Idataclass field | floatRequired | See the operation contract and implementation below. |
Fields & methods
lossfield
loss: floatDeclared float field on DualFTCResult. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.
View source ↗r_Dfield
r_D: list[float]Declared list[float] field on DualFTCResult. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.
View source ↗r_Ifield
r_I: list[float]Declared list[float] field on DualFTCResult. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.
View source ↗max_r_Dfield
max_r_D: floatDeclared float field on DualFTCResult. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.
View source ↗max_r_Ifield
max_r_I: floatDeclared float field on DualFTCResult. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.
View source ↗Read the implementation
class DualFTCResult:
loss: float
r_D: list[float]
r_I: list[float]
max_r_D: float
max_r_I: floatFTCNetConfig
omnibias.core.ftc.FTCNetConfigSource ↗class FTCNetConfigDataclass constructor fields; inherited fields, if any, are declared by the base class. A field(...) expression describes a default factory or field options, not a literal argument default.
The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
n_blocksdataclass field | intDefault: 2 | See the operation contract and implementation below. |
widthdataclass field | intDefault: 12 | See the operation contract and implementation below. |
windowdataclass field | floatDefault: 0.6 | See the operation contract and implementation below. |
Regression example · g1 matches core
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_g1_matches_core() -> None:
x = jnp.asarray(0.0)
w = jnp.asarray(1.0)
lo = jnp.asarray(-0.1)
hi = jnp.asarray(0.1)
integral, deriv, collapse = ftc_block(x, w, lo, hi)
ex = worked_example()
assert float(integral) == ex["I"]
assert float(deriv) == ex["dI"]
assert float(collapse) == ex["collapse"]
assert FTCNet(FTCNetConfig()).config.window == 0.6python -m pytest packages/omnibias-jax/tests/test_ftc_net.py -k test_g1_matches_core -qRegression example · g1 and g4 matches core
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_g1_and_g4_matches_core() -> None:
torch.set_default_dtype(torch.float64)
x = torch.tensor(0.0)
w = torch.tensor(1.0)
lo = torch.tensor(-0.1)
hi = torch.tensor(0.1)
integral, deriv, collapse = ftc_block(x, w, lo, hi)
ex = worked_example()
assert float(integral) == ex["I"]
assert float(deriv) == ex["dI"]
assert float(collapse) == ex["collapse"]
net = FTCNet(FTCNetConfig())
assert net.config.width == 12
loss = dual_ftc_loss([float(integral)], [float(deriv)], [float(deriv)], [0.0], I_a=float(integral))
assert loss.max_r_D < 1e-12python -m pytest packages/omnibias-torch/tests/test_ftc_net.py -k test_g1_and_g4_matches_core -qFields & methods
n_blocksfield
n_blocks: int = 2Declared int field on FTCNetConfig. Default expression: 2.
windowfield
window: float = 0.6Declared float field on FTCNetConfig. Default expression: 0.6.
Read the implementation
class FTCNetConfig:
n_blocks: int = 2
width: int = 12
window: float = 0.6Other public import paths
omnibias.core.ftc.FTCNetConfigomnibias.jax.architectures.FTCNetConfigomnibias.torch.architectures.FTCNetConfigomnibias.jax.architectures.ftc_net.FTCNetConfigomnibias.torch.architectures.ftc_net.FTCNetConfig
Pack
omnibias.core.ftc.PackSource ↗class PackDataclass constructor fields; inherited fields, if any, are declared by the base class. A field(...) expression describes a default factory or field options, not a literal argument default.
The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
wdataclass field | floatRequired | See the operation contract and implementation below. |
centerdataclass field | floatRequired | See the operation contract and implementation below. |
half_windowdataclass field | floatRequired | See the operation contract and implementation below. |
ampdataclass field | floatDefault: 1.0 | See the operation contract and implementation below. |
Fields & methods
wfield
w: floatDeclared float field on Pack. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.
View source ↗centerfield
center: floatDeclared float field on Pack. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.
View source ↗half_windowfield
half_window: floatDeclared float field on Pack. A value must be provided when constructing the configuration, unless an inherited constructor supplies it.
View source ↗Read the implementation
class Pack:
w: float
center: float
half_window: float
amp: float = 1.0dual_ftc_loss
omnibias.core.ftc.dual_ftc_lossSource ↗dual_ftc_loss(I_vals: Sequence[float], dI_vals: Sequence[float], f_vals: Sequence[float], F_vals: Sequence[float], *, config: DualFTCConfig=DEFAULT_DUAL, I_a: float | None=None) -> DualFTCResultr_D = dI - f, r_I = I - I(a) - Integral_a^x f. I_a defaults to I[0].
Parameters
| Name | Type & default | Contract |
|---|---|---|
I_valspositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
dI_valspositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
f_valspositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
F_valspositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
configkeyword-only | DualFTCConfigDefault: DEFAULT_DUAL | See the operation contract and implementation below. |
I_akeyword-only | float | NoneDefault: None | See the operation contract and implementation below. |
DualFTCResultExplicit validation & failure cases
- When
not len(I_vals) == len(dI_vals) == len(f_vals) == len(F_vals), raisesValueError('dual_ftc_loss requires aligned sequences').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Executed regression · g2 dual reduces integral residual
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_g2_dual_reduces_integral_residual() -> None:
report = dual_skill_report()
assert report["below_1e4"] is True
assert report["ri_below_deriv_only"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_vpinn"] is Falsepython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g2_dual_reduces_integral_residual" -qRegression example · g1 worked example
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_g1_worked_example() -> None:
ex = worked_example()
assert ex["collapse_err"] < 1e-12
assert ex["ftc_err"] < 1e-12
assert abs(ex["I"] - 0.1) < 1e-12
integral, deriv, collapse = ftc_block(0.0, 1.0, -0.1, 0.1)
loss = dual_ftc_loss([integral], [deriv], [deriv], [0.0], I_a=integral)
assert loss.max_r_D < 1e-12
assert loss.max_r_I < 1e-12
loss0 = dual_ftc_loss([integral], [deriv], [0.0], [0.0], I_a=integral)
assert loss0.max_r_D > 0.04python -m pytest packages/omnibias-core/tests/test_ftc.py -k test_g1_worked_example -qRead the implementation
def dual_ftc_loss(
I_vals: Sequence[float],
dI_vals: Sequence[float],
f_vals: Sequence[float],
F_vals: Sequence[float],
*,
config: DualFTCConfig = DEFAULT_DUAL,
I_a: float | None = None,
) -> DualFTCResult:
"""``r_D = dI - f``, ``r_I = I - I(a) - Integral_a^x f``. ``I_a`` defaults to ``I[0]``."""
if not (len(I_vals) == len(dI_vals) == len(f_vals) == len(F_vals)):
raise ValueError("dual_ftc_loss requires aligned sequences")
ia = float(I_vals[0] if I_a is None else I_a)
r_d = [di - fi for di, fi in zip(dI_vals, f_vals, strict=True)]
r_i = [iv - ia - Fv for iv, Fv in zip(I_vals, F_vals, strict=True)]
loss = config.w_deriv * sum(v * v for v in r_d) + config.w_int * sum(v * v for v in r_i)
n = float(len(r_d))
return DualFTCResult(loss / n, r_d, r_i, max_abs(r_d), max_abs(r_i))dual_skill_report
omnibias.core.ftc.dual_skill_reportSource ↗dual_skill_report(*, seeds: int=5, n_grid: int=129) -> dict[str, object]G2 for 09-17: dual residual vs derivative-only on f = cos.
Parameters
| Name | Type & default | Contract |
|---|---|---|
seedskeyword-only | intDefault: 5 | See the operation contract and implementation below. |
n_gridkeyword-only | intDefault: 129 | See the operation contract and implementation below. |
dict[str, object]Executed regression · g2 dual reduces integral residual
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_g2_dual_reduces_integral_residual() -> None:
report = dual_skill_report()
assert report["below_1e4"] is True
assert report["ri_below_deriv_only"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_vpinn"] is Falsepython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g2_dual_reduces_integral_residual" -qRegression example · g2 skill beats identity
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_g2_skill_beats_identity() -> None:
report = skill_report()
assert report["below_1e4"] is True
assert report["beats_identity"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_weak_form"] is Falsepython -m pytest packages/omnibias-core/tests/test_ftc.py -k test_g2_skill_beats_identity -qRead the implementation
def dual_skill_report(*, seeds: int = 5, n_grid: int = 129) -> dict[str, object]:
"""G2 for 09-17: dual residual vs derivative-only on ``f = cos``."""
xs = _grid(n_grid)
f = [math.cos(x) for x in xs]
F = [math.sin(x) - math.sin(xs[0]) for x in xs]
cfg = FTCNetConfig()
dual_rd: list[float] = []
dual_ri: list[float] = []
only_ri: list[float] = []
zero_i = max_abs(F)
for seed in range(seeds):
packs = _seed_packs(cfg, seed)
deriv_only = fit_ftc_deriv(xs, f, packs)
dual = fit_dual(xs, f, F, packs)
d_only_I = evaluate_sum(xs, deriv_only, "integral")
d_only_dI = evaluate_sum(xs, deriv_only, "deriv")
dual_I = evaluate_sum(xs, dual, "integral")
dual_dI = evaluate_sum(xs, dual, "deriv")
only = dual_ftc_loss(d_only_I, d_only_dI, f, F, I_a=0.0)
both = dual_ftc_loss(dual_I, dual_dI, f, F, I_a=0.0)
dual_rd.append(both.max_r_D)
dual_ri.append(both.max_r_I)
only_ri.append(only.max_r_I)
med_rd = sorted(dual_rd)[len(dual_rd) // 2]
med_ri = sorted(dual_ri)[len(dual_ri) // 2]
med_only = sorted(only_ri)[len(only_ri) // 2]
return {
"dual_max_r_D": dual_rd,
"dual_max_r_I": dual_ri,
"deriv_only_max_r_I": only_ri,
"median_r_D": med_rd,
"median_r_I": med_ri,
"median_deriv_only_r_I": med_only,
"skill": 1.0 - med_ri / zero_i if zero_i else 0.0,
"ri_below_deriv_only": med_ri < med_only,
"below_1e4": med_rd < 1e-4 and med_ri < 1e-4,
"claimed_vpinn": False,
}evaluate_sum
omnibias.core.ftc.evaluate_sumSource ↗evaluate_sum(xs: Sequence[float], packs: Sequence[Pack], kind: str) -> list[float]The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
xspositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
packspositional-or-keyword | Sequence[Pack]Required | See the operation contract and implementation below. |
kindpositional-or-keyword | strRequired | See the operation contract and implementation below. |
list[float]Executed regression · g2 skill beats identity
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_g2_skill_beats_identity() -> None:
report = skill_report()
assert report["below_1e4"] is True
assert report["beats_identity"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_weak_form"] is Falsepython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g2_skill_beats_identity" -qRead the implementation
def evaluate_sum(
xs: Sequence[float],
packs: Sequence[Pack],
kind: str,
) -> list[float]:
fn = {
"integral": pack_integral,
"deriv": pack_deriv,
"identity": identity_value,
"identity_deriv": identity_deriv,
}[kind]
return [sum(fn(x, p) for p in packs) for x in xs]fit_dual
omnibias.core.ftc.fit_dualSource ↗fit_dual(xs: Sequence[float], f: Sequence[float], F: Sequence[float], packs: Sequence[Pack], *, config: DualFTCConfig=DEFAULT_DUAL) -> list[Pack]Stacked [sqrt(w_d) dI; sqrt(w_I) I] against [f; F].
Parameters
| Name | Type & default | Contract |
|---|---|---|
xspositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
fpositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
Fpositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
packspositional-or-keyword | Sequence[Pack]Required | See the operation contract and implementation below. |
configkeyword-only | DualFTCConfigDefault: DEFAULT_DUAL | See the operation contract and implementation below. |
list[Pack]Executed regression · g2 dual reduces integral residual
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_g2_dual_reduces_integral_residual() -> None:
report = dual_skill_report()
assert report["below_1e4"] is True
assert report["ri_below_deriv_only"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_vpinn"] is Falsepython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g2_dual_reduces_integral_residual" -qRead the implementation
def fit_dual(
xs: Sequence[float],
f: Sequence[float],
F: Sequence[float],
packs: Sequence[Pack],
*,
config: DualFTCConfig = DEFAULT_DUAL,
) -> list[Pack]:
"""Stacked ``[sqrt(w_d) dI; sqrt(w_I) I]`` against ``[f; F]``."""
wd = math.sqrt(config.w_deriv)
wi = math.sqrt(config.w_int)
cols: list[list[float]] = []
for p in packs:
unit = Pack(p.w, p.center, p.half_window, 1.0)
col = [wd * pack_deriv(x, unit) for x in xs]
col.extend(wi * pack_integral(x, unit) for x in xs)
cols.append(col)
target = [wd * v for v in f]
target.extend(wi * v for v in F)
return _with_amps(packs, _lstsq(cols, target))fit_ftc_deriv
omnibias.core.ftc.fit_ftc_derivSource ↗fit_ftc_deriv(xs: Sequence[float], target: Sequence[float], packs: Sequence[Pack]) -> list[Pack]The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
xspositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
targetpositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
packspositional-or-keyword | Sequence[Pack]Required | See the operation contract and implementation below. |
list[Pack]Executed regression · g2 skill beats identity
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_g2_skill_beats_identity() -> None:
report = skill_report()
assert report["below_1e4"] is True
assert report["beats_identity"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_weak_form"] is Falsepython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g2_skill_beats_identity" -qRead the implementation
def fit_ftc_deriv(
xs: Sequence[float],
target: Sequence[float],
packs: Sequence[Pack],
) -> list[Pack]:
cols = [[pack_deriv(x, Pack(p.w, p.center, p.half_window, 1.0)) for x in xs] for p in packs]
return _with_amps(packs, _lstsq(cols, target))fit_identity_deriv
omnibias.core.ftc.fit_identity_derivSource ↗fit_identity_deriv(xs: Sequence[float], target: Sequence[float], packs: Sequence[Pack]) -> list[Pack]The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
xspositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
targetpositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
packspositional-or-keyword | Sequence[Pack]Required | See the operation contract and implementation below. |
list[Pack]Executed regression · g2 skill beats identity
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_g2_skill_beats_identity() -> None:
report = skill_report()
assert report["below_1e4"] is True
assert report["beats_identity"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_weak_form"] is Falsepython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g2_skill_beats_identity" -qRead the implementation
def fit_identity_deriv(
xs: Sequence[float],
target: Sequence[float],
packs: Sequence[Pack],
) -> list[Pack]:
cols = [[identity_deriv(x, Pack(p.w, p.center, p.half_window, 1.0)) for x in xs] for p in packs]
return _with_amps(packs, _lstsq(cols, target))ftc_block
omnibias.core.ftc.ftc_blockSource ↗ftc_block(x: float, w: float, b_lo: float, b_hi: float, *, activation: str='sigmoid') -> tuple[float, float, float]Closed-form integral cell, FTC derivative, and collapse head.
Parameters
| Name | Type & default | Contract |
|---|---|---|
xpositional-or-keyword | floatRequired | See the operation contract and implementation below. |
wpositional-or-keyword | floatRequired | See the operation contract and implementation below. |
b_lopositional-or-keyword | floatRequired | See the operation contract and implementation below. |
b_hipositional-or-keyword | floatRequired | See the operation contract and implementation below. |
activationkeyword-only | strDefault: 'sigmoid' | See the operation contract and implementation below. |
tuple[float, float, float]Explicit validation & failure cases
- When
activation != 'sigmoid', raisesValueError(f'only sigmoid is implemented, got {activation!r}'). - When
b_hi == b_lo, raisesValueError('window is degenerate; collapse is a separate head').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Executed regression · g2 skill beats identity
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_g2_skill_beats_identity() -> None:
report = skill_report()
assert report["below_1e4"] is True
assert report["beats_identity"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_weak_form"] is Falsepython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g2_skill_beats_identity" -qRegression example · band embed interior bin matches ftc block
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_band_embed_interior_bin_matches_ftc_block() -> None:
"""The one finite (non-open-tail) bin of a 2-threshold grid == ftc_block's deriv."""
t_lo, t_hi, beta, x = -0.4, 0.9, 2.5, 0.37
interior = band_embed(np.array([x]), np.array([t_lo, t_hi]), beta=beta)[0, 1]
b_hi = -beta * t_lo
b_lo = -beta * t_hi
_integral, deriv, _collapse = ftc_block(beta * x, 1.0, b_lo, b_hi)
assert abs(float(interior) - deriv) < 1e-12python -m pytest packages/omnibias-core/tests/test_band_embed.py -k test_band_embed_interior_bin_matches_ftc_block -qRead the implementation
def ftc_block(
x: float,
w: float,
b_lo: float,
b_hi: float,
*,
activation: str = "sigmoid",
) -> tuple[float, float, float]:
"""Closed-form integral cell, FTC derivative, and collapse head."""
if activation != "sigmoid":
raise ValueError(f"only sigmoid is implemented, got {activation!r}")
if b_hi == b_lo:
raise ValueError("window is degenerate; collapse is a separate head")
z_lo = w * x + b_lo
z_hi = w * x + b_hi
integral = softplus(z_hi) - softplus(z_lo)
deriv = w * (sigmoid(z_hi) - sigmoid(z_lo))
collapse = integral / (b_hi - b_lo)
return integral, deriv, collapsehonesty_payload
omnibias.core.ftc.honesty_payloadSource ↗honesty_payload() -> dict[str, bool]The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
dict[str, bool]Executed regression · g3 honesty
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_g3_honesty() -> None:
payload = honesty_payload()
assert payload["claimed_weak_form"] is False
assert payload["claimed_vpinn"] is False
assert payload["theorem_prover_verified"] is False
assert "not a VPINN" in DISCLAIMERpython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g3_honesty" -qRead the implementation
def honesty_payload() -> dict[str, bool]:
return {
"claimed_weak_form": False,
"claimed_vpinn": False,
"global_convergence_claim": False,
"theorem_prover_verified": False,
}Other public import paths
omnibias.core.ftc.honesty_payloadomnibias.jax.architectures.ftc_net.honesty_payloadomnibias.torch.architectures.ftc_net.honesty_payload
identity_deriv
omnibias.core.ftc.identity_derivSource ↗identity_deriv(x: float, pack: Pack) -> floatd/dx sigma(w x + c) of an identity cell, not an integral window.
Parameters
| Name | Type & default | Contract |
|---|---|---|
xpositional-or-keyword | floatRequired | See the operation contract and implementation below. |
packpositional-or-keyword | PackRequired | See the operation contract and implementation below. |
floatExecuted regression · g2 skill beats identity
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_g2_skill_beats_identity() -> None:
report = skill_report()
assert report["below_1e4"] is True
assert report["beats_identity"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_weak_form"] is Falsepython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g2_skill_beats_identity" -qRead the implementation
def identity_deriv(x: float, pack: Pack) -> float:
"""``d/dx sigma(w x + c)`` of an identity cell, not an integral window."""
s = sigmoid(pack.w * x + pack.center)
return pack.amp * pack.w * s * (1.0 - s)identity_value
omnibias.core.ftc.identity_valueSource ↗identity_value(x: float, pack: Pack) -> floatThe module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
xpositional-or-keyword | floatRequired | See the operation contract and implementation below. |
packpositional-or-keyword | PackRequired | See the operation contract and implementation below. |
floatRead the implementation
def identity_value(x: float, pack: Pack) -> float:
return pack.amp * sigmoid(pack.w * x + pack.center)max_abs
omnibias.core.ftc.max_absSource ↗max_abs(values: Sequence[float]) -> floatThe module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
valuespositional-or-keyword | Sequence[float]Required | See the operation contract and implementation below. |
floatExecuted regression · g2 skill beats identity
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_g2_skill_beats_identity() -> None:
report = skill_report()
assert report["below_1e4"] is True
assert report["beats_identity"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_weak_form"] is Falsepython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g2_skill_beats_identity" -qRead the implementation
def max_abs(values: Sequence[float]) -> float:
return max(abs(v) for v in values) if values else 0.0pack_deriv
omnibias.core.ftc.pack_derivSource ↗pack_deriv(x: float, pack: Pack) -> floatThe module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
xpositional-or-keyword | floatRequired | See the operation contract and implementation below. |
packpositional-or-keyword | PackRequired | See the operation contract and implementation below. |
floatExecuted regression · g2 skill beats identity
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_g2_skill_beats_identity() -> None:
report = skill_report()
assert report["below_1e4"] is True
assert report["beats_identity"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_weak_form"] is Falsepython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g2_skill_beats_identity" -qRead the implementation
def pack_deriv(x: float, pack: Pack) -> float:
b_lo, b_hi = _lo_hi(pack)
_i, deriv, _c = ftc_block(x, pack.w, b_lo, b_hi)
return pack.amp * derivpack_integral
omnibias.core.ftc.pack_integralSource ↗pack_integral(x: float, pack: Pack) -> floatThe module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
xpositional-or-keyword | floatRequired | See the operation contract and implementation below. |
packpositional-or-keyword | PackRequired | See the operation contract and implementation below. |
floatExecuted regression · g2 dual reduces integral residual
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_g2_dual_reduces_integral_residual() -> None:
report = dual_skill_report()
assert report["below_1e4"] is True
assert report["ri_below_deriv_only"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_vpinn"] is Falsepython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g2_dual_reduces_integral_residual" -qRead the implementation
def pack_integral(x: float, pack: Pack) -> float:
b_lo, b_hi = _lo_hi(pack)
integral, _d, _c = ftc_block(x, pack.w, b_lo, b_hi)
return pack.amp * integralsigmoid
omnibias.core.ftc.sigmoidSource ↗sigmoid(z: float) -> floatThe module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.
Parameters
| Name | Type & default | Contract |
|---|---|---|
zpositional-or-keyword | floatRequired | See the operation contract and implementation below. |
floatExecuted regression · g2 antiderivative
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_g2_antiderivative() -> None:
report = antiderivative_skill()
assert report["below_1e3"] is True
assert report["skill_positive"] is True
assert float(report["skill"]) > 0.0python -m pytest "packages/omnibias-core/tests/test_integral_kernel.py::test_g2_antiderivative" -qRead the implementation
def sigmoid(z: float) -> float:
if z >= 0.0:
return float(1.0 / (1.0 + math.exp(-z)))
ez = math.exp(z)
return float(ez / (1.0 + ez))skill_report
omnibias.core.ftc.skill_reportSource ↗skill_report(*, seeds: int=5, n_grid: int=129) -> dict[str, object]G2 for 09-03: fit dI/dx = cos x vs identity-cell sigma'.
Parameters
| Name | Type & default | Contract |
|---|---|---|
seedskeyword-only | intDefault: 5 | See the operation contract and implementation below. |
n_gridkeyword-only | intDefault: 129 | See the operation contract and implementation below. |
dict[str, object]Executed regression · g2 skill beats identity
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_g2_skill_beats_identity() -> None:
report = skill_report()
assert report["below_1e4"] is True
assert report["beats_identity"] is True
assert float(report["skill"]) > 0.0
assert report["claimed_weak_form"] is Falsepython -m pytest "packages/omnibias-core/tests/test_ftc.py::test_g2_skill_beats_identity" -qRead the implementation
def skill_report(*, seeds: int = 5, n_grid: int = 129) -> dict[str, object]:
"""G2 for 09-03: fit ``dI/dx = cos x`` vs identity-cell ``sigma'``."""
xs = _grid(n_grid)
target = [math.cos(x) for x in xs]
zero_err = max_abs(target)
ftc_errs: list[float] = []
id_errs: list[float] = []
cfg = FTCNetConfig()
for seed in range(seeds):
packs = _seed_packs(cfg, seed)
ftc = fit_ftc_deriv(xs, target, packs)
ident = fit_identity_deriv(xs, target, packs)
ftc_errs.append(max_abs([a - b for a, b in zip(evaluate_sum(xs, ftc, "deriv"), target, strict=True)]))
id_errs.append(
max_abs([a - b for a, b in zip(evaluate_sum(xs, ident, "identity_deriv"), target, strict=True)])
)
ftc_med = sorted(ftc_errs)[len(ftc_errs) // 2]
id_med = sorted(id_errs)[len(id_errs) // 2]
return {
"ftc_errors": ftc_errs,
"identity_errors": id_errs,
"ftc_median": ftc_med,
"identity_median": id_med,
"zero_error": zero_err,
"skill": 1.0 - ftc_med / zero_err if zero_err else 0.0,
"beats_identity": ftc_med < id_med,
"below_1e4": ftc_med < 1e-4,
"claimed_weak_form": False,
}softplus
omnibias.core.ftc.softplusSource ↗softplus(z: float) -> floatlog(1 + exp(z)) with the stable z + log1p(exp(-z)) branch.
Parameters
| Name | Type & default | Contract |
|---|---|---|
zpositional-or-keyword | floatRequired | See the operation contract and implementation below. |
floatExecuted regression · g1
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_g1() -> None:
ex = worked_example()
assert ex["g1_err"] < 1e-12
z = jnp.asarray([0.5])
cell = float(integral_cell(z, -0.5, 0.5)[0])
assert abs(cell - core_cell(0.5, -0.5, 0.5)) < 1e-12python -m pytest "packages/omnibias-jax/tests/test_integral_kernel.py::test_g1" -qRegression example · g1 cell
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_g1_cell() -> None:
ex = worked_example()
assert ex["g1_err"] < 1e-12
assert abs(integral_cell(0.5, -0.5, 0.5) - (softplus(1.0) - softplus(0.0))) < 1e-12
assert abs(ex["mass"] - 0.5) < 1e-12python -m pytest packages/omnibias-core/tests/test_integral_kernel.py -k test_g1_cell -qRead the implementation
def softplus(z: float) -> float:
"""``log(1 + exp(z))`` with the stable ``z + log1p(exp(-z))`` branch."""
if z >= 0.0:
return float(z + math.log1p(math.exp(-z)))
return float(math.log1p(math.exp(z)))worked_example
omnibias.core.ftc.worked_exampleSource ↗worked_example() -> dict[str, float]Spec 09-03 / 09-17 numbers at x=0, delta=0.2.
dict[str, float]Executed regression · g1 matches core
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_g1_matches_core() -> None:
x = jnp.asarray(0.0)
w = jnp.asarray(1.0)
lo = jnp.asarray(-0.1)
hi = jnp.asarray(0.1)
integral, deriv, collapse = ftc_block(x, w, lo, hi)
ex = worked_example()
assert float(integral) == ex["I"]
assert float(deriv) == ex["dI"]
assert float(collapse) == ex["collapse"]
assert FTCNet(FTCNetConfig()).config.window == 0.6python -m pytest "packages/omnibias-jax/tests/test_ftc_net.py::test_g1_matches_core" -qRegression example · g1 worked example
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_g1_worked_example() -> None:
ex = worked_example()
assert ex["collapse_err"] < 1e-12
assert ex["ftc_err"] < 1e-12
assert abs(ex["I"] - 0.1) < 1e-12
integral, deriv, collapse = ftc_block(0.0, 1.0, -0.1, 0.1)
loss = dual_ftc_loss([integral], [deriv], [deriv], [0.0], I_a=integral)
assert loss.max_r_D < 1e-12
assert loss.max_r_I < 1e-12
loss0 = dual_ftc_loss([integral], [deriv], [0.0], [0.0], I_a=integral)
assert loss0.max_r_D > 0.04python -m pytest packages/omnibias-core/tests/test_ftc.py -k test_g1_worked_example -qRead the implementation
def worked_example() -> dict[str, float]:
"""Spec 09-03 / 09-17 numbers at ``x=0``, ``delta=0.2``."""
integral, deriv, collapse = ftc_block(0.0, 1.0, -0.1, 0.1)
sig_hi = sigmoid(0.1)
sig_lo = sigmoid(-0.1)
return {
"I": integral,
"dI": deriv,
"collapse": collapse,
"sigmoid_0": sigmoid(0.0),
"ftc_band": sig_hi - sig_lo,
"collapse_err": abs(collapse - sigmoid(0.0)),
"ftc_err": abs(deriv - (sig_hi - sig_lo)),
}Other public import paths
omnibias.core.ftc.worked_exampleomnibias.jax.architectures.ftc_net.worked_exampleomnibias.torch.architectures.ftc_net.worked_example