Treatment load

ml/models/whisper::load


Configuration

⬡ whisper: ml/models/whisper::Whisper

Inputs

⇥ safetensors: Stream<string>
⇥ tokenizer: Block<string>

Outputs

↦ error: Block<string>
↦ failed: Block<void>
↦ loaded: Block<void>


Load weights into a Whisper model.

Collects all .safetensors shard paths from safetensors (stream closes when all shards have been emitted), then memory-maps the weight shards and starts the decode worker thread inside the Whisper model.

loaded is emitted when the model is ready to accept audio. If any step fails, failed and error are emitted instead and loaded is never sent.

ℹ️ Wire safetensors directly from a fetch treatment.

⚠️ decode will silently drop audio until load has successfully completed.

graph LR
     T("load()")
     S["🟩 🟩 🟩 …"] -->|safetensors| T
     T -->|loaded| L["〈🟦〉"]
     T -->|failed| F["〈🟦〉"]
     T -->|error|  E["〈🟨〉"]

     style S fill:#ffff,stroke:#ffff
     style L fill:#ffff,stroke:#ffff
     style F fill:#ffff,stroke:#ffff
     style E fill:#ffff,stroke:#ffff
use ml/repos/hf::HfHub
use ml/repos/hf::fetch
use ml/models/whisper::Whisper
use ml/models/whisper::load
use std/engine/util::startup

treatment example()
  model hub:     HfHub(repo_id = "openai/whisper-tiny")
  model whisper: Whisper()
{
    startup()
    fetch[hub=hub]()
    load[whisper=whisper]()

    startup.trigger   -> fetch.trigger
    fetch.safetensors -> load.safetensors
}