Skip to main content

//clika-runtime/io.clika.runtime

Package-level declarations

Types​

NameSummary
Activation[common]
enum Activation : Enum<Activation>
A fused activation epilogue. Identity = none. The gated kinds (SwiGlu, GeGlu, ReGlu, Situ) take a concatenated [*, 2d] gate‖up input and emit [*, d], used as a fused projection epilogue.
Agg[common]
enum Agg : Enum<Agg>
A group-by aggregation over a group's non-null values.
AggSpec[common]
data class AggSpec(val column: String, val agg: Agg = Agg.SUM, val outName: String = "")
One aggregation of a Table.groupBy: the column, the reduction and the output name (empty for <column>_<agg>).
AudioData[common]
class AudioData(val samples: Tensor, val info: AudioInfo)
A decoded waveform plus its effective layout: samples is [frames] (mono) or [frames, channels] Float32 on the host. Release samples when done (use {}), as any tensor.
AudioInfo[common]
data class AudioInfo(val sampleRate: Int, val channels: Int, val frames: Long)
An audio stream's effective layout, read from its header. With a non-zero target rate or channel count the figures are what a decode to that target produces; frames is exactly the count Io.loadAudio with the same targets returns (seconds = frames / sampleRate).
AudioNormKind[common]
enum AudioNormKind : Enum<AudioNormKind>
The normalization an audio feature processor applies to its output.
AudioProcessOptions[common]
data class AudioProcessOptions(val maxLengthSamples: Long? = null, val chunkLengthSeconds: Double? = null, val padToChunk: Boolean? = null, val paddingValue: Double? = null, val inputScaleFactor: Double? = null, val melFloor: Double? = null, val logMode: LogMode? = null, val logDynamicRange: Double? = null, val logShift: Double? = null, val logScale: Double? = null, val normalization: AudioNormKind? = null, val normMean: Float? = null, val normStd: Float? = null)
Per-call overrides of AudioProcessor.process: only the knobs the pipeline reads fresh each call. A set field replaces the loaded configuration's value for that call only. normMean and normStd are the scalar operands of AudioNormKind.GLOBAL_MEAN_STD.
AudioProcessor[common]
class AudioProcessor
A configuration-driven audio feature processor: a waveform in, the raw waveform, a log-mel spectrogram or a log-mel filterbank out, as a model's preprocessor_config.json states it. A file or payload is decoded, resampled to the configured rate and mixed to mono first; a waveform you hand in must already be at that rate. AutoCloseable: close releases it.
Backends[common]
object Backends
Backend discovery: which compute backends this runtime carries, which load on THIS device and why one does not, and the devices each exposes. Every call takes a ComputeApi.
BatchableState[common]
interface BatchableState
The reads the continuous batcher takes of a session's state, on the engine's thread, every step: the carried load, its ceiling (the headroom admits work) and the units the next step launches (1 for a decode step; a prompt ingested in chunks reports its next chunk's length). Keep them cheap and never raise: a raise is reported and reads as 0.
BatcherConfig[common]
data class BatcherConfig(val maxBatch: Long = 0, val workBudget: Long = 0, val stepTokenBudget: Long = 0)
Continuous-batch composition knobs: sessions per step, work per step, tokens launched per step (0 = unbounded).
CapacityPolicy[common]
enum CapacityPolicy : Enum<CapacityPolicy>
How admission accounts for the model's capacity beyond the session cap: SLOT_CAP admits up to the session ceiling and never reads the model's capacity; NO_EVICT admits a request only while the free capacity covers every active session's remaining need plus this one's whole need; PREEMPT_LAST admits while the free capacity covers the next step and lets the model set a session aside when it runs short, to re-admit it later.
ChatTemplateInputs[common]
class ChatTemplateInputs(val messages: String, val tools: String? = null, val addGenerationPrompt: Boolean = true, val extraContext: String? = null, val nowEpochSeconds: Long = 0)
The full inputs of a chat render: the messages as a JSON array of {"role", "content", ...} turns (an assistant turn may carry tool_calls, a "tool" turn a tool response), the tools offered to the model as a JSON array of schemas (null for none), whether to append the assistant-turn priming (addGenerationPrompt), extraContext as a JSON object whose keys become template variables (null for none), and the fixed clock behind the template's strftime_now as Unix seconds, so a render is reproducible (0, the default, renders at the epoch).
ChatTemplateOptions[common]
class ChatTemplateOptions(val chatTemplate: String? = null, val applyPolyfills: Boolean? = null, val useBosToken: Boolean? = null, val useEosToken: Boolean? = null, val defineStrftimeNow: Boolean? = null, val polyfillTools: Boolean? = null, val polyfillToolCallExamples: Boolean? = null, val polyfillToolCalls: Boolean? = null, val polyfillToolResponses: Boolean? = null, val polyfillSystemRole: Boolean? = null, val polyfillObjectArguments: Boolean? = null, val polyfillTypedContent: Boolean? = null)
Per-render overrides of a chat render. Every toggle is tri-state: null keeps the template's standing behavior, a value forces it for this render only. chatTemplate swaps the template source for the call; it is parsed per render, so keep the standing template for the hot path.
ChunkCallback[common]
fun interface ChunkCallback
Called per streamed chunk, on the engine's thread; never block in it.
ChunkProducer[common]
fun interface ChunkProducer
A chunked body's producer: one chunk per pull, null at the end.
ChunkSink[common]
fun interface ChunkSink
A sink for the body chunks of a streaming read.
ClikaRt[common]
object ClikaRt
The entry of the binding: the runtime library and the bridge load at the first touch of this object, and load runs the one check every call depends on.
ClikaRtAndroid[android]
object ClikaRtAndroid
The Android entry over ClikaRt: pins the runtime's cache root to the app's own cache directory, then loads the binding.
ClikaRtException[common]
class ClikaRtException(val status: Status, val codeName: String, message: String)
A runtime failure. codeName is the machine-readable channel that survives every build flavor; branch on it, never on the message text (release builds may show an opaque message code). status is the coarse class.
ClikaRtLog[common]
object ClikaRtLog
The runtime's log lines through the host app's own logger. The runtime logs on its "ClikaRT" channel; setLevel sets that channel's threshold and setCallback routes every record at or above it to a LogCallback. The runtime's own console output continues beside the callback.
ColumnOp[common]
enum ColumnOp : Enum<ColumnOp>
An in-place column operation (Table.applyScalar, Table.applyColumn).
CompileOptions[common]
data class CompileOptions(val inputShapes: Map<String, LongArray> = emptyMap(), val namedDims: Map<String, Long> = emptyMap(), val sampleInputs: Map<String, Tensor> = emptyMap(), val weights: Placement? = null, val stickyWeights: Boolean = false)
How OnnxModel.compile builds the graph. With none of the shape roads a dynamic input dim stays dynamic and the graph binds real shapes at run time; inputShapes pins an input to one fixed shape, namedDims pins every dim declared under that name (an ONNX dim_param), and sampleInputs pins each named input to its example's shape and dtype (the values are never read); the roads combine, the explicit shapes winning. weights is the device or stream the finalized graph serves on (null keeps the operators where they are); stickyWeights keeps the weights resident under memory pressure.
CompletionCallback[common]
fun interface CompletionCallback
Called once at a session's end, on the engine's thread, with its response or its failure (the other is null); never block in it.
ComputeApi[common]
enum ComputeApi : Enum<ComputeApi>
The compute backend a device dispatches through.
Cookie[common]
data class Cookie(val name: String, val value: String, val path: String = "/", val domain: String = "", val maxAge: Int = -1, val httpOnly: Boolean = true, val secure: Boolean = false, val sameSite: SameSite = SameSite.LAX)
A cookie to set on a response: maxAge below 0 means a session cookie, an empty domain omits the attribute, httpOnly hides it from script, secure limits it to HTTPS.
CsvReadOptions[common]
data class CsvReadOptions(val separator: Char = ',', val hasHeader: Boolean = true, val nullTokens: List<String> = emptyList())
The options of a CSV read: the field separator, whether the first row carries the column names, and the unquoted values that read as null beside an empty field. Column types are inferred.
DefaultsOptions[common]
data class DefaultsOptions(val specialize: Boolean = false, val shapeFixation: Boolean = false, val channelsLastInputs: Boolean = false, val channelsLastOutputs: Boolean = false)
The choices the optimizer's transforms read: specialize collapses the shape arithmetic the compile's pinned shapes fix (a graph compiled from ONNX), shapeFixation the same for a traced graph's static dims, and the two channels-last choices omit the layout conversions at the inputs or the outputs (changing those slots' contract: read the specs after).
Device[common]
data class Device(val api: ComputeApi, val index: Int) : Placement
A compute device: a backend api plus a device index. An accelerator index is zero-based and names one physical device; a CPU index names a SOCKET, with the whole machine at WHOLE_MACHINE, so CPU uses every core and Device.cpu(0) confines work to socket 0.
DeviceKind[common]
enum DeviceKind : Enum<DeviceKind>
Where a device sits relative to the host: an integrated GPU shares the host's memory (phones, Jetson boards, Apple silicon), a discrete one has its own, the CPU is the host itself; UNKNOWN when the backend reports no kind.
DeviceProperties[common]
data class DeviceProperties(val name: String, val kind: DeviceKind, val driverVersion: String, val backendRuntimeVersion: String, val smCount: Int, val computeCapabilityMajor: Int, val computeCapabilityMinor: Int, val warpSize: Int, val maxThreadsPerBlock: Int, val sharedMemoryPerBlockBytes: Long, val totalMemoryBytes: Long, val isIntegrated: Boolean, val hasTensorCores: Boolean, val supportsFp16: Boolean, val supportsBf16: Boolean, val supportsFp8E4m3: Boolean, val prefixContinuationBitExact: Boolean, val unavailableReason: String)
A device's static capabilities (see Device.properties). Field meanings are normalized across backends: smCount is SMs on CUDA, compute units elsewhere; warpSize is the warp/wave/subgroup width; the compute capability is the CUDA SM version or the nearest generation tag elsewhere. A field the backend does not report is 0 / false / "". unavailableReason is empty when the device serves.
Disposition[common]
enum Disposition : Enum<Disposition>
A session's outcome of one iterate step: keep stepping, done (its outputs are final), failed (see SessionStepResult.error), or set aside for lack of capacity and re-admitted later with its delivered chunks intact (only under CapacityPolicy.PREEMPT_LAST).
DownloadOptions[common]
data class DownloadOptions(val bearerToken: String? = null, val progress: ProgressSink? = null, val connectTimeoutSec: Int = 10, val readTimeoutSec: Int = 30, val followRedirects: Boolean = true, val resume: Boolean = false)
The options of a transfer: a bearer token for Authorization (never logged), a progress sink (return false to cancel), the connect and read budgets in seconds, whether 3xx redirects are followed, and, for Http.downloadFile alone, whether an existing partial destination is resumed with a ranged request and kept on failure.
DType[common]
enum DType : Enum<DType>
The element format of a tensor's values. The set covers booleans, signed and unsigned integers (sub-byte widths included), the IEEE-style floats and the narrow floating formats quantized models use.
EagerScope[common]
class EagerScope
While open, forces EAGER execution on the calling thread, even inside a TracingScope: a region that must compute concrete values. Thread-local.
Encoded[common]
class Encoded(val ids: Array<IntArray>, val inputIds: Tensor?, val attentionMask: Tensor?, val seqLengths: Tensor?, val cuSeqlens: Tensor?)
A tensor-shaped encode: ids always carries one id row per input text; the tensor columns are present only when EncodeOptions.returnTensors was set: inputIds[B, S] padded Int32 (or one flat row with varlen), attentionMask[B, S] Int32 with 1 for a token and 0 for pad (padded layout only), seqLengths[B] Int32, the real token count per sequence, and cuSeqlens[B + 1] Int32, the exclusive prefix sums an attention over the flat row takes. Release the tensors you were given when done.
EncodeOptions[common]
data class EncodeOptions(val addSpecialTokens: Boolean = true, val returnTensors: Boolean = false, val varlen: Boolean = false, val padId: Int? = null, val device: Placement? = null, val maxLength: Long? = null, val truncationSide: TruncationSide = TruncationSide.RIGHT, val paddingSide: PaddingSide = PaddingSide.RIGHT, val padToMultipleOf: Long? = null)
The per-call controls of the tensor-shaped encode entry points (Tokenizer.encodeText, Tokenizer.encodeBatch).
ErrorHandler[common]
fun interface ErrorHandler
The page of an error status (a 404, an explicit error): the request and the status in, the response out.
EventProducer[common]
fun interface EventProducer
A Server-Sent-Events body's producer: one event per pull, null at the end.
ExceptionHandler[common]
fun interface ExceptionHandler
The page of a failed handler (one that raised): the request and the failure's text in, the response out.
ExecConfig[common]
data class ExecConfig(val batcher: BatcherConfig = BatcherConfig(), val scheduler: SchedulerConfig = SchedulerConfig(), val stream: Stream? = null, val maxQueued: Long = 0)
One executor's configuration: the batching and scheduling knobs, the stream it runs on (null = a new asynchronous stream of its own) and the in-flight cap for backpressure (0 = unbounded).
Executor[common]
class Executor
Drives one model: admits requests, runs its phases and delivers results. enqueue validates the request against the model's schema and answers at once; await blocks for the session's response; shutdown drains; a later enqueue fails with FAILED_PRECONDITION. AutoCloseable: close shuts down and releases the executor, and the model stays the caller's.
FormFile[common]
class FormFile
One uploaded file of a multipart/form-data body: its client-side name, content type and bytes.
FormPart[common]
class FormPart
One part of a multipart/form-data body: a text field (empty filename and contentType) or a file part.
FrameBatch[common]
class FrameBatch(val frames: Tensor, val indices: LongArray, val ptsSeconds: DoubleArray, val durationSeconds: DoubleArray)
A decoded batch of frames plus the alignment facts a video model needs: frames packed [K, H, W, 3] UInt8 on the host, the source indices they were taken from, each frame's presentation time in seconds (the clip's own timeline, offsets and uneven spacing included) and its display duration. Release frames when done.
FunctionModel[common]
class FunctionModel
A serving model whose phases are Kotlin bodies: declare the contract, bind each phase (and the state factory of a stateful model), then hand it to an Executor or a Pipeline. A phase bound after an executor or a pipeline was created over the model is not one it runs. AutoCloseable; close refuses while an executor or a pipeline holds the model.
GeluMode[common]
enum GeluMode : Enum<GeluMode>
GELU approximation: exact (None), Tanh (the tanh approximation), Quick (sigmoid-based), or Fast.
GridSampleMode[common]
enum GridSampleMode : Enum<GridSampleMode>
grid_sample interpolation.
GridSamplePaddingMode[common]
enum GridSamplePaddingMode : Enum<GridSamplePaddingMode>
grid_sample out-of-bounds handling.
Handler[common]
fun interface Handler
A route handler: the request in, the response out.
HashLaneAlgo[common]
enum HashLaneAlgo : Enum<HashLaneAlgo>
hash_lanes permutation. Auto picks by the input's lane width: a 32-bit integer lane maps through Triple32, a 64-bit lane through Moremur. The named kinds select a permutation within that width: Triple32 and WeakTwoMul are 32-bit, Moremur, Feistel3Mul3 and Feistel4Mul2 are 64-bit; a kind of the other width is refused.
HashTensorMode[common]
enum HashTensorMode : Enum<HashTensorMode>
hash_tensor combine mode. XorSum xor-folds the elements' mixed hashes; order-independent, so a digest survives layout permutations.
Http[common]
object Http
The runtime's HTTP client: text and byte downloads, a download to a file (resumable), the full response of a GET, a POST or a DELETE, and the streaming reads whose chunks or events arrive through a sink on the calling thread. A failure to complete a request is a ClikaRtException; an answered status is data in the HttpResponse.
HttpResponse[common]
class HttpResponse
A finished HTTP response, the outcome of a request the server answered: any answered status arrives here as data (a 404 or a 401 too; branch on status or isOk); only a request that could not complete at all (the connection, TLS, a timeout, a cancellation) fails with a ClikaRtException. headers keep the arrival order and a name may repeat; body is empty for a transfer that streamed its body to a file.
HttpServer[common]
class HttpServer
The runtime's HTTP server: routes by verb and path (exact, or a pattern whose groups become captures), route groups, middleware, static files, the failure and error pages, an access logger, the tuning knobs, and the start and stop (listen blocks; listenAsync / bindToAnyPort serve on a background thread; stop drains). A handler runs on the server's own thread; the runtime attaches it to the JVM for the call. AutoCloseable: close stops the server if it runs and releases it. A borrowed server (isBorrowed) is another object's, handed out for its routes: close drops the handle and releases nothing, and the owner's start, stop and lifetime stay the owner's.
ImageInfo[common]
data class ImageInfo(val height: Long, val width: Long, val channels: Long)
An image's pixel geometry as displayed (channels-last), read from its header: an EXIF orientation tag is applied, so a rotated photo reports the swapped height and width, the same [H, W, C]Io.loadImage returns.
ImageProcessOptions[common]
data class ImageProcessOptions(val doResize: Boolean? = null, val resize: <Error class: unknown class><Long, Long>? = null, val resample: ImageResample? = null, val antialias: Boolean? = null, val doCenterCrop: Boolean? = null, val crop: <Error class: unknown class><Long, Long>? = null, val doRescale: Boolean? = null, val rescaleFactor: Double? = null, val doNormalize: Boolean? = null, val imageMean: FloatArray? = null, val imageStd: FloatArray? = null, val doConvertRgb: Boolean? = null, val doPad: Boolean? = null, val padTo: <Error class: unknown class><Long, Long>? = null)
Per-call overrides of ImageProcessor.process: a set field replaces the loaded configuration's value for that call only, an unset (null) field keeps it. Setting resize does not turn doResize on by itself. imageMean and imageStd are set together, per channel (length 1 or 3).
ImageProcessor[common]
class ImageProcessor
A configuration-driven image preprocessor: convert to RGB, resize, center-crop, rescale, normalize and pad, as a model's preprocessor_config.json states them, to a [H, W, C] Float32 tensor (channels-last). Load one from a model directory, or build one from the common knobs with fromArgs. AutoCloseable: close releases it.
ImageResample[common]
enum ImageResample : Enum<ImageResample>
The resampling filter of an image resize; the codes are the runtime's own.
InterpMode[common]
enum InterpMode : Enum<InterpMode>
Resampling mode for ops::interpolate (rank dispatch picks the spatial variant: Linear covers linear/bilinear/trilinear by input rank).
Io[common]
object Io
Decoding and encoding of images, audio and video, and the NumPy .npy entry and exit forms of a tensor.
IterateBody[common]
fun interface IterateBody
The body of an iterate phase: one result per slot, in slot order.
JoinKind[common]
enum JoinKind : Enum<JoinKind>
The flavor of a Table.join: INNER keeps matched rows only, LEFT and RIGHT also keep that side's unmatched rows (nulls fill the other side), OUTER keeps both sides' unmatched rows.
Json[common]
class Json
A JSON document: null, a boolean, a number, a string, an array or an object. Parse one with parse or readFile, build one with newObject / newArray and the scalar factories, read it with the is predicates, the as readers and at, write it with set and add, and serialize it with dump or writeFile. A read answers an independent copy, a write copies the given value in, so no document ever aliases another. AutoCloseable: close releases the document.
JsonKind[common]
enum JsonKind : Enum<JsonKind>
The kind of a JSON value; the codes are the bridge's.
KVSpecOptions[common]
data class KVSpecOptions(val batch: Long = 1, val pastLenMin: Long = 0, val pastLenOpt: Long = 0, val pastLenMax: Long = 0)
The session cache sizing of a model served from a graph with a KV cache: the batch every cache input is specced at and the past length as a min / opt / max range (the one-value form fixes it). A graph without a KV cache ignores it.
LogCallback[common]
fun interface LogCallback
A callback carrying one runtime log record: its LogLevel and the formatted line (no trailing newline). Registered through ClikaRtLog.setCallback; fires on whichever thread logged, so keep the body short and never log back into the runtime from it.
Logger[common]
fun interface Logger
The per-request access logger, run after each response.
LogLevel[common]
enum LogLevel : Enum<LogLevel>
The severities of the runtime's log records, low to high; OFF disables the channel.
LogMode[common]
enum LogMode : Enum<LogMode>
How an audio spectrum is compressed after the mel bank.
MemorySource[common]
enum MemorySource : Enum<MemorySource>
How the physical figures of a MemoryStats were obtained: read from the driver or the OS (MEASURED), derived from a declared budget or a clamped read (HEURISTIC), or not available (UNKNOWN).
MemoryStats[common]
data class MemoryStats(val deviceFreeBytes: Long, val deviceTotalBytes: Long, val deviceMemorySource: MemorySource, val activeBytes: Long, val requestedBytes: Long, val reservedBytes: Long, val cachedBytes: Long, val peakActiveBytes: Long, val peakReservedBytes: Long, val peakRequestedBytes: Long, val numAllocs: Long, val numFrees: Long, val numOom: Long, val numInflightParkWaits: Long, val wrappedBytes: Long, val wrappedAllocs: Long)
A device's memory at one point in time (see Device.memoryStats): the physical free and total bytes with how they were obtained, and the runtime pool's counters for that device. requestedBytes is the residency gauge (what the live allocations asked for: a second live copy of a weight doubles it); the peaks only ever rise until Device.resetPeakMemoryStats. Byte counts and tallies are unsigned 64-bit in the runtime and ride Long.
MeshgridIndexing[common]
enum MeshgridIndexing : Enum<MeshgridIndexing>
meshgrid output orientation: NumPy's indexing= argument. IJ (matrix indexing) keeps output shapes in the input order; XY (Cartesian) swaps the first two axes.
Method[common]
enum Method : Enum<Method>
An HTTP verb; the codes are the bridge's.
Middleware[common]
fun interface Middleware
A middleware: read or tag the request, call Next (or not), answer a response.
ModelGraph[common]
class ModelGraph
A compiled model: its I/O contract, its placement, and its runs. A graph runs once it is finalized (finalizeGraph: placed on its device, the weights packed, the execution order planned); a run before that fails with FAILED_PRECONDITION. to moves it to a device or a stream, before finalizing (recording where finalizing places it) or after (moving the finalized graph). AutoCloseable: close releases the graph.
ModelSchema[common]
data class ModelSchema(val inputs: List<TensorSpec> = emptyList(), val outputs: List<TensorSpec> = emptyList(), val stateful: Boolean = false, val supportsStreaming: Boolean = false)
A model's full I/O contract: the consumed and produced slots, and whether it keeps per-session state or streams.
ModMode[common]
enum ModMode : Enum<ModMode>
mod convention: Python (sign follows divisor) or C (sign follows dividend).
MoeRouting[common]
enum MoeRouting : Enum<MoeRouting>
Mixture-of-Experts routing: how the router logits select the top-k experts and produce the combine weights. Values are PINNED (ABI).
NativeLibraries[common]
object NativeLibraries
The runtime's native libraries on a desktop JVM. A library packed in a bridge jar under native/<os>-<arch>/ (the platform ids: linux-x86_64, linux-arm64, macos-arm64, windows-x86_64, windows-arm64) is extracted once per process into a temporary directory, removed at exit, and loaded from there; a library packed nowhere on the classpath loads by name through java.library.path. An Android app ships its libraries in jniLibs, where the by-name load is the one path.
Next[common]
fun interface Next
The rest of the chain a middleware may call: the next middleware, or the route's handler.
NullOrder[common]
enum NullOrder : Enum<NullOrder>
Where a multi-key sort places null cells.
OnnxModel[common]
class OnnxModel
An ONNX model opened from a file: the graph loads into memory and the external initializer payloads stay on disk until something consumes them; nothing is validated beyond the wire format, and compile is where operator support is decided. AutoCloseable: close releases the parsed model (a graph it compiled lives on).
OnnxModelOptions[common]
data class OnnxModelOptions(val saveAsExternalData: Boolean? = null, val deduplicateInitializers: Boolean = true, val deduplicateNodes: Boolean = true, val producerName: String = "ClikaRT", val irVersion: Long = 0)
How an ONNX model is edited and saved; given at OnnxModel.open, they hold for the model's lifetime. saveAsExternalData null means automatic (a <stem>_data sidecar once the payloads exceed the 2 GiB protobuf ceiling), true always a sidecar, false never; irVersion 0 keeps an opened file's own IR version.
Ops[common]
object Ops
The generated operator surface; see the file banner for its laws.
OptimizeOptions[common]
data class OptimizeOptions(val defaults: DefaultsOptions = DefaultsOptions(), val maxNumIterations: Long = 100)
How ModelGraph.optimize runs: the transforms' choices and the most iterations one run makes (at least 1). The list is the graph's own defaults.
OptimizeReport[common]
class OptimizeReport
What one optimize run did: the iterations run, whether it stopped on its own, whether it changed the graph, and one row per transform.
PaddingSide[common]
enum PaddingSide : Enum<PaddingSide>
Which end of a short row a padded batch fills. LEFT suits decoder-only batch generation: every row's real tokens end flush at the last column.
PadMode[common]
enum PadMode : Enum<PadMode>
pad boundary handling. Constant fills with the given value; Reflect mirrors about the edge (edge sample not repeated); Replicate repeats the edge sample; Circular wraps around.
PhaseContext[common]
class PhaseContext
What a run-once phase body reads and writes: the request's inputs (each read answers a fresh tensor the body owns; the bytes are the request's) and the phase's outputs. Valid for the body's call alone; never keep it past the return. An op the body issues runs on the phase's own stream.
PhaseKind[common]
enum PhaseKind : Enum<PhaseKind>
How a phase runs: once per session, or stepped by the runtime until the session finishes.
Pipeline[common]
class Pipeline
A multi-step serving ensemble: each step runs a model under its own executor tuning, wired by name maps into one request/response surface declared by the external schema. enqueue validates the request against that schema and answers at once, with or without callbacks; await blocks for the session's response; cancel stops a session at its next step boundary (its completion reads CANCELLED); shutdown drains and a later enqueue fails with FAILED_PRECONDITION. AutoCloseable: close shuts down and releases the pipeline, and the models stay the caller's.
PipelineStep[common]
data class PipelineStep(val name: String, val model: FunctionModel, val execConfig: ExecConfig = ExecConfig(), val inputMap: List<<Error class: unknown class><String, String>> = emptyList(), val outputMap: List<<Error class: unknown class><String, String>> = emptyList())
One node of a Pipeline: a model with its executor tuning, wired by (pipeline name, step input) pairs in inputMap and (step output, pipeline name) pairs in outputMap.
PixelShuffleMode[common]
enum PixelShuffleMode : Enum<PixelShuffleMode>
pixel_shuffle channel ordering.
Placement[common]
sealed interface Placement
Where work runs or a tensor lives: a Device names the device (the work follows its inputs and otherwise takes the calling thread's current lane there), a Stream names the lane exactly (a device's default stream is the opt-in to synchronous execution). A null placement is the runtime's default.
PlacementScope[common]
class PlacementScope(where: Placement)
While open, where is the calling thread's ambient placement: every call that names no placement takes it. Thread-local; scopes nest and each restores what it displaced.
ProcessedVideo[common]
class ProcessedVideo(val clip: Tensor, val frameIndices: LongArray, val ptsSeconds: DoubleArray)
A processed clip plus the sampling facts a timestamp-aware model needs: clip[sampled, H, W, C] Float32, the source frameIndices sampled in order, and each one's presentation time in seconds. Release clip when done.
Processor[common]
class Processor
A model directory's preprocessors as one composite: the tokenizer and the one media processor (image, audio or video) its files describe; a missing piece leaves its slot empty rather than failing the load. Each accessor hands out a standalone handle sharing the composite's instance, valid after the composite is closed; an empty slot fails with NOT_FOUND, so check the has properties first. AutoCloseable.
ProgressSink[common]
fun interface ProgressSink
A progress callback of a transfer; return false to cancel it.
QuantileInterp[common]
enum QuantileInterp : Enum<QuantileInterp>
quantile interpolation between data points. Linear interpolates between the two neighbors; Lower / Higher take a neighbor; Nearest the closer one; Midpoint their mean.
Reduction[common]
enum Reduction : Enum<Reduction>
Loss reduction over the batch.
Regex[common]
class Regex
A compiled regular expression, matched over bytes (UTF-8 by default). fullMatch needs the whole text to match; partialMatch and find look anywhere in it. A malformed pattern fails at compile with INVALID_ARGUMENT and the engine's diagnostic. AutoCloseable: close releases the compiled program.
RegexOptions[common]
data class RegexOptions(val caseSensitive: Boolean = true, val longestMatch: Boolean = false, val dotMatchesNewline: Boolean = false, val neverCapture: Boolean = false, val maxProgramMemory: Long = 0, val latin1: Boolean = false)
The compile options of a Regex: a case-insensitive match (caseSensitive false), leftmost-longest instead of leftmost-first (longestMatch), . matching a newline, every group non-capturing, a cap on the compiled program's memory in bytes (0 for none), and Latin-1 bytes instead of UTF-8.
Request[common]
data class Request(val inputs: Map<String, Tensor>, val priority: Int = 0, val deadlineMs: Long? = null, val streaming: Boolean = false)
A request: named inputs (the keys are the schema's input names; an input the schema does not declare is carried through for the phase body to read) plus scheduling hints. The tensors stay the caller's.
RequestCallbacks[common]
data class RequestCallbacks(val onChunk: ChunkCallback? = null, val onComplete: CompletionCallback? = null)
The event-driven hooks of a pipeline session: delivered serially and in order, the completion once after the last chunk. A raise from either is reported on its thread and the engine proceeds.
Response[common]
class Response
A session's final response: its named outputs, fresh tensors the caller owns; close releases them all.
ResponseChunk[common]
class ResponseChunk
One streamed chunk of a session's output: fresh tensors the caller owns (close releases them); final marks the last chunk of a cleanly finishing stream. A pipeline's stream ends with one empty final chunk and its payload rides the completion; an erroring or canceled session marks no chunk final.
RopeScaling[common]
enum RopeScaling : Enum<RopeScaling>
RoPE frequency-scaling family (long-context extension). Every family also folds an OPTIONAL 1-D [rotary_dim/2]``freq_factors per-band divisor table into its frequencies (absent ⇒ no division); the 2-D [2, rotary_dim/2] short/long-row form belongs to the LongRoPE families alone, which REQUIRE a table in one of the two shapes.
RotaryMode[common]
enum RotaryMode : Enum<RotaryMode>
How a rotary embedding pairs the channels it rotates.
RoundingMode[common]
enum RoundingMode : Enum<RoundingMode>
Integer-division / floor-div rounding.
RouteGroup[common]
class RouteGroup
A group of routes under a path prefix, with its own middleware; made by HttpServer.group or group. AutoCloseable: close releases the group's handle (the routes registered stay on the server).
RunOnceBody[common]
fun interface RunOnceBody
The body of a run-once phase: read the context's inputs, set its outputs.
SameSite[common]
enum SameSite : Enum<SameSite>
A cookie's cross-site posture.
ScatterReduceMode[common]
enum ScatterReduceMode : Enum<ScatterReduceMode>
scatter_reduce combine op. Sum / Prod / Mean accumulate; AMax / AMin keep the extremum.
SchedulerConfig[common]
data class SchedulerConfig(val maxActiveSessions: Long = 1, val capacityPolicy: CapacityPolicy = CapacityPolicy.SLOT_CAP)
Admission knobs: the concurrent-session ceiling (1 = serial) and the capacity policy.
ServerRequest[common]
class ServerRequest
A request as a handler sees it: a borrowed view, valid for the handler call alone; never keep it past the return. The observers are always present; the lookups answer null when the header, query field, cookie or form field is absent; the path captures of a pattern route are read by index or by name; setAttr / attr are the middleware-to-handler channel (read-only inside the failure and error pages and the logger).
ServerResponse[common]
class ServerResponse
A response a handler answers, built by a factory and chained with withHeader / withCookie. Returning it from a handler consumes it; a response never returned is released by close.
ServerSentEvent[common]
class ServerSentEvent(val event: String = "message", val data: String, val id: String = "")
One Server-Sent-Events frame: its event type (message by default), its data payload and its id.
SessionId[common]
typealias SessionId = Long
A session's handle, answered by enqueue and read by await and cancel.
SessionStepResult[common]
class SessionStepResult(val disposition: Disposition = Disposition.CONTINUE, val outputs: Map<String, Tensor> = emptyMap(), val error: ClikaRtException? = null)
One session's result of an iterate step: the verdict, this step's outputs (the engine takes them at the return: the body gives them away and their handles are emptied) and, under Disposition.ERROR, the failure.
SortKey[common]
data class SortKey(val column: String, val order: SortOrder = SortOrder.ASCENDING, val nulls: NullOrder = NullOrder.LAST)
One key of a multi-key sort, most significant first, with its direction and null placement.
SortOrder[common]
enum SortOrder : Enum<SortOrder>
A sort's direction.
SseSink[common]
fun interface SseSink
A sink for the events of a Server-Sent-Events stream.
StateFactory[common]
fun interface StateFactory
A model's per-session state factory: any object, or null for no state. It runs with the session's stream as the thread's placement. A state that is AutoCloseable is closed when the engine releases the session; one that implements BatchableState is read by the batcher.
Status[common]
enum Status : Enum<Status>
The coarse class of a runtime failure, the first thing to branch on; ClikaRtException.codeName is the fine-grained name.
StepContext[common]
class StepContext
What an iterate body reads: one slot per session in the batch, in batch order. An op the body issues runs on the step's stream.
StepSlot[common]
class StepSlot
One session's slot in a batched iterate step: its state (the object the model's state factory made; null for a stateless model), the runtime's session id (minted in arrival order) and the request's priority.
Stream[common]
class Stream : Placement
An execution stream: an ordered queue of device work. Work placed on a stream you create is pipelined, so the host keeps queueing while the device runs, and two such streams overlap independent work. The per-device defaultStream runs each operation on the calling thread instead: the explicit opt-in to synchronous execution.
StreamingDecoder[common]
class StreamingDecoder
Incremental id-to-text decoding for a generation stream. Ids arrive one at a time, but decoded bytes are displayable only at UTF-8 boundaries (a code point can span tokens): push returns exactly the newly stable text (often empty while a code point is incomplete) and finish flushes the tail and resets the decoder for a fresh stream. One decoder serves one stream at a time; it stays valid after the Tokenizer it came from is closed. AutoCloseable: close releases it.
SwigluFusion[common]
enum SwigluFusion : Enum<SwigluFusion>
How the gate‖up halves are laid out in a gated MoE FC1 output.
SynchronousScope[common]
class SynchronousScope
While open, every op dispatched on the calling thread COMPLETES before the dispatch returns, whichever stream runs it. Thread-local: open and close it on one thread (use { }); scopes nest.
SynchronousStreamScope[common]
class SynchronousStreamScope(stream: Stream)
While open, every op dispatched on the calling thread waits for completion before the dispatch returns, and stream runs at most one task at a time. Open it only on a quiescent stream (synchronize first); thread-local.
Table[common]
class Table
A columnar frame: an ordered set of named, typed columns sharing one row count. Build one with create and addColumn / addStringColumn or read a CSV; read a column back as a tensor or a cell by row and column; the verbs (select, head, sortBy, filter, groupBy, join, ...) each answer a new frame and leave the source unchanged; the in-place operations (applyScalar, applyColumn, assignColumn) change a column of this frame. AutoCloseable: close releases the frame.
Template[common]
class Template
A parsed, reusable text template (the engine the chat templates use): parse once, render against a JSON object of variables as often as needed. Malformed syntax fails at parse; an undefined variable in a strict position or a type error fails at render. AutoCloseable.
Tensor[common]
class Tensor
An N-dimensional array on a device, with a shape, a dtype and a placement. Build one through Tensors, move it with to, read it back with item and the typed array readers, and release it when done (the last release frees the storage).
TensorCallback[common]
fun interface TensorCallback
A callback carrying a tensor: Tensor.onComplete's notification. The Tensor handed in is the callback's for the duration of the call only: whatever reference it does not Tensor.release itself is released when the callback returns. A callback that needs the value past its return reads it out (Tensor.item, the array readers) inside the call.
Tensors[common]
object Tensors
The tensor factories and data entry.
TensorSpec[common]
class TensorSpec(val name: String, val dtype: DType = DType.FLOAT32, val dims: LongArray = LongArray(0), val optional: Boolean = false, val dimNames: List<String> = emptyList())
A named, typed tensor slot of a model's contract. A dims entry equal to DYNAMIC_DIM resolves at run time and an empty dims leaves the shape unconstrained; dimNames is empty or dims-long with "" for an unnamed dim, and the same name on two slots declares one size; optional marks an input the model runs without.
Token[common]
data class Token(val id: Int, val text: String, val begin: Long, val end: Long, val special: Boolean)
One token of Tokenizer.tokenize: its id, the surface text it spells, the half-open byte span [begin, end) it covers in the source text, and whether the tokenizer injected it itself (special: bos, eos, ...) rather than reading it from the input.
Tokenizer[common]
class Tokenizer
A loaded tokenizer: text to ids and back, the tensor-shaped batch forms, the model's chat template, and a streaming decoder for generation.
TracingScope[common]
class TracingScope
While open, the calling thread builds a LAZY graph: ops return unscheduled tensors that carry their lineage and no kernel runs; Tensor.synchronize materializes one. Thread-local.
TransformReport[common]
class TransformReport
What one transform of the list did: the iterations in which it changed the graph, a failure (undone and skipped, the graph still correct) with its code and message, and whether it still fired when the cap stopped the run.
TruncationSide[common]
enum TruncationSide : Enum<TruncationSide>
Which end of a too-long sequence truncation drops; RIGHT keeps the head.
VideoData[common]
class VideoData(val batch: FrameBatch, val info: VideoInfo)
A whole decoded clip (batch: every frame in order) plus its stream facts.
VideoInfo[common]
data class VideoInfo(val totalFrames: Long, val fps: Double, val durationSeconds: Double, val width: Int, val height: Int, val codec: String, val pixelFormat: String)
A video stream's static geometry and timing, read from its header. The frame count reads 0 where the container cannot establish it; the index reads then refuse an out-of-range frame by name.
VideoMetadata[common]
data class VideoMetadata(val totalFrames: Long = 0, val fps: Double = 0.0, val durationSeconds: Double = 0.0)
The timing facts of a decoded clip; only fps-based sampling reads them.
VideoProcessOptions[common]
data class VideoProcessOptions(val numFrames: Long? = null, val fps: Double? = null, val image: ImageProcessOptions? = null)
Per-call overrides of VideoProcessor.process: the temporal sampling (numFrames sampled uniformly, 0 keeps every frame; or a target fps, which needs the clip's timing) and per-frame spatial overrides in image.
VideoProcessor[common]
class VideoProcessor
A configuration-driven video preprocessor: temporal frame sampling over the per-frame image pipeline, to a [sampled, H, W, C] Float32 clip. It takes decoded frames ([T, H, W, C] UInt8), or a file or payload it decodes through the ffmpeg command the host provides (Io.videoCapability). AutoCloseable: close releases it.
VideoReader[common]
class VideoReader
A lazily opened video: open reads the header only, info reports the stream facts, and each read decodes exactly the frames it names. The decode runs through the ffmpeg command the host provides (Io.videoCapability). AutoCloseable: close releases the reader and its decoder state; a released reader refuses every call.
VoidCallback[common]
fun interface VoidCallback
A callback with no payload: the deleter of a wrapped buffer (Tensors.fromBlob / Tensors.fromBlobStrided). The runtime runs it exactly once, when the last reference to the wrapping tensor drops, on whichever thread that happens; the callback already holds the buffer it is being told to release, so nothing is passed.