Skip to content
Systems programming for what’s next.
— Vex

Inference ​

inference is an experimental model-execution package built on ml and Vex SIR. Its current implementation centers on memory-mapped GGUF weights, tokenization, sampling, and F16/F32 inference plans. It is separate from the core standard-library release scope.

Public API and current behavior ​

The following describes the inspected development source. It is a guide to choosing an entry point, not a model or hardware qualification report.

Entry pointCurrent behavior
Model.load(path)Loads a GGUF model and tokenizer; returns Model and panics on a load failure. It does not return a Result.
generate(&model, prompt, options)Uses the supported-weight F16 SIR plan. Unsupported weight routes panic rather than selecting a legacy CPU fallback.
GenerateOptions.default() / .greedy()Construct explicit token-count, sampler and end-of-sequence options.
stream(&model, prompt, options, callback)Generates the complete text, then calls the callback once. It is not incremental token streaming.
generate_typed<T> / stream_typed<T>Exported but currently stop at an unimplemented-specialization diagnostic; do not use these as working alternatives.
InferencePlanF32 / InferencePlanF16Lower-level plan construction, prefill, decode, and sampling surfaces for integration work.

The generation eligibility check recognizes F32, F16, Q4_0, Q8_0, Q4_K, and Q6_K projection/output weights. That check is only one prerequisite: a file's architecture, tensor shapes, tokenizer, context size, and backend operations must also match the implementation. The current loader is GGUF-specific; SafeTensors loading is not documented as an available path here.

Generation sequence ​

For a model and target already qualified by the package's tests, the API shape is:

vex
import { Model, GenerateOptions, generate } from "inference";

fn main() {
    let model = Model.load("models/qualified-model.gguf");
    let! options = GenerateOptions.greedy();
    options.max_tokens = 32;
    let text = generate(&model, "Hello", options);
    $println(text);
}

This integration example requires an actual compatible model file; it is not a self-contained smoke test and no expected model output is promised. The current high-level path also prints loading/generation diagnostics, so an application that needs a machine-readable response must not treat all stdout as generated text.

Model and cache ownership ​

The model retains the weight store and tokenizer. The loader's mapped storage backs weight views and must remain alive while they are used. Generation constructs a plan, prefills prompt tokens, and advances its KV state during decode. A repeated generate call should not be treated as an implicit conversation session or an API for reusing a previous call's KV cache.

The public surface also includes chat-template helpers, sampler utilities, quantized-row helpers, attention operations and LoRA structures. A declaration or export establishes availability in source; it does not establish complete model coverage or a completed application workflow.

Direction: Graph-Based Inference ​

SIR graphs expose compute to the compiler. They do not establish where weights are dequantized, how many device dispatches occur, or whether a workload stays on the GPU. Verify the complete loading → tokenization → prefill → decode → sampling sequence for the exact model, compiler binary and backend before depending on it. Record model identity, precision, context length and output checks alongside any throughput measurement.

The package source contains targeted tests under lib/std/inference/tests; these are starting points for qualification. This page does not claim a fresh end-to-end inference or physical-GPU run.

Released under the MIT License.