Runtime state machine

Defines valid runtime states and operations across initialization, model loading, ready, generating, reset, replacement, error recovery, and model release.

Experimental
Last verified
2026-06-25 00:00 UTC
Updated
Reading time
2 minutes

Defines valid runtime states and operations across initialization, model loading, ready, generating, reset, replacement, error recovery, and model release.

Implementation evidence: this topic is grounded in the reviewed GGUF.MiRust.com source snapshot. It documents observed code and artifacts without claiming broad deployment, model quality, or production readiness.

Architecture topic: this page does not claim that the WordPress website implements or executes the described runtime behavior.

Logical states

{table(‘Runtime lifecycle’, [‘State’,’Resident data’,’Allowed operations’], [(‘Uninitialized’,’No Runtime value’,’init_runtime; most exports lazily initialize before reporting an operation error.’),(‘Initialized’,’Diagnostics and configuration only’,’load_model; sampling configuration.’),(‘Ready’,’Model, tokenizer, KV cache, scratch, logits’,’generate; set sampling; reset; free; replace model.’),(‘Continuation ready’,’Prompt and generated tokens plus KV state’,’generate_next_token; reset; free.’),(‘Recoverable error’,’Model may remain resident; last_error set’,’Correct configuration/input and retry; inspect diagnostics.’),(‘Freed’,’No model, cache, scratch, or logits’,’load_model; generation returns ModelNotLoaded.’)])}

Transactional load behavior

Model bytes are parsed and validated before the new runtime model is installed. A failed load records the error and leaves generation disabled in the browser.

Request-state cleanup

Each new generate clears prior tokens, output, and diagnostics request counters. A context-rejected request does not leave partially prefetched state.

Concurrency boundary

The global mutex serializes native or WASM callers, but the browser currently calls from one UI thread. Multiple browser sessions or models require an explicit handle-based runtime rather than additional globals.

Scope

This starter page defines the questions, boundaries, evidence, and failure modes that should be recorded before a capability is presented as supported.

Engineering considerations

  • Identify the source, version, target environment, and owner.
  • Separate observed values from estimates and externally reported values.
  • Record trade-offs, unsupported cases, and fallback behavior.
  • Link performance statements to a compatible benchmark methodology.

Verification questions

  • What exact artifact, revision, backend, and environment were reviewed?
  • Which assumptions could change the result?
  • Which data should be retained so another engineer can reproduce the conclusion?