Python API

Core, runtime, and cryptography

The Python-visible matrix, execution, hashing, signing, and post-quantum surface.

Generated from Source/Python71 functions11 classes2 enums
This inventory is generated from symbols registered by OA's nanobind source and public Python facade. It deliberately excludes unbound C++ internals. Signatures show the Python keyword names declared by each binding; follow the source link for ownership, capability, and execution details.

oa.core

Functions

Add(a, b)
Source
AddScalar(a, scalar)
Source
Argmax(a, dim)
Source
Cast(a, dtype)
Source
CausalMask(seq_len)CausalMask(scores)
Source
CopyToHost(mat)
Source

Copy device matrix to host as a list (dtype-aware: uint8 or float32)

CopyToHost2D(mat, rows, cols)
Source

Copy device matrix to host as a 2D list of float32 values

Detach(a)
Source
Div(a, b)
Source
DivScalar(a, scalar)
Source
Empty(shape, dtype)
Source
Exp(a)
Source
FromBytes(data, shape, dtype)FromBytes(data, d0, d1, dtype)FromBytes(data, d0, dtype)
Source

Create matrix from host byte data

FromFloats(data, shape)FromFloats(data, d0, d1)FromFloats(data, d0)
Source

Create a Float32 matrix from host float data

FromInt32(data, shape, dtype)
Source

Create matrix from host int32 data

Full(shape, value, dtype)Full(d0, d1, value, dtype)
Source
Gather(a, indices)
Source
GatherBwd(indices, grad_output, vocab_size, embed_dim)
Source
Gelu(a)
Source
GeluBwd(input, grad_output)
Source
GetWeightDtype()
Source

Get the current weight dtype (Float32, BFloat16, or Float16)

LinearDataBwd(grad_output, weight)
Source
LinearWeightBiasBwd(input, grad_output)
Source
Log(a)
Source
LogSoftmax(a, dim)
Source
MatMulNt(a, b, precision)
Source

Matrix multiplication: C = A @ B^T (weight convention). B is stored transposed as [N,K]. For standard A@B use Bmm.

Max(a, dim)
Source
Mean(a, dim)
Source
Mul(a, b)
Source
Ones(shape, dtype)Ones(d0, d1, dtype)
Source
Pow(a, exponent)
Source
Rand(shape, dtype)Rand(d0, d1, dtype)
Source
RandGlorotUniform(shape, dtype)RandGlorotUniform(d0, d1, dtype)
Source
RandKaimingUniform(shape, dtype)RandKaimingUniform(d0, d1, dtype)
Source
RandN(shape, dtype)RandN(d0, d1, dtype)
Source
RandXavier(shape, dtype)RandXavier(d0, d1, dtype)
Source
Relu(a)
Source
ReluBwd(forward_output, grad_output)
Source
Reshape(a, shape)Reshape(a, d0, d1)Reshape(a, d0)
Source
Scalar(mat)
Source
Scale(a, scalar)
Source
SetRngSeed(seed)
Source
SetWeightDtype(dtype)
Source

Set the weight dtype for new weight tensors

Sigmoid(a)
Source
Silu(a)
Source
SiluBwd(input, grad_output)
Source
Slice(a, dim, start, end)
Source
Softmax(a, dim)
Source
SoftmaxBwd(forward_output, grad_output)
Source
Sqrt(a)
Source
Sub(a, b)
Source
SubScalar(a, scalar)
Source
Sum(a, dim)
Source
Tanh(a)
Source
TanhBwd(forward_output, grad_output)
Source
Transpose(a, dim0, dim1)
Source
Zeros(shape, dtype)Zeros(d0, d1, dtype)
Source

Classes

OaLinearWeightBiasBwdResult2 members
GradWeight(...)
ro
GradBias(...)
ro
Source
OaMatrix30 members
Rank(...)

Get tensor rank

method
NumElements(...)

Get total number of elements

method
ByteSize(...)

Get total byte size

method
Size(...)

Get size of dimension

method
Shape(...)
method
Dtype(...)
method
IsEmpty(...)
method
Clone(...)
method
Reshape(shape)
method
Flatten(...)
method
Unsqueeze(dim)
method
Squeeze(dim)
method
Transpose(dim0, dim1)
method
Contiguous(...)
method
Item(...)
method
At(index)
method
Set(index, value)
method
Zero(...)
method
RequiresGrad(...)
method
SetRequiresGrad(...)
method
GradMatrix(...)

Get persistent gradient accumulator

method
MutGradMatrix(...)

Get mutable persistent gradient accumulator

method
AccumulateGrad(contribution)

Accumulate gradient: grad += contribution

method
ZeroGrad(...)

Zero gradient: grad = 0

method
IsLeaf(...)

Check if tensor is a leaf (no grad_fn)

method
HasGradFn(...)

Check if tensor has a gradient function attached

method
__add__(...)
method
__sub__(...)
method
__mul__(...)
method
__truediv__(...)
method
Source
OaMatrixShape6 members
__init__(dims)
method
__getitem__(...)
method
__setitem__(...)
method
NumElements(...)
method
Dims(...)
method
Rank(...)
prop_ro
Source

Enums

OaContextMatMulPrecisionSource

Auto · Fp32 · Bf16

OaScalarTypeSource

Float32 · Float16 · BFloat16 · Float64 · Int32 · Int16 · Int64 · Int8 · UInt8 · UInt16 · UInt32 · UInt64 · Bool · Complex64 · Complex128 · Q4_0 · Q4_1 · Q5_0 · Q5_1 · Q8_0 · Q8_1 · Q2_K · Q3_K · Q4_K · Q5_K · Q6_K · Q8_K

oa.runtime

Functions

OaContext_GetDefault()
Source

Get the thread-local default context

OaInitComputeEngine()
Source

Initialize OA compute engine and default context. Must be called before any GPU operations.

OaShutdownComputeEngine()
Source

Shutdown OA compute engine and release resources.

Classes

Context0 members

Execute and synchronize the default OA context on scope exit.

Source
OaContext2 members
Execute(...)

Execute all recorded GPU operations

method
Sync(...)

Synchronize (wait for GPU completion)

method
Source

oa.crypto

Functions

GenerateKeypair()
Source

Generate a random ML-DSA-65 keypair.

KeccakF1600(states)
Source

Batch Keccak-f[1600] permutation over a [N, 200] u8 state matrix.

Kmac256Bytes(key, data, custom, out_len)
Source

KMAC-256 keyed hash (NIST SP 800-185).

MerkleRoot(leaves)
Source

GPU Merkle root of [N, 32] leaves (N a power of two) → [1, 32].

MerkleRootHashes(leaves)
Source

CPU Merkle root over a list of OaHash leaves.

Shake128(messages, out_len)
Source

Batch SHAKE-128 over rows of a [N, MsgLen] u8 matrix.

Shake128Bytes(data, out_len)
Source

One-shot SHAKE-128 over bytes → bytes.

Shake256(messages, out_len)
Source

Batch SHAKE-256 over rows of a [N, MsgLen] u8 matrix → [N, ceil(out/8)*8].

Shake256Bytes(data, out_len)
Source

One-shot SHAKE-256 over bytes → bytes.

Sign(data, secret)
Source

Sign a message with an ML-DSA-65 secret key.

Verify(data, signature, pubkey)
Source

Verify an ML-DSA-65 signature. Returns False for any tampered input.

Classes

OaHash9 members
__init__(data)

Construct from exactly 32 raw bytes.

method
FromHex(hex)

Parse exactly 64 hexadecimal characters.

static
Zero(...)
static
ToHex(...)
method
ToShortHex(...)
method
IsZero(...)
method
bytes(...)

The 32 digest bytes.

method
__eq__(...)
method
__repr__(...)
method
Source
OaHasher4 members
__init__(...)
constructor
Update(data)

Absorb more bytes (call repeatedly before Finalize).

method
Finalize(...)

Squeeze the 32-byte digest.

method
Reset(...)
method
Source
OaKeypair2 members
Pubkey(...)
prop_ro
Secret(...)
prop_ro
Source
OaPublicKey4 members
__init__(data)
method
bytes(...)

The 1952 public-key bytes.

method
ToShortHex(...)
method
__eq__(...)
method
Source
OaSecretKey0 members
OaSignature3 members
__init__(data)
method
bytes(...)

The 3309 signature bytes.

method
ToShortHex(...)
method
Source