Python API
Core, runtime, and cryptography
The Python-visible matrix, execution, hashing, signing, and post-quantum surface.
oa.core
Functions
Add(a, b)AddScalar(a, scalar)Argmax(a, dim)Cast(a, dtype)CausalMask(seq_len)CausalMask(scores)CopyToHost(mat)Copy device matrix to host as a list (dtype-aware: uint8 or float32)
CopyToHost2D(mat, rows, cols)Copy device matrix to host as a 2D list of float32 values
Detach(a)Div(a, b)DivScalar(a, scalar)Empty(shape, dtype)Exp(a)FromBytes(data, shape, dtype)FromBytes(data, d0, d1, dtype)FromBytes(data, d0, dtype)Create matrix from host byte data
FromFloats(data, shape)FromFloats(data, d0, d1)FromFloats(data, d0)Create a Float32 matrix from host float data
FromInt32(data, shape, dtype)Create matrix from host int32 data
Full(shape, value, dtype)Full(d0, d1, value, dtype)Gather(a, indices)GatherBwd(indices, grad_output, vocab_size, embed_dim)Gelu(a)GeluBwd(input, grad_output)GetWeightDtype()Get the current weight dtype (Float32, BFloat16, or Float16)
LinearDataBwd(grad_output, weight)LinearWeightBiasBwd(input, grad_output)Log(a)LogSoftmax(a, dim)MatMulNt(a, b, precision)Matrix multiplication: C = A @ B^T (weight convention). B is stored transposed as [N,K]. For standard A@B use Bmm.
Max(a, dim)Mean(a, dim)Mul(a, b)Ones(shape, dtype)Ones(d0, d1, dtype)Pow(a, exponent)Rand(shape, dtype)Rand(d0, d1, dtype)RandGlorotUniform(shape, dtype)RandGlorotUniform(d0, d1, dtype)RandKaimingUniform(shape, dtype)RandKaimingUniform(d0, d1, dtype)RandN(shape, dtype)RandN(d0, d1, dtype)RandXavier(shape, dtype)RandXavier(d0, d1, dtype)Relu(a)ReluBwd(forward_output, grad_output)Reshape(a, shape)Reshape(a, d0, d1)Reshape(a, d0)Scalar(mat)Scale(a, scalar)SetRngSeed(seed)SetWeightDtype(dtype)Set the weight dtype for new weight tensors
Sigmoid(a)Silu(a)SiluBwd(input, grad_output)Slice(a, dim, start, end)Softmax(a, dim)SoftmaxBwd(forward_output, grad_output)Sqrt(a)Sub(a, b)SubScalar(a, scalar)Sum(a, dim)Tanh(a)TanhBwd(forward_output, grad_output)Transpose(a, dim0, dim1)Zeros(shape, dtype)Zeros(d0, d1, dtype)Classes
OaLinearWeightBiasBwdResult2 members
GradWeight(...)GradBias(...)OaMatrix30 members
Rank(...)Get tensor rank
NumElements(...)Get total number of elements
ByteSize(...)Get total byte size
Size(...)Get size of dimension
Shape(...)Dtype(...)IsEmpty(...)Clone(...)Reshape(shape)Flatten(...)Unsqueeze(dim)Squeeze(dim)Transpose(dim0, dim1)Contiguous(...)Item(...)At(index)Set(index, value)Zero(...)RequiresGrad(...)SetRequiresGrad(...)GradMatrix(...)Get persistent gradient accumulator
MutGradMatrix(...)Get mutable persistent gradient accumulator
AccumulateGrad(contribution)Accumulate gradient: grad += contribution
ZeroGrad(...)Zero gradient: grad = 0
IsLeaf(...)Check if tensor is a leaf (no grad_fn)
HasGradFn(...)Check if tensor has a gradient function attached
__add__(...)__sub__(...)__mul__(...)__truediv__(...)OaMatrixShape6 members
__init__(dims)__getitem__(...)__setitem__(...)NumElements(...)Dims(...)Rank(...)Enums
oa.runtime
Functions
OaContext_GetDefault()Get the thread-local default context
OaInitComputeEngine()Initialize OA compute engine and default context. Must be called before any GPU operations.
OaShutdownComputeEngine()Shutdown OA compute engine and release resources.
Classes
oa.crypto
Functions
GenerateKeypair()Generate a random ML-DSA-65 keypair.
KeccakF1600(states)Batch Keccak-f[1600] permutation over a [N, 200] u8 state matrix.
Kmac256Bytes(key, data, custom, out_len)KMAC-256 keyed hash (NIST SP 800-185).
MerkleRoot(leaves)GPU Merkle root of [N, 32] leaves (N a power of two) → [1, 32].
MerkleRootHashes(leaves)CPU Merkle root over a list of OaHash leaves.
Shake128(messages, out_len)Batch SHAKE-128 over rows of a [N, MsgLen] u8 matrix.
Shake128Bytes(data, out_len)One-shot SHAKE-128 over bytes → bytes.
Shake256(messages, out_len)Batch SHAKE-256 over rows of a [N, MsgLen] u8 matrix → [N, ceil(out/8)*8].
Shake256Bytes(data, out_len)One-shot SHAKE-256 over bytes → bytes.
Sign(data, secret)Sign a message with an ML-DSA-65 secret key.
Verify(data, signature, pubkey)Verify an ML-DSA-65 signature. Returns False for any tampered input.
Classes
OaHash9 members
__init__(data)Construct from exactly 32 raw bytes.
FromHex(hex)Parse exactly 64 hexadecimal characters.
Zero(...)ToHex(...)ToShortHex(...)IsZero(...)bytes(...)The 32 digest bytes.
__eq__(...)__repr__(...)OaHasher4 members
__init__(...)Update(data)Absorb more bytes (call repeatedly before Finalize).
Finalize(...)Squeeze the 32-byte digest.
Reset(...)OaKeypair2 members
Pubkey(...)Secret(...)OaPublicKey4 members
__init__(data)bytes(...)The 1952 public-key bytes.
ToShortHex(...)__eq__(...)OaSecretKey0 members
OaSignature3 members
__init__(data)bytes(...)The 3309 signature bytes.
ToShortHex(...)