API

Machine learning

Root modules, optimizers, training values, and the FnAutograd, FnLoss, FnMetric, and FnRl operation families.

Compiler-extracted public headersNative C++ surface35 functions192 classes23 enums0 constants & variables
This inventory is extracted from OA public headers by clang-doc. Native types, pointers, references, defaults, public inheritance, comments and source ownership come from the compiler surface.

Examples

Ml

Functions

Classes

2 members

environment-neutral discrete actor/critic contract. Custom policies only need to implement evaluate; PPO collection, loss construction and updates do not depend on the concrete network architecture.

Inherits public Module

Source
1 members
8 members

─── Adam ────────────────────────────────────────────────────────────────────

Inherits public Optimizer

Source
9 members

─── AdamW ─────────────────────────────────────────────────────────────────── Decoupled weight decay — preferred for transformers.

Inherits public Optimizer

Source
2 members
2 members
2 members
0 members
9 members

─── BpeTokenizer ──────────────────────────────────────────────────────────── Learns byte pair merges to build vocabulary from 256 base bytes to target size. Useful for compressing sequences and improving model efficiency.

Persist/load the learned merge ranks. The format is deterministic and architecture-independent so a training checkpoint can ship its text vocab.

method
Source
3 members

BYTE EMBEDDING - The 256-entry lookup table Maps each byte value (0-255) to a d_model dimensional vector. input: [batch, seq_len] of UInt8 output: [batch, seq_len, d_model] of Float32 This replaces the massive 30k-100k token embedding tables in GPT/LLaMA. Ours is always 256 x d_model. Tiny. Fast. Universal.

Inherits public Module

Source
8 members

BYTE ENCODER - Raw bytes to tensor and back

Source
2 members

BYTE OUTPUT HEAD - convert hidden states back to byte probabilities input: [batch, seq_len, d_model] output: [batch, seq_len, 256] (logits over byte values)

Inherits public Module

Source
3 members
0 members
6 members

─── oa::CbCheckpoint ─────────────────────────────────────────────────────── keras modelCheckpoint(save_freq="epoch") + EarlyStopping's restore_best_weights, on top of oa::CheckpointManager. Every epoch end writes a resumable rotating checkpoint. Pass SaveEvery > 0 to add mid-epoch checkpoints every N completed optimizer steps. The master model is updated only on improvement. at each epoch end it prints a TF-style mini summary: epoch 3: cross_entropy improved from 0.4056 to 0.3486 — saving model epoch 4: cross_entropy did not improve from 0.3486 at train end, if RestoreBest is set and the best epoch wasn't the last one, the best checkpoint is loaded back into model + optimizer — you always walk away with the best weights, not whatever the final (possibly degraded) epoch produced. Monitored value: inMetric->result() when provided (e.g. a val_loss metric), otherwise the epoch mean train loss. Better/worse direction comes from the manager's lowerIsBetter config.

Inherits public CbTraining · public Callback

Source
6 members
3 members
2 members

─── oa::LrSchedulerCallback ──────────────────────────────────────────────── Applies any oa::LRScheduler to the optimizer at each step. Use oa::CosineScheduler, oa::OneCycleScheduler, oa::WarmupScheduler, etc. from <oa /ml/optim.h>.

Inherits public CbTraining · public Callback

Source
5 members

