Skip to main content

omnibias.torch.architectures.integral_kernel

0.5.0rc1Release candidatePython >=3.10Apache-2.0

PyTorch activation derivatives, trainable operator layers, network jets, and direct differential-operator contractions.

import omnibias.torch.architectures.integral_kernel
Module contract & mathematical conventions

Integral-kernel operator (torch; theory 09-14).

The kernel cell is the OMBU integral role. founding bias collapse (delta -> 0) of the window is not the default. Temperature collapse (beta -> inf, feasibility) does not appear. do not conflate the two.

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.

Imports & aliases​

These names share a definition with another public module. Follow a name for its full contract, parameters, and examples.

Import from this moduleCanonical reference
DISCLAIMERomnibias.core.integral_kernel.DISCLAIMER
IntegralKernelConfigomnibias.core.integral_kernel.IntegralKernelConfig
honesty_payloadomnibias.core.integral_kernel.honesty_payload
FUNCTION

integral_cell​

omnibias.torch.architectures.integral_kernel.integral_cellSource ↗
integral_cell(z: Tensor, b_lo: float, b_hi: float) -> Tensor

S(z + b_hi) - S(z + b_lo). Matches OperatorBlock(op='integral').

Parameters

NameType & defaultContract
zpositional-or-keywordTensorRequiredSee the operation contract and implementation below.
b_lopositional-or-keywordfloatRequiredSee the operation contract and implementation below.
b_hipositional-or-keywordfloatRequiredSee the operation contract and implementation below.
ReturnsTensor
Executed regression · g1 matches operator block

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_operator_block() -> None:
    torch.set_default_dtype(torch.float64)
    ex = worked_example()
    assert ex["g1_err"] < 1e-12
    block = OperatorBlock(op="integral", base="sigmoid", channels=1, init_delta=1.0).double()
    z = torch.tensor([[0.5]])
    out = float(block(z).detach().reshape(-1)[0])
    cell = float(integral_cell(z.reshape(-1), -0.5, 0.5).detach()[0])
    assert abs(out - cell) < 1e-12
    assert abs(out - core_cell(0.5, -0.5, 0.5)) < 1e-12
python -m pytest "packages/omnibias-torch/tests/test_integral_kernel.py::test_g1_matches_operator_block" -q
Regression example · g4 bit identical

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_g4_bit_identical() -> None:
    torch.set_default_dtype(torch.float64)
    assert torch_ex()["g1_cell"] == jax_ex()["g1_cell"]
    t = float(torch_cell(torch.tensor([0.5]), -0.5, 0.5)[0])
    j = float(jax_cell(jnp.asarray([0.5]), -0.5, 0.5)[0])
    assert t == j
python -m pytest tests/test_integral_kernel_parity.py -k test_g4_bit_identical -q
Read the implementation
def integral_cell(z: Tensor, b_lo: float, b_hi: float) -> Tensor:
    """``S(z + b_hi) - S(z + b_lo)``. Matches ``OperatorBlock(op='integral')``."""
    vals = [core.integral_cell(float(v), b_lo, b_hi) for v in z.reshape(-1).tolist()]
    return z.new_tensor(vals).reshape(z.shape)
FUNCTION

integral_kernel_apply​

omnibias.torch.architectures.integral_kernel_applySource ↗
integral_kernel_apply(source: Tensor, coords: Tensor, params: Sequence[float] | None=None, *, config: IntegralKernelConfig | None=None, nodes: Tensor | None=None) -> Tensor

Volumetric apply. Not BEM-Net.

Parameters

NameType & defaultContract
sourcepositional-or-keywordTensorRequiredSee the operation contract and implementation below.
coordspositional-or-keywordTensorRequiredSee the operation contract and implementation below.
paramspositional-or-keywordSequence[float] | NoneDefault: NoneSee the operation contract and implementation below.
configkeyword-onlyIntegralKernelConfig | NoneDefault: NoneSee the operation contract and implementation below.
nodeskeyword-onlyTensor | NoneDefault: NoneSee the operation contract and implementation below.
ReturnsTensor
Read the implementation
def integral_kernel_apply(
    source: Tensor,
    coords: Tensor,
    params: Sequence[float] | None = None,
    *,
    config: IntegralKernelConfig | None = None,
    nodes: Tensor | None = None,
) -> Tensor:
    """Volumetric apply. Not BEM-Net."""
    src = [float(v) for v in source.reshape(-1).tolist()]
    xs = [float(v) for v in coords.reshape(-1).tolist()]
    ys = [float(v) for v in nodes.reshape(-1).tolist()] if nodes is not None else None
    out = core.integral_kernel_apply(src, xs, params, config=config, nodes=ys)
    return coords.new_tensor(out)
Other public import paths
  • omnibias.torch.architectures.integral_kernel_apply
  • omnibias.torch.architectures.integral_kernel.integral_kernel_apply
FUNCTION

worked_example​

omnibias.torch.architectures.integral_kernel.worked_exampleSource ↗
worked_example() -> dict[str, float]

The module contract describes the context for this operation. Its signature, explicit validation, return expressions, and implementation are recorded below.

Returnsdict[str, float]
Executed regression · g1 matches operator block

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_operator_block() -> None:
    torch.set_default_dtype(torch.float64)
    ex = worked_example()
    assert ex["g1_err"] < 1e-12
    block = OperatorBlock(op="integral", base="sigmoid", channels=1, init_delta=1.0).double()
    z = torch.tensor([[0.5]])
    out = float(block(z).detach().reshape(-1)[0])
    cell = float(integral_cell(z.reshape(-1), -0.5, 0.5).detach()[0])
    assert abs(out - cell) < 1e-12
    assert abs(out - core_cell(0.5, -0.5, 0.5)) < 1e-12
python -m pytest "packages/omnibias-torch/tests/test_integral_kernel.py::test_g1_matches_operator_block" -q
Regression example · g4 bit identical

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_g4_bit_identical() -> None:
    torch.set_default_dtype(torch.float64)
    assert torch_ex()["g1_cell"] == jax_ex()["g1_cell"]
    t = float(torch_cell(torch.tensor([0.5]), -0.5, 0.5)[0])
    j = float(jax_cell(jnp.asarray([0.5]), -0.5, 0.5)[0])
    assert t == j
python -m pytest tests/test_integral_kernel_parity.py -k test_g4_bit_identical -q
Read the implementation
def worked_example() -> dict[str, float]:
    return core.worked_example()