─── oa::CbPhase ───────────────────────────────────────────────────────────── Multi-phase training callback. phases are consecutive ranges of epochs — build the iterator with oa::ItTrainingConfig::epochSteps so epoch boundaries follow the phase schedule, then register one addPhase() per phase in order. Prints a schedule preview at train begin and a phase banner + phase-relative epoch headers (disable the progress bar's own header via SetShowEpochHeader): phase schedule: 1. warmup — 1 epoch (2000 steps) 2. main — 10 epochs (20000 steps) phase 1/2 — warmup · 1 epoch × 2000 steps epoch 1/1 2000/2000 |██████████| ... The OnPhaseBegin hook fires on entering each phase (including the first) — use it to swap LR schedulers, change datasets, etc.

Inherits public CbTraining · public Callback

Source
8 members

─── oa::CbProgressBar ────────────────────────────────────────────────────── tqdm/keras-hybrid progress bar with `█`+`░` and rolling metrics: epoch 1/5 938/938 |██████████| 0.65s · 0.7 ms/step · 1.26M sample/s · accuracy: 0.9091 · loss: 0.2914 epoch 2/5 938/938 |██████████| 0.59s · 0.6 ms/step · 1.31M sample/s · accuracy: 0.9134 · loss: 0.1822 mid-epoch: 468/938 |█████░░░░░| 0.32s · 0.7 ms/step · 1.25M sample/s · loss: 0.3128 Per-step updates rewrite the same line via ` `; epoch end leaves the final line and starts a new one. Uses lastLoss() so per- step refresh never forces a Sync. Accuracy comes from recordAccuracy(); if the caller hasn't set it (NaN), the field is omitted. Wall time per step and workload throughput are shown instead of GPU time. Latency and rates are derived from the iterator's single workload definition; they are not metrics that callers must register separately.

Inherits public CbTraining · public Callback

Source
4 members

─── oa::CbSummary ───────────────────────────────────────────────────────── Prints a final training summary at onTrainEnd: loss, wall latency/throughput, GPU mean/p50/p95, the wall-to-GPU timing gap, and total duration. Optionally tracks initial loss for comparison. example output: summary: loss: initial 2.6558 · final 0.2965 · mean 0.4812 Wall: 0.07 ms/step · 943.68K sample/s · 60.40M token/s GPU: mean 0.051 ms/step · p50 0.049 · p95 0.061 · 1.26M sample/s run: 0.32s · 4686 steps · batch 64 · sequence 64 token/sample

Inherits public CbTraining · public Callback

Source
7 members
8 members
0 members
11 members

save model + optimizer state if the metric improved (or unconditionally if inForce=true). Saves weights AND optimizer state (AdamW M/V/step, etc.) into one .oam via Module::save(engine, path, opt).

method
Source
0 members

CheckpointManager — auto-save best models with rotation. Wraps Module::save/load to manage directory structure, path naming, metric tracking, and incremental-checkpoint rotation.

Source
1 members

Diagonal Gaussian transformed through tanh into a bounded action interval. rawAction is retained because it is the numerically stable carrier for PPO re-evaluation; action is the value passed to the environment.

Source
5 members
0 members
2 members
0 members
2 members
2 members
0 members
2 members

─── CosineScheduler ───────────────────────────────────────────────────────── Cosine annealing from maxLr to minLr over totalSteps.

Inherits public LRScheduler

Source
2 members

─── CosineWarmRestartsScheduler ───────────────────────────────────────────── SGDR: cosine annealing with periodic warm restarts. Period starts at t0 steps, multiplied by tMult after each restart.

Inherits public LRScheduler

Source
2 members
0 members
1 members
10 members

Environment-neutral DQN update coordinator over caller-owned online and target modules, optimizer, and replay storage. It composes `ItTraining` for the exact optimizer lifecycle; it does not inherit a nominal trainer base.

Source
0 members
0 members
2 members
4 members
8 members

EmpyrealmCore — empyrealm-style sequential modeling core. high-utilization reusable backbone: input projection (byte embed or custom) → mixer + flat per-token residual → mixed features [B*seq, dModel]. The mixer is EmpyrealmModule, which dispatches empyrealm* kernels (EmpyrealmDt, EmpyrealmAdt, EmpyrealmSiso) — renamed copies of the Mamba3* kernels with identical SPIR-V today, ready for future architecture-specific divergence. shader layout (for fusion / branding): Ssm/Mamba3/ — original Mamba3Siso* (untouched reference, used by Mamba3Module) Ssm/empyrealm/ — ported/copied starting point; will host fused empyrealm* variants (e.g. custom one-node mixers) while Mamba3 stays pristine. The reconstruction tutorial demonstrates the intended usage. Brand Mamba3 tech as empyrealm for custom evolution.

Inherits public Module

method
Source
0 members

tag type selecting the embedded-only EmpyrealmCore constructor (no embed module is created or registered; the caller drives the mixer via ForwardEmbedded with its own [B, S, D] features). Disambiguates from the byte ctor, whose two leading ints would otherwise collide.

Source
17 members

Stateful native environment session. The session borrows one Engine and privately owns its recorder/execution state. reset/step remain stateful commands; submit returns the exact completion for every command recorded since the previous completion. The public boundary never exposes context or queue controls.

begin is idempotent while recording. recordCommands selects the owned execution session only for the callback's dynamic extent, so ambient context state is restored even on failure. A callback failure cancels the whole unsubmitted transaction.

method

cancel discards only unsubmitted commands. close completes an already submitted event, discards unsubmitted commands, and is idempotent.

method

True after begin or the first recorded command and until submit accepts the transaction or cancel discards it. Host snapshots must reject this state because recorded writes have not reached the device.

method
Source
7 members
ScalarType
EnvironmentSpaceKind
String
MatrixShape
Source
4 members
1 members
8 members
0 members
Matrix
Matrix
Matrix
Source
2 members
7 members
0 members

Modality-independent flow denoiser. Image patches and motion frames use the same token contract; callers choose inputDim, sequence length and optional condition features. numExperts selects dense or shared dropless-MoE FFNs.

Source
0 members

Linear flow-matching state and its constant path velocity. Both matrices remain on the active OA device and participate in the normal autograd graph.

Source
5 members
10 members

Reusable bidirectional Transformer backbone for flow/diffusion denoisers. input is conditioned token state [B,S,D] or flattened [B*S,D]; output keeps the same shape. This is a sibling model family that composes generic Transformer blocks; it is not part of the generic Transformer itself.

Inherits public Module

Source
0 members

Configuration for a bidirectional denoising Transformer. numExperts == 0 selects an ordinary dense FFN; a positive value selects the shared dropless MoE implementation without changing the model's input/output contract.

Source
0 members
1 members
2 members
0 members
5 members
2 members

oa::GradNo — RAII scope guard that disables autograd for its lifetime.

Source
7 members
8 members

Inherits public Module

Source
0 members
0 members
0 members
2 members
16 members

Coordinates the two-phase lifecycle of synchronous on-policy training. Environment stepping, policy evaluation, and loss construction remain caller supplied; an owned `ItTraining` controls each exact optimizer update.

Restores the pre-beginRollout collect state after the caller cancels the unsubmitted command transaction. This is also valid after finalizeRollout and before the first update begins.

method

Must be called immediately before recording one differentiable PPO update. It advances the underlying ItTraining lifecycle and returns false only on invalid phase/configuration or after completion.

method

Completes the update recorded after beginUpdate: optimizer, submit, sync, metrics and phase advancement.

method
Source
0 members
60 members

Inherits public Iterator

─── callbacks ────────────────────────────────────────────────────────

method

─── oa::Iterator interface ─────────────────────────────────────────────

method

─── training step (lambda sugar) ─────────────────────────────────────

method

─── State ────────────────────────────────────────────────────────────

method
Source
0 members
2 members
0 members
3 members
2 members

─── LinearWarmupCosineScheduler ───────────────────────────────────────────── Convenience scheduler: linear warmup to targetLr, then cosine annealing to minLr. Composes WarmupScheduler + CosineScheduler.

Inherits public LRScheduler

Source
0 members

--- ML result structs (domain types, not bound to FnMatrix) ---

Source
3 members

─── LRScheduler (base) ──────────────────────────────────────────────────────

Source
22 members

Mamba3Module — Mamba-3 selective state space model block Reference: Mamba-3 paper (https://arxiv.org/abs/2603.15569) Based on: https://github.com/state-spaces/mamba (mamba_ssm/modules/mamba3.py)

Inherits public Module

weight accessors for the fused empyrealm path (reuses the same weights as the reference Mamba3Module).

method

Config accessors for EmpyrealmCore / general use (no more hardcodes in callers).

method
method

Autoregressive single-step for inference (maintains recurrent state across calls).

method
Source
2 members
0 members
0 members
8 members

─── Metric ────────────────────────────────────────────────────────────────── base class for all metrics. Follows the keras pattern: - update(): add a new batch of predictions/labels - reset(): clear accumulated state - result(): get the current metric value

Source
7 members
13 members

─── MetricLoss ──────────────────────────────────────────────────────────────

Inherits public Metric

Source
3 members
14 members

A complete OA model file loaded in memory. `ModelFile` owns model configuration, named weights, persistent state, optimizer state, and training progress. `load()` and `save()` implement the native `.oam` wire format. External formats are imported by `oa::ModelTranslator`; they are not alternative representations of this type.

Produce a weight-only inference artifact. Dense Float32 tensors with rank >= 2 become native OA Q4/Q8 blocks; scalar/vector weights and all state remain dense. Optimizer state is deliberately removed.

method
Source
0 members

Generic config — universal fields that every architecture has. architecture-specific config follows immediately after (archConfigSize bytes).

Source
0 members
0 members
0 members
0 members
0 members
3 members
29 members

oa::Module — base class for all neural network modules.

method

persistent/non-trainable state. buffers never receive gradients and never participate in optimizer parameter traversal or numParameters().

method

Parameter management WARNING: parameters() returns ONLY direct parameters (non-recursive), unlike PyTorch's .parameters(). For nested modules use allParameterPtrs() instead. FOOTGUN: module->parameters()[0] on a nested module is OOB. Always check .size() first or use allParameterPtrs().

method

Persistence — non-virtual generic tree walks. Builds dotted parameter paths from registerModule/registerParameter names (e.g. "fc1.weight"). arch-specific loaders (SafeTensors, sharded LLM weights) live as separate helper fns that write into an already-constructed module. Optimizer overloads bundle state into the same .oam file so resume training is one call per side.

method

training mode — propagates to every registered child. eval() is equivalent to train(false). Newly registered children inherit the parent's current mode.

method
Source
0 members

oa::ModuleBuffer — persistent/non-trainable buffer registered on a module.

Source
20 members

Inherits public Module

── route telemetry (read after execute+Sync) ──────────────────────────────

method

── Optional differentiable balancing losses (opt-in, default off) ───────── Switch/GShard aux loss α·E·Σ_e f_e·p_e (f = hard load fraction, constant; P = mean router prob, differentiable) plus router z-loss β·mean(LSE²). Add auxLoss() to the task loss before backward. Both coefficients 0 ⇒ auxLoss() is a 0 scalar recorded on the tape with no gradient effect.

method

── Aux-loss-free load balancing (DeepSeek-V3) ───────────────────────────── A per-expert bias added to the routing logits for the top-k SELECTION decision only (never into the gate magnitude, so it does not distort the weighted combine and produces no gradient). After each optimizer step, call updateRoutingBias() to nudge under-loaded experts up and over-loaded ones down. The update and next forward remain in the deferred GPU graph.

method
Source
0 members

route-utilization telemetry from the last forward. Read after execute+Sync, exactly like lastSelectionMask(). This is the instrument that makes expert collapse observable — with no balancing, a MoE can silently route everything to one expert (harmless while the oracle runs every expert densely, fatal the moment the sparse executor lands).

Source
11 members

MultiHeadAttention: Multi-head scaled dot-product self-attention with explicit causal/bidirectional visibility and interchangeable standard/fused causal Flash backends.

Inherits public Module

Source
8 members

─── Muon ──────────────────────────────────────────────────────────────────── GPU momentum + Newton-Schulz5 orthogonalization optimizer. https://github.com/KellerJordan/Muon + https://arxiv.org/abs/2502.16982 Rank-2 parameters use the orthogonalized Muon update. Other ranks use the optimizer's fused GPU momentum update. Muon owns exactly the parameter set supplied by the caller and never delegates to another optimizer.

Inherits public Optimizer

Source
0 members

Sub-modules

SharedPtr
String
Source
0 members

Dotted module path + parameter pointer (e.g. "blocks.0.gate.weight").

Parameter *
String
Source
8 members

Ready-to-train causal language model: token + position embeddings, a stack of Transformer blocks, final normalization, and vocabulary projection. Input token ids are [batch, contextLength]; logits are [batch*contextLength, vocabSize] for all-position next-token training.

Inherits public Module

Source
2 members

─── OneCycleScheduler ─────────────────────────────────────────────────────── Smith's 1cycle policy: warmup ramp to maxLr, then cosine anneal to near-zero. initialLr = maxLr/divFactor. finalLr = initialLr/finalDivFactor.

Inherits public LRScheduler

Source
11 members

─── base Optimizer ──────────────────────────────────────────────────────────

A compiled training program executes the already-recorded optimizer kernels without calling step() again. Keep the host-visible logical step aligned so schedules and checkpoints observe the same state as eager execution.

method

Persistence — write/read optimizer state (moments, step count, hyperparams) into a ModelFile section. Default no-op so SGD/Adam compile until they implement.

method

apply accumulated gradients to parameters.

method
Source
0 members
3 members

─── No-op optimizer ───────────────────────────────────────────────────────── For callers that pass an Optimizer & but update params themselves (e.g. hand-rolled training tutorials using ItTraining purely for cadence + callbacks).

Inherits public Optimizer

Source
2 members

oa::Parameter — named trainable tensor with live gradient access.

Gradient — SINGLE SOURCE OF TRUTH. The grad buffer is owned by data's autograd meta (allocated lazily by setRequiresGrad / accumulateGrad). grad() resolves to that live buffer every call, so it can never be a stale snapshot. - non-const grad() → mutable lvalue ref to the live grad (fill / assign / & ). - const grad() → by-value handle sharing the live buffer (read-only).

method
Source
0 members
0 members
0 members
2 members
1 members
0 members
1 members
19 members

Complete environment-neutral categorical PPO loop. The environment remains caller-owned; this class owns collection storage, policy bookkeeping, GAE, and optimizer updates. It composes `ItRolloutTraining` because collection and update phases are not the same lifecycle as DQN or SAC.

Rolls back collection control state after the caller cancels the unsubmitted command transaction. valid from beginCollection through endCollection, until the first update actually begins.

method

The ordinary optimizer-update iterator shared by supervised and RL training. attach TrainingSession here for live control/observation.

method

Performs one PPO update epoch. call until needsCollection() or isDone().

method
Source
0 members
0 members
0 members

in_proj split + RMSNorm/discretization shared by forward and step.

Matrix
Matrix
Matrix
Matrix
Matrix
Matrix
Source
8 members

A GPU-resident weight stored in OA's native Q4 or Q8 block encoding. Quantization is deliberately not an `oa::ScalarType`: one logical value owns a packed integer payload and a separate Float32 scale plane. Treating Q4 as a scalar dtype would make matrix byte sizes, strides, views, and element access incorrect. The physical planes remain private and travel as one weight value.

Source
3 members
2 members
1 members
10 members
0 members
0 members
9 members

Inherits public Module

Per-level EMA codebook update; call once per step AFTER the optimizer step with the result returned by this step's quantize().

method

Token → latent: sum each level's gathered code vectors. The inference-time inverse of quantize for the SUMMED RVQ output — pass per-level generated token ids (one [N] Int32 per level, shallow→deep) → z_q [N, D] for the decoder. inIdx may carry fewer than numLevels() levels (e.g. a model that only generates level 0); only the supplied levels are summed.

method

z_e [N, D] → straight-through total quantization + per-level tokens + per-level residuals (kept for emaUpdate) + commitment loss. Records entirely on-GPU.

method

Greedy data-dependent seed: seed level 0 from the latents, then each deeper level from the running residual under the already-seeded shallower levels.

method
Source
0 members

─── residual Vector quantizer (RVQ) ──────────────────────────────────────── Stacks Q VectorQuantizer levels: level 0 quantizes z_e, level q quantizes the residual left by levels 0..q-1. The quantized output is the SUM of all levels' codes, so Q tokens per frame give far finer reconstruction than one (K^Q effective codes) — the basis for MoMask / MotionDreamer residual-token generation, where a masked model later predicts these per-level tokens. Each level keeps its own EMA codebook; the straight-through estimate and commitment loss apply once on the total.

Source
2 members
0 members
0 members
7 members
8 members

RnnCell / Rnn — vanilla Elman recurrent module. h_new = tanh( W_ih x + b_ih + W_hh h + b_hh ) Mirrors the Gru / GruCell API 1:1 (zeroState / step / forward, stacked layers) so the two recurrent modules are interchangeable in a model. Like the GRU it fuses its pointwise tail (Add + Tanh) into one RnnCellPointwise kernel. The two Linear projections stay separate dispatches; since oa::FnMatrix::Linear is pure dispatch, each needs a manual grad-node attach — see AttachLinearGrad in Rnn.cpp.

Inherits public Module

split projections so Rnn can hoist the (recurrence-free) input projection out of the timestep loop into one batched GEMM. inputProjection: gi = Linear(x, W_ih, b_ih) for any row count → [*, H]. stepWithGi: consumes a precomputed gi [B*T, H] at row offset timeOffset and runs only the recurrent gh = Linear(h, W_hh) + fused tanh pointwise (no per-step Slice).

method
Source
0 members
0 members
0 members
1 members

time-major PPO carrier. reshape the leading [time, environments] dimensions to create minibatch views without copying storage.

Source
12 members

Records one fused GPU append. The CPU cursor is control metadata only; no matrix data is read or copied through the host.

method

Requires a complete rollout and records GAE directly into the preallocated advantage/return matrices.

method

Begins a new collection cycle and clears valid on the GPU. Previously collected tensors remain allocated and are overwritten in place.

method
Source
3 members
0 members
0 members
0 members

Fixed-shape categorical on-policy rollout storage. observationShape excludes the environment axis; for CartPole it is {4}.

Source
0 members

One vector-environment transition. Every matrix remains device-resident.

Source
2 members
1 members
0 members
10 members

Minimal fixed-alpha SAC trainer. Actor forward returns [B, 2*A] containing mean then log-standard-deviation; each critic consumes [observation, action] concatenated on the last axis and returns [B] or [B,1]. Its independent actor and critic update loops are composed rather than hidden by inheritance.

SAC has two exact optimizer units. The critic loop is the primary update controller; the actor loop remains separately observable.

method
Source
0 members
0 members
2 members
5 members
2 members

─── SequentialScheduler ───────────────────────────────────────────────────── Chain N schedulers at milestones. milestones[i] = step at which scheduler i+1 starts. Each sub-scheduler receives step relative to its own start.

Inherits public LRScheduler

Source
8 members

─── SGD ─────────────────────────────────────────────────────────────────────

Inherits public Optimizer

Source
2 members
2 members
2 members
0 members
1 members
0 members
0 members
TrainingCommandDisposition
TrainingState
Source
0 members

Stable, deterministic evidence for the current training-plan capture seam. `Inherited` means the decision still happened in the compatibility authoring or lowering path rather than in a unified graph compiler. `NotRun` is not a success: it makes an intentionally missing optimization visible.

TrainingCompilationStage
TrainingCompilationState
Source
0 members
0 members
TrainingValueKind
String
TrainingParameterClass
Source
2 members
25 members

compile the engine's currently recorded fixed-shape step. On success the source graph is cleared without execution and this program becomes its sole executable owner. On failure the source graph is left intact so the caller may execute it eagerly or diagnose the rejected node. The engine and its vulkan device must outlive this program.

method

Non-blocking submit. Same-queue replays are ordered by vulkan; call wait() before mapped host reads or resource mutation from the CPU.

method

wait for pending work, release the compiled plan and all retained buffers.

method
Source
0 members
26 members

Atomically combines the live state/revision with the most recently published step metrics. Unlike latestSnapshot(), this reflects commands applied since the last completed training step.

method

Called by oa::ItTraining after a completed step/reset/finish. Public for custom iterator adapters, but ordinary callers do not invoke these.

method

apply commands without advancing the training iterator.

method

Non-destructive bounded result view for independent observers such as a viewer and MCP client. results older than the configured ring capacity may have been dropped; callers advance their own sequence cursor.

method

Non-blocking safe point for UI/event-loop owned training. Returns true only when one ordinary training step may begin now.

method

Blocking safe point for a dedicated training thread. Enqueued resume/stop commands wake the wait without polling.

method
Source
0 members
0 members
0 members
5 members
0 members

TRAINING PHASE CONFIG — Multi-phase training schedule

Source
23 members

Inherits public Module

Enables DiT-style AdaLN-Zero modulation. The ordinary language-model path remains unchanged until this is explicitly enabled by a conditioned model.

method

forward: x [B*S, D] → [B*S, D]. inSeqLen separates sequences within the flattened batch. Causal visibility remains the language-model default; flow/denoising encoders explicitly select Bidirectional.

method

Same block with an explicit additive attention mask [B*H*S,S]. The mask is shared by language padding and bidirectional denoising; Flash attention is intentionally bypassed because its current kernel is causal-only.

method

The weights are sequence-length independent. Updating the runtime length only changes the B/S view and its causal mask, which lets one block serve fixed-length training and growing-prefix autoregressive generation.

method
Source
2 members
2 members
0 members

─── oa::CbValidation ─────────────────────────────────────────────────────── Runs inference-only validation after every epoch. step-only runs can provide an interval and are always evaluated once at train end. The evaluator owns batching/model semantics and returns the sample-weighted mean loss. Validation time is excluded from training throughput and printed separately. register this callback before checkpoint and early-stopping callbacks, then pass metricPtr() to both.

Source
10 members

Inherits public Module

EMA codebook update + dead-code reinit. call ONCE per step AFTER the optimizer step, with this step's z_e and the idx returned by quantize(). in-place on the codebook buffer (so it stays the same checkpointed buffers() entry).

method

Token → latent: gather the code vectors for the given indices ([N] Int32, the dtype VqAssign emits, or any generated ids). The inference-time inverse of the nearest-code assignment — feed generated token ids straight back through it to reconstruct z_q [N, D] for the decoder. Pure lookup, no STE.

method

z_e [N, D] (RMS-normalized latents recommended) → quantized (STE) + code indices + commitment loss. Records entirely on-GPU.

method

Data-dependent init: seed the K codes from the K HIGHEST-NORM rows of inLatents ([>= K, D] encoder outputs) — NOT the first K, which is degenerate for residual VQ (rows a shallow level used → ~zero residual → a deeper codebook seeds all zeros and dies). Highest-norm rows are never zero, so every level gets live, distinct codes. writes the codebook IN-PLACE (copyFrom) so the registered buffers() entry stays valid. Completes inLatents before reading.

method
Source
0 members
0 members
Matrix
Matrix
Source
0 members
0 members
0 members
2 members

─── WarmupScheduler ───────────────────────────────────────────────────────── Linear warmup to targetLr over warmupSteps, then delegate to after scheduler.

Inherits public LRScheduler

Source
0 members
0 members
0 members
0 members
10 members

Immutable named-weight source. Implementations may mmap one file, aggregate a sharded manifest, or expose another model container. Returned byte spans remain valid while the source remains alive.

Source
0 members

Enums

None · Relu · Gelu · Silu

Execution policy for scaled dot-product attention. Auto selects only an internally proven route and otherwise preserves the compositional reference path; Flash explicitly requests the fused causal implementation.

Auto · Standard · Flash

Token-visibility contract for self-attention.

Causal · Bidirectional

─── CyclicScheduler ───────────────────────────────────────────────────────── Cyclic LR: oscillates between baseLr and maxLr. Triangular = constant amplitude. Triangular2 = halving amplitude per cycle. ExpRange = exponential decay per iteration.

Triangular · Triangular2 · ExpRange

─── oa::CbEarlyStop ──────────────────────────────────────────────────────── keras EarlyStopping. calls iter.requestStop() once the monitored value has not improved for `patience` epochs — the training while-loop exits on the next isDone(). Pair with oa::CbCheckpoint(RestoreBest) to also get restore_best_weights semantics. Patience: number of epochs without improvement to tolerate. MinDelta: minimum change to count as improvement. Mode: Min for loss (lower is better), Max for accuracy (higher is better). If inMetric is provided, uses that metric's value; otherwise epoch mean loss.

Min · Max

Structural domains shared by native OA environments and interoperability adapters. Shapes exclude the leading environment-batch dimension; rank zero therefore represents one scalar per environment.

Box · Discrete · Binary

Mean · Last

Config · Weights · State · Optimizer · Progress · LegacyKernelCache

─── ReduceOnPlateauScheduler ──────────────────────────────────────────────── Metric-driven: drop LR by factor when metric stalls for patience steps. call step(metric) each epoch. getLr() returns current LR (ignores inStep).

Min · Max

Pause · Resume · Stop · Checkpoint · Evaluate · SetParameter · RequestRecapture · RequestRebuild

SemanticValidation · ReplaySafety · Decomposition · Fusion · Placement · Precision · KernelSelection · LoweringValidation · MemoryPlanning · SynchronizationPlanning · CommandRecording

NotRun · Inherited · Analyzed · Applied · Failed

Hot · Recapture · Rebuild · Immutable

Running · Paused · Stopping · Completed · Failed

Empty · Boolean · Integer · Float · String

Auto · SafeTensors · ModelFile · Gguf · Onnx

Identity · Transpose2D · Concat · Slice

Functions

Functions

crossEntropy: Mean cross-entropy over rank-two logits and UInt8, UInt32, or non-negative Int32 class-index targets; the scalar result is Float32, and an out-of-range target produces NaN without an out-of-bounds read.

crossEntropyBwd: gradient w.r.t. logits: (softmax(logits) - onehot(targets)) / batch

inLogitsin — [batch, classes] unnormalized logits

inTargetsin — [batch] class indices (UInt8, UInt32, or non-negative Int32)

Returns the name of the most recently called loss function, or nullptr.

Functions