Introducing a new way to review your PRs.

Read the announcement

debpalash / voicestudio

VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.

View on GitHub

26 documents · Updated Nov 23, 2026

docs / engine-routing

Inference engine routing

Inference engine routing chooses where an inference request can run and makes that choice visible before work starts. It combines engine capability data with a safe view of host hardware, then selects accelerated local execution, CPU execution, an isolated sidecar, or an approved remote worker without hiding a loss of acceleration.

Routing purpose

Routing is the decision layer between a product request and an inference engine. It helps the model-compute system select a usable engine while preserving clear limits for hardware, process placement, and fallback behavior. See Model compute for the wider compute model.

Engine capability model

Each engine declares the accelerator families it can use and whether it is ready in the current environment. A runtime-aware profile can replace this static view when a native executable discovers its own provider and device. The same capability surface also carries product hints such as supported languages, voice features, process placement, and an optional memory estimate. A sidecar may narrow its declared families when its installed runtime cannot use the host accelerator. IndexTTS, for example, does not claim ROCm acceleration when its resolved environment contains a CUDA-only torch build. Supertonic-3 declares CPU only because its ONNX runtime has no CUDA or MPS path. MOSS-TTS-v1.5 uses a separate environment and selects a usable torch accelerator at load time, but treats MPS as CPU because its model code is not supported there. Confucius4 selects an available torch accelerator at load time, but also treats MPS as CPU after validation showed that path was slower. Native engines such as OmniVoice GGUF, audio.cpp, and whisper.cpp declare possible native accelerator paths, but their runtime profiles do not claim acceleration until the native provider is verified. audio.cpp asks its selected binary for a device list and maps each reported device to a hardware family before routing. ASR engines use the same capability contract, so an engine with a broken native dependency can be marked unavailable before auto-selection rather than failing during transcription.

The catalogue keeps readiness and routing as separate facts. An availability probe can fail without hiding the other engines, and an available engine can return a user-facing advisory. TTS redacts Hugging Face-shaped tokens from probe errors and ASR scrubs probe errors before they reach the catalogue, so diagnostics remain useful without exposing credentials. Auto-selection also records a deep import failure and can move to the next independent ASR engine, while an explicitly selected engine keeps its named failure instead of changing behavior silently. The engine API returns the effective device, routing status, and reason so a selection can show a CPU fallback before inference begins. Native runtime details are included only when the runtime verifies its own device. A separate sidecar runtime can remain unknown when its installed accelerator stack cannot be checked cheaply; that state avoids claiming either a working GPU path or a CPU fallback before the child environment is known.

Isolated engines check their private environment and sidecar entry point without importing conflicting model packages into the parent process. The dots.tts resolver gives an existing user environment priority and can create a nearby compatible constraint file that changes only known broken pins. It does not replace the user's source or model data. The CosyVoice, VoxCPM2, IndexTTS, and Confucius4 paths keep their engine imports in separate environments. IndexTTS also keeps its heavy model import lazy, so readiness does not require a cold model load. OmniVoice subprocess isolation and the faster-whisper ASR sidecar use the parent environment because they add a killable process boundary rather than a separate dependency set. A slow import probe remains unproven rather than being treated as proof that the environment is missing. Native audio.cpp, GGUF OmniVoice, and whisper.cpp use installed native programs as their process boundary; their provider health is checked by the native runtime rather than inferred from the parent torch process. Native model files and binaries remain installed inputs, not hidden executable downloads during routing.

MOSS-TTS-Nano uses a dedicated installed environment because its upstream package and dependency pins must not enter the app environment. Its sidecar declares CUDA and CPU support, while the established in-process engine remains the effective fallback when that environment is not present. MOSS-TTS-v1.5 follows the same isolation goal for its conflicting transformers pin and keeps the public engine identity stable across a user environment, an app-managed environment, and the sidecar. Supertonic-3 can use the parent environment or an app-managed engine environment because its dependencies are compatible with the app, but it still uses a sidecar to contain crashes and cold-load delays. TTS catalogue entries expose availability, placement, effective device, and routing status together, so a ready engine can also carry a user-facing caveat without being treated as unavailable.

References: backend/…/tts_backend.py• L506-556 backend/…/tts_backend.py• L4110-4255 backend/…/asr_backend.py• L424-483 backend/…/asr_backend.py• L2808-2882 backend/…/asr_backend.py• L2885-2903 backend/…/asr_backend.py• L3162-3246 backend/…/engine_routing.py• L37-104 backend/…/subprocess_backend.py• L375-519 backend/…/sidecar_rocm_metadata.py• L1-24 backend/…/engines.py• L59-116 backend/…/engines.py• L977-1055 backend/…/backend.py• L30-84 backend/…/backend.py• L894-944 backend/…/compute.py• L166-206 backend/…/bootstrap.py• L235-365 backend/…/bootstrap.py• L471-680

Host capability snapshot

The host probe creates one cached snapshot of the accelerator families that the process can use. It checks CUDA or ROCm, Intel XPU, Apple MPS, and CPU. It treats DirectML as a known non-accelerated path rather than claiming that it is a supported torch device.

The probe does not load a model or make a network request. If it cannot import or use the accelerator stack, it returns a CPU-only result with a diagnostic note. This keeps the app usable on machines with no GPU or with a broken driver.

References: backend/…/device_caps.py• L1-27 backend/…/device_caps.py• L349-375 backend/…/device_caps.py• L405-577

Routing verdicts

The resolver compares engine targets with the host family and returns an effective device, a status, and an optional reason. An engine can supply a runtime-specific profile after a native executable verifies its own device. The status distinguishes a normal CPU engine from an unexpected CPU fallback.

StatusMeaningUser-facing effect
acceleratedThe host or selected runtime family is an engine target.Run on the accelerator. Show a notice only for a real kernel or memory caveat.
cpu_fallbackThe engine could use another accelerator but not this host's family or selected runtime.Run on CPU and explain the loss of acceleration.
cpu_onlyThe engine is CPU-native or the host has no usable accelerator.Run on CPU without a warning tone.
unavailableThe engine needs an accelerator that the host does not have and has no CPU path.Refuse the selection before later work fails.
n/aThe result is not a hardware-routing verdict.Used by network-style paths such as LLM providers.

The engine picker permits cpu_fallback because the request can still run. It blocks unavailable so a saved choice cannot knowingly break a pipeline. The selection response repeats the verdict and effective device for the UI. A sidecar or native CLI whose separate runtime has not been verified may report cpu_only or unknown, depending on the owning contract, instead of making a premature hardware claim.

References: backend/…/engine_routing.py• L26-58 backend/…/engine_routing.py• L68-104 backend/…/engine_routing.py• L186-343 backend/…/subprocess_backend.py• L497-519 backend/…/bootstrap.py• L403-680 backend/…/compute.py• L166-219 backend/…/backend.py• L40-55 backend/…/engines.py• L977-1055

Request placement

The request path can keep inference in the main process, place it in a local sidecar, run a fresh native process or a resident native server, or send an eligible task to an approved remote worker. Placement changes the resource and security boundary. Each path still uses the engine contract and must return a clear result or a named failure.

This diagram shows how an inference request moves from engine choice to a local, isolated, native, or remote execution target.

flowchart TD
    A[Inference request] --> B[Resolve engine and host capabilities]
    B --> C{Usable execution target?}
    C -->|In process| D[Run in app process]
    C -->|Sidecar| E[Run in isolated local process]
    C -->|Native runtime| F[Run fresh process or managed local server]
    C -->|Remote enabled| G[Run on approved capable worker]
    C -->|No valid target| H[Return named failure]
    D --> I[Return inference result]
    E --> I
    F --> I
    G --> I

Local execution

In-process engines load on demand and use the effective device chosen from the host snapshot. Before a TTS engine switch, the system can release other resident TTS models so a new model does not silently stack on the same memory pool. The same policy reaps resident sidecars when it switches away from them. It is enabled by default and can be disabled for hosts with enough memory. This supports engine changes without an app restart.

Model loading and inference have separate time budgets. A cold model may need time to download and load before generation begins. TTS loaders retry recognized transient model-download failures within a bounded budget, including one targeted reset when the shared Hub client is closed. The generation budget starts after readiness. Active progress is therefore evidence of work rather than a failed hardware check.

References: backend/…/engine_memory.py• L1-18 backend/…/engine_memory.py• L30-43 backend/…/engine_memory.py• L65-111 backend/…/tts_backend.py• L82-173 backend/…/tts_backend.py• L275-293 backend/…/tts_backend.py• L245-263

Sidecar execution

A sidecar is a local child process with a boundary from the main app. CosyVoice, VoxCPM2, IndexTTS, dots.tts, Confucius4, MOSS-TTS-Nano, and MOSS-TTS-v1.5 use private environments when their dependency or runtime needs differ from the parent. IndexTTS, MOSS-TTS-v1.5, Supertonic-3, and OmniVoice load heavy model packages only after the sidecar sends its ready signal. Supertonic-3 normally uses the parent environment because its CPU-oriented SDK dependencies match the app, but the installer can provide a private environment without changing its public route. The OmniVoice subprocess and faster-whisper ASR paths also use the parent environment, but their purpose is crash and timeout recovery rather than dependency isolation.

The parent owns the sidecar lifecycle. The sidecar sends a ready signal before heavy model imports and progress during cold environment resolution, model loading, or large weight downloads. OmniVoice, IndexTTS, MOSS-TTS-v1.5, Supertonic-3, and VoxCPM2 keep their import-time paths light, then load the model lazily after the ready signal. OmniVoice also keeps reference-audio transcription inside the killable child when needed, so that work uses the same recovery boundary as speech generation. MOSS-TTS-Nano and MOSS-TTS-v1.5 run their upstream runtimes from dedicated environments and use bounded receive budgets for cold model loading. Supertonic-3 uses a longer bounded budget because its CPU sidecar can download and initialize a large model on first use. This lets the parent distinguish active slow work from a silent failure. VoxCPM2 retries transient checkpoint-download failures and keeps a long receive budget while progress is active. OmniVoice allows up to 120 seconds for the sidecar to become ready and uses a 300-second receive budget by default, so valid cold or MPS work is not killed too early. When the receive budget expires, the parent hard-kills and respawns the child. IndexTTS and VoxCPM2 use long, finite receive budgets and send periodic liveness frames during cold loading and synthesis. OmniVoice also sends liveness frames during reference-audio transcription, so a slow reference pass is not mistaken for a dead child. The faster-whisper sidecar loads its model lazily after the ready signal and can reduce its compute type when the selected GPU cannot run the preferred type. CosyVoice, VoxCPM2, IndexTTS, MOSS-TTS-v1.5, Supertonic-3, and ASR keep library output away from the framed protocol and reject unsafe request values where their contracts require it.

An idle sidecar can be reaped to release its process and accelerator memory. A later request starts it again. If a sidecar stops responding, the parent kills it and keeps ownership until the process tree is fully reaped before it permits reuse. When a managed environment is replaced, a revision mark makes the next request restart the sidecar against the selected environment rather than reuse an older child. On MPS, a child that closes its pipe during generation produces a named memory-pressure error rather than taking down the backend process. In-process ASR cannot kill a native transcription thread safely, so repeated timeouts recommend the isolated ASR engine instead of switching to it without user consent.

References: backend/…/subprocess_backend.py• L353-405 backend/…/subprocess_backend.py• L492-590 backend/…/subprocess_backend.py• L629-695 backend/…/subprocess_backend.py• L783-930 backend/…/subprocess_backend.py• L986-1089 backend/…/subprocess_backend.py• L406-415 backend/…/sidecar_revisions.py• L1-14 backend/…/asr_backend.py• L94-147 backend/…/asr_backend.py• L150-250 backend/…/main.py• L210-245 backend/…/main.py• L94-154 backend/…/main.py• L145-181 backend/…/main.py• L388-427 backend/…/main.py• L470-513 backend/…/main.py• L107-151 backend/…/main.py• L221-287 backend/…/backend.py• L103-118 backend/…/main.py• L65-119 backend/…/main.py• L209-274 backend/…/main.py• L297-378 backend/…/main.py• L395-477 backend/…/main.py• L68-127

Native runtime execution

Native runtimes keep model execution outside the API process without requiring a Python sidecar protocol. The GGUF OmniVoice path can run each synthesis in a fresh native process or use a resident native server when that server is available. The resident path reuses a loaded model for normal requests, retries a failed server once, and then falls back to a fresh process. The audio.cpp path also runs a managed native server on loopback and reuses it across requests. The whisper.cpp ASR path runs a local CLI for each transcription and currently keeps acceleration unverified in its routing profile.

The runtime chooses a platform binary and a hardware-matched model or provider. Launch and health checks verify that the executable is present, valid, and usable before the engine is offered. The audio.cpp bootstrap keeps executable discovery separate from device discovery: an installed binary is found first, then its own device registry is queried with a short bound. A failed automatic device probe can use CPU, while an explicit backend or device request keeps its error visible. The GGUF readiness check covers the native binary and its runtime libraries. It does not require model weights because the selected pair can be fetched on first generation. A separate load probe checks that the binary starts without downloading weights. Native generation has a long hard deadline to reap a wedged process without killing valid slow CPU work. A resident server timeout stops the server and does not start a second path after the request budget is spent.

The GGUF runtime is treated as a separate hardware path when its bundled Vulkan module and driver verify a real adapter. It can report the native device and memory instead of borrowing the parent process's PyTorch result. On a CPU-only PyTorch host, the app may offer this path once for an AMD or Intel GPU. The offer names the GPU, selected quant, and download size. It changes the engine only after the user accepts, the model licence passes, and the weight download starts or is already complete. A decline is remembered and does not trigger a download. If a native GPU run crashes, the runtime retries the request on CPU and pins later GGUF requests to CPU for the rest of the session.

The managed audio.cpp server uses a launch-specific model identity. The parent verifies that identity before sending speech text or reference paths, so a different local listener cannot receive an inference request. The server loads its model lazily and limits residency to the served model.

References: backend/…/backend.py• L894-944 backend/…/backend.py• L963-1072 backend/…/backend.py• L1195-1249 backend/…/backend.py• L1289-1607 backend/…/backend.py• L1668-1764 backend/…/backend.py• L1851-1885 backend/…/compute.py• L90-146 backend/…/compute.py• L166-219 backend/…/gpu_offer.py• L1-19 backend/…/gpu_offer.py• L56-125 backend/…/quants.py• L180-228 backend/…/bootstrap.py• L317-365 backend/…/bootstrap.py• L441-680 backend/…/__init__.py• L305-399 backend/…/__init__.py• L412-457 backend/…/backend.py• L30-84 backend/…/engines.py• L472-550

Remote worker execution

Remote workers extend placement to another approved machine. The control plane sends only supported task types to a connected worker that has the requested engine, capacity, and required protocol features. A warm model is preferred when the other conditions are equal.

Remote placement is opt-in. If a worker is busy, the task waits. If no approved worker can run the task, the request fails instead of waiting without a possible destination. A lost connection gets a grace period and a result is not run twice only because the link briefly failed. See Remote workers for the worker lifecycle and trust model.

References: docs/remote-workers.md• L146-200 docs/remote-workers.md• L181-193 docs/remote-workers.md• L215-227

Hardware compatibility

Hardware checks answer two questions: whether an accelerator family is present, and whether the installed runtime can launch the required kernels or provider. Routing uses both questions so a valid accelerator choice does not hide a known architecture problem.

Accelerator family checks

The host snapshot reports the preferred family and all usable families. A user override may select a detected family, but it cannot invent hardware. If the requested family is absent, routing keeps the detected family and records why the override was ignored.

ROCm is distinct from CUDA even though both appear through the torch CUDA interface. MPS uses unified memory rather than a directly measured dedicated VRAM pool. Native runtimes also need a binary for the host architecture. Confucius4-TTS declares CUDA, ROCm, XPU, NPU, and CPU paths. dots.tts offers only CUDA and CPU and refuses Windows rather than advertising an unsupported route. The CTranslate2 ASR engines declare CUDA and CPU only because they have no HIP path; ROCm hosts therefore use a CUDA-capable torch ASR path when available or receive an honest CPU fallback. audio.cpp resolves its actual native provider and device at run time. It maps Vulkan device names to likely CUDA, ROCm, or XPU families, while software Vulkan adapters count as CPU work for automatic selection. Explicit backend and device overrides can still target a reported native registry, but an automatic choice prefers real compute devices and falls back to CPU when discovery fails. GGUF uses a verified Vulkan adapter as its own native device path, even when the parent PyTorch probe reports CPU. whisper.cpp lists Vulkan, CUDA, MPS, and CPU as possible native paths, but its current runtime profile remains unverified and therefore uses CPU routing estimates. A private sidecar's ROCm claim is narrowed when its installed torch metadata proves that the environment has no HIP build. If that metadata is not available, routing keeps the result unverified instead of guessing.

References: backend/…/device_caps.py• L38-55 backend/…/device_caps.py• L383-403 backend/…/device_caps.py• L529-567 backend/…/asr_backend.py• L658-680 backend/…/asr_backend.py• L1116-1120 backend/…/asr_backend.py• L2941-3013 backend/…/subprocess_backend.py• L497-519 backend/…/sidecar_rocm_metadata.py• L7-24 backend/…/sidecar_install.py• L366-396 backend/…/main.py• L144-169 backend/…/__init__.py• L69-114 backend/…/bootstrap.py• L235-365 backend/…/bootstrap.py• L471-701 backend/…/compute.py• L90-125 backend/…/compute.py• L197-224 backend/…/backend.py• L30-55 backend/…/main.py• L68-127

Runtime compatibility checks

The shared runtime check compares the device architecture with the installed torch build. CUDA and ROCm use different architecture names, so the check avoids treating every ROCm device as incompatible. A mismatch remains an accelerated route with a visible kernel-risk caveat because the actual launch may still fail. IndexTTS adds a model-specific safety check on ROCm: it tests one BF16 operation in a child process. If the operation fails or times out, the model uses FP32 instead of letting a kernel fault kill the sidecar.

Sidecars with their own torch build add one more boundary to this check. The parent can read cheap wheel metadata, but that metadata does not prove that the sidecar can execute kernels on the selected GPU. The route therefore stays unverified until the sidecar environment can support a reliable claim; a proven non-HIP wheel removes the ROCm target and allows the normal CPU decision.

ASR adds checks for native library health before it selects CTranslate2 engines. The CTranslate2 cuDNN and executable-stack checks can mark WhisperX or faster-whisper unusable so auto-detection falls through rather than taking down the backend. Before model load, the ASR path also compares free VRAM with the selected model and compute type. It lowers the compute type or uses CPU before a native out-of-memory abort can occur. At load time, an unsupported compute type follows the same lower-cost chain.

Native runtimes add a second check. The installed executable must expose a usable provider and device before routing can report acceleration. audio.cpp accepts host VRAM only when the selected native device has the same normalized name as the host device and is the only matching native peer. Otherwise its selection keeps memory unknown instead of borrowing a value from a different device. GGUF verifies the Vulkan adapter through its own native probe before it reports accelerated routing. whisper.cpp currently checks that its binary and model exist, but it does not yet verify the provider it will open, so its profile remains CPU-only and uses the CPU timeout budget. This avoids claiming that a parent-side VRAM figure belongs to a different native device.

An engine memory floor is advisory for dedicated CUDA and ROCm devices. OmniVoice uses a 6 GB floor to warn about hosts where a normal render may be too slow. The same discrete-memory rule does not apply to MPS unified memory. GGUF sizes its native quant from the verified adapter's effective memory, including shared memory for an integrated GPU.

References: backend/…/device_caps.py• L281-347 backend/…/engine_routing.py• L107-183 backend/…/engine_routing.py• L217-279 backend/…/subprocess_backend.py• L503-519 backend/…/sidecar_rocm_metadata.py• L7-24 backend/…/asr_backend.py• L270-311 backend/…/asr_backend.py• L682-749 backend/…/asr_backend.py• L776-888 backend/…/asr_backend.py• L1135-1224 backend/…/main.py• L209-303 backend/…/main.py• L388-427 backend/…/main.py• L103-127 backend/…/bootstrap.py• L429-680 backend/…/compute.py• L115-224 backend/…/backend.py• L244-267 backend/…/backend.py• L40-55 backend/…/__init__.py• L48-59

Optimization compatibility

Optional acceleration features are optimizations, not requirements. The system skips compile or specialized kernels when the platform, package, architecture, user setting, or prior runtime failure makes them unsafe. It then uses the regular eager path.

This keeps a failed optimization from becoming a failed inference. A runtime failure disables the affected optimization for the current process. A later app restart can probe it again.

References: backend/…/engine_env.py• L27-36 backend/…/engine_env.py• L106-197 backend/…/engine_env.py• L234-297 backend/…/engine_env.py• L367-425

Fallback decisions

Fallbacks are deliberate decisions, not silent substitutions. The system prefers a clear slower path over a hidden change in device or voice behavior. It stops early when no valid path exists.

Selection-time decisions

The engine picker checks dependency readiness and the routing verdict before saving a choice. It allows cpu_fallback because the request can still run. It rejects unavailable because saving that choice would make later work fail for a known reason. The response returns the same verdict so the UI can explain a slower selection immediately. Generation paths repeat the availability and routing checks before they create a live TTS backend, so a stale or invalid engine setting does not silently become OmniVoice.

ASR auto-detection treats a failed availability probe or a broken deep import chain as a reason to try the next independent engine. It performs installed-model checks for each fallback candidate before loading it, so a fallback does not trigger an unexpected multi-gigabyte download. An explicitly pinned ASR engine does not get replaced silently; its actionable load error is returned instead. whisper.cpp is eligible only when its binary and model are present, while its native acceleration remains unverified.

The GGUF GPU offer is a user-approved promotion from the CPU route to a native Vulkan route. It is shown only when the bundled runtime and adapter are verified, PyTorch has no usable accelerator, and no environment pin blocks the engine. Accepting it checks the licence and starts or reuses the selected weight download before saving the engine choice. Declining it keeps the current engine and suppresses the offer on later checks.

References: backend/…/engines.py• L529-550 backend/…/engines.py• L977-1055 backend/…/engine_routing.py• L157-165 backend/…/tts_backend.py• L4341-4430 backend/…/asr_backend.py• L68-84 backend/…/asr_backend.py• L2885-2903 backend/…/asr_backend.py• L3162-3246 backend/…/backend.py• L1061-1072 backend/…/compute.py• L222-299 backend/…/gpu_offer.py• L56-125 backend/…/backend.py• L68-84

Runtime default decisions

The default OmniVoice resolver prefers the GGUF runtime only when its binary passes availability checks and a launch probe succeeds. A probe failure returns the existing in-process OmniVoice engine so application start and voice generation still have a working path. The fallback also keeps a broken or missing native binary from blocking app start. Model weights are a first-generation readiness concern rather than a default-engine probe requirement. On MPS, the effective omnivoice implementation instead uses the killable subprocess class while keeping the same engine identity and controls. The explicit omnivoice-subprocess route is also available on every host for operators who want the same containment elsewhere. A child that stops during MPS generation returns a clear memory-pressure message so the user can retry after reducing memory use or selecting a smaller engine. These failures remain visible in engine compatibility information.

MOSS-TTS-Nano uses its dedicated sidecar when the installed environment is ready. If that environment is absent, the effective backend keeps the established in-process engine available while the sidecar route reports that it needs installation. This separates a missing optional isolation environment from a loss of the public engine contract.

MOSS-TTS-v1.5 uses its sidecar only after a working user-managed or app-managed environment is found. Its default bootstrap installs the CUDA package set and therefore blocks one-click installation on hosts without NVIDIA hardware; a manually prepared CPU or Mac environment can still be resolved. A slow import probe remains eligible instead of forcing a reinstall. Supertonic-3 has no alternate accelerated route: its default remains a CPU sidecar, and an unaccepted license or missing package makes it unavailable rather than selecting a different voice engine.

The GGUF route applies the same rule to the native binary itself. A missing, invalid, or failed-probe binary selects the in-process engine for the default route, while an explicitly selected GGUF engine keeps its named failure. A verified Vulkan device can be offered as an explicit user choice, but it never silently replaces the current engine. If a selected native GPU run crashes, the GGUF runtime retries on CPU and keeps later GGUF work on CPU for the session; an illegal-instruction result instead marks the unchanged binary incompatible until it is replaced.

References: backend/…/backend.py• L410-490 backend/…/backend.py• L578-627 backend/…/backend.py• L963-1072 backend/…/backend.py• L1834-1871 backend/…/compute.py• L280-299 backend/…/__init__.py• L24-60 backend/…/bootstrap.py• L100-175 backend/…/backend.py• L118-159 backend/…/__init__.py• L92-171 backend/…/bootstrap.py• L441-680

Run-time recovery

Inference can fail after selection because a download, driver, process, or worker can change state. Model downloads retry bounded network failures, including the VoxCPM2 cold-load path. TTS model loading also retries a closed shared Hub client once without spending the normal download retry budget. Sidecars retry their launch path. Remote tasks can retry after a worker-loss grace period. A sidecar that timed out remains quarantined until its owner exits, which prevents an immediate retry from sharing a dead or still-running process. The retry preserves the original engine and request contract rather than silently switching to a different voice or model.

ASR guards whole-file and chunked transcription with a wall-clock limit. When an in-process native call times out, the system abandons the request and keeps the worker accounted for until the call exits; it does not immediately overlap a second native call. Pool reset is used only where the caller owns a killable recovery path. Consecutive timeouts recommend the crash-isolated ASR engine, but the system does not switch engines automatically. Faster-whisper and WhisperX lower compute precision or move to CPU for supported hardware and memory failures instead of treating those failures as an engine loss. whisper.cpp uses the file deadline around its native transcription process, so a slow or stuck CLI does not run without a bound.

When a sidecar import probe times out, the result is unproven, not no. A candidate that may be slow stays eligible. A candidate that proves it cannot import the engine is discarded. This avoids turning a slow disk or cold torch import into a false missing-install report. Sidecars also send progress or heartbeat frames while a valid cold load or long synthesis is active, so the parent does not confuse slow work with a hung process. Faster-whisper degrades from an unsupported preferred compute type to a supported lower-precision or CPU type instead of treating that optimization mismatch as an engine loss. GGUF retries one native GPU crash on CPU and keeps later GGUF work on CPU for the session; an illegal-instruction result instead marks the unchanged binary incompatible until it is replaced.

References: backend/…/tts_backend.py• L82-173 backend/…/asr_backend.py• L45-250 backend/…/asr_backend.py• L253-291 backend/…/asr_backend.py• L1151-1224 backend/…/subprocess_backend.py• L295-377 backend/…/_venv_probe.py• L24-41 backend/…/_venv_probe.py• L109-155 backend/…/main.py• L68-127 backend/…/main.py• L94-154 backend/…/main.py• L145-181 backend/…/main.py• L388-427 backend/…/main.py• L470-513 backend/…/main.py• L65-119 backend/…/main.py• L209-274 backend/…/main.py• L297-378 backend/…/main.py• L328-409 backend/…/backend.py• L244-320 backend/…/backend.py• L264-285 backend/…/backend.py• L1699-1740 backend/…/backend.py• L86-147 docs/remote-workers.md• L195-233

Engine installation decisions

Sidecar installation is resumable and checks source, environment, dependencies, and weights as one readiness chain. It keeps app-managed installs separate from user-managed clones and does not delete a user path. A partial install is repaired or resumed instead of being reported as ready. IndexTTS also accepts the upstream and legacy checkpoint config names, then repairs stale absolute checkpoint paths in a temporary in-memory copy. The installed model files remain unchanged.

For dots.tts, bootstrap first tries a working user or app environment. If the upstream constraint set contains known incompatible pins, it writes a nearby compatible copy that changes only those pins and keeps relative references valid. It does not remove model data or replace the source environment during a retry. MOSS-TTS-v1.5 uses the same user-first rule, then creates an app-managed environment only when its clone is available and the host supports the CUDA install recipe. Supertonic-3 can install as a package in an engine environment or use the app environment, and it records a completed import check before the engine is considered ready.

Managed repairs use a fresh generation beside the active checkout. The installer copies the usable source while leaving the live environment in place, validates the replacement, and changes the selected path only at the final promotion step. A failed repair is removed when it has not been promoted. This keeps the last known-good sidecar available while a ROCm or dependency repair runs, and a revision counter tells the sidecar owner to restart against the new selection.

External install steps run under an independently terminable operation owner. This lets a timeout or backend shutdown clean up the whole process tree, including helpers that outlive the direct child, without relying on process discovery.

References: backend/…/sidecar_install.py• L1-45 backend/…/sidecar_install.py• L245-396 backend/…/sidecar_install.py• L770-785 backend/…/sidecar_install.py• L1206-1325 backend/…/sidecar_install.py• L1414-1495 backend/…/sidecar_install.py• L1755-1898 backend/…/sidecar_install.py• L1901-2047 backend/…/sidecar_generations.py• L12-80 backend/…/sidecar_revisions.py• L8-14 backend/…/bootstrap.py• L204-221 backend/…/main.py• L301-381 backend/…/bootstrap.py• L187-256 backend/…/install.py• L6-27 backend/…/contained_subprocess.py• L382-428

Process security

Process placement creates a boundary around code that may have different dependencies and failure behavior. The boundary limits what the child can ask the parent to do, contains its process tree, and prevents malformed messages from causing unbounded resource use.

Sidecar process boundary

The parent and sidecar use a bounded framed protocol with an allowlist of accepted operations. Unexpected operations are dropped. Oversized frames are refused before allocation. A silent or unready sidecar is terminated. If a timeout kill cannot finish at once, the process remains owned and blocks reuse until cleanup succeeds. OmniVoice sends its frames through a private file descriptor and redirects library output away from that channel, so model logs cannot corrupt the control stream.

The protocol stream is separate from library output. Sidecars duplicate the frame channel and redirect ordinary standard output to standard error, so progress bars and native library logs cannot corrupt the parent’s frame reader. OmniVoice, IndexTTS, VoxCPM2, MOSS-TTS-v1.5, Supertonic-3, and Confucius4 perform this separation before or during their heavy imports and keep the private frame channel for ready, progress, audio, and error messages. The parent drains that error output through its redaction path. Parent death and operation timeout both clean up the owned process tree. The faster-whisper sidecar uses the same private frame-channel rule and validates its decode and request options before calling the model. OmniVoice, IndexTTS, MOSS-TTS-v1.5, and Supertonic-3 limit forwarded generation controls to their known model surfaces. OmniVoice also keeps its reference-audio transcription and generation inside the same framed child boundary.

The parent forwards only JSON-safe request values. Public health responses replace detailed child errors with safe messages. CosyVoice and VoxCPM2 accept local reference paths only, so a synthesis request cannot make a sidecar fetch an arbitrary URL. A sidecar process also carries the revision of the environment it opened; a later managed installation cannot silently leave a child serving the previous environment.

References: backend/…/subprocess_backend.py• L28-37 backend/…/subprocess_backend.py• L75-103 backend/…/subprocess_backend.py• L406-415 backend/…/subprocess_backend.py• L451-539 backend/…/subprocess_backend.py• L729-835 backend/…/sidecar_revisions.py• L1-14 backend/…/contained_subprocess.py• L382-428 backend/…/contained_subprocess.py• L617-696 backend/…/main.py• L184-232 backend/…/main.py• L40-123 backend/…/main.py• L328-477 backend/…/main.py• L50-61 backend/…/main.py• L542-613 backend/…/main.py• L379-448 backend/…/sidecar.py• L384-459 backend/…/main.py• L315-379 backend/…/main.py• L252-325 backend/…/main.py• L233-288

Desktop parent liveness

Desktop-contained backend runs use the owning desktop shell's stdin pipe as a parent-liveness signal. When that pipe closes, the backend exits. Nested operation owners then receive their own cancellation signal and clean up their descendants. See Desktop application runtime for the shell that owns this boundary.

References: backend/…/parent_liveness.py• L1-33 backend/…/contained_subprocess.py• L35-55

Credential and path boundaries

A sidecar receives the credentials needed for its own model work through its process environment. Diagnostic and public error paths redact tokens and user paths. MOSS-TTS-v1.5 does not log the environment and requires an explicit audit plus immutable revision when a custom model uses executable remote code. Supertonic-3 passes a pinned model revision to the child and keeps its sidecar free of arbitrary code execution in the dispatch loop. Engine tasks identify a fixed engine rather than accepting an arbitrary executable path.

Sidecar installation avoids shell command strings and validates downloaded source extraction. Managed generations accept only marked, non-symlink paths inside the engine root, and preserved checkouts reject external links before they are copied. GGUF runtime launches use typed argument lists, verify the bundled executable and its listed runtime libraries before execution, and enforce checksums when a manifest is present. The GGUF path also limits reference audio to approved local roots and bounds conversion before decoding. audio.cpp writes its local server configuration with restricted permissions, binds the managed server to loopback, and checks a launch-specific model identity before sending speech text or file paths. Its bootstrap accepts an installed binary and local model cache only.

References: backend/…/engine_env.py• L300-346 backend/…/subprocess_backend.py• L455-463 backend/…/sidecar_install.py• L719-820 backend/…/sidecar_install.py• L1610-1721 backend/…/sidecar_generations.py• L12-80 backend/…/main.py• L63-80 backend/…/sidecar.py• L116-151 backend/…/backend.py• L217-241 backend/…/backend.py• L792-835 backend/…/backend.py• L963-1057 backend/…/backend.py• L706-727 backend/…/__init__.py• L317-429 backend/…/bootstrap.py• L326-353 backend/…/main.py• L315-323 backend/…/main.py• L252-261 docs/remote-workers.md• L248-263

Product flow relationships

Routing is shared by product flows that create or consume model output. It affects which TTS engine renders a voice, which ASR engine reads speech, and whether a localization job can use a local or remote execution target.

Product flowRouting concern
Voice generationSelect a ready engine and expose CPU fallback or hardware caveats before synthesis.
Speech inputKeep transcription usable when a GPU, compute type, or isolated ASR process cannot run as preferred.
Model lifecycleCoordinate loading, residency, unload, and recovery as engines change.
OmniVoice inferenceRelate OmniVoice's in-process, subprocess, and native runtime choices to model loading and voice output.
Remote workersPlace eligible work on an approved capable worker without hiding worker loss.

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the host capability probe, native provider discovery, and model-loader device choice aligned. A new accelerator family or override must update both the detection result and every consumer of the routing verdict.
  • Keep each engine's declared accelerator targets and memory hint aligned with its real loader or native provider path. A stale declaration can either block a valid host or label a CPU run as accelerated.
  • Preserve the distinction between cpu_only, cpu_fallback, unavailable, and an unverified sidecar or native route. UI notices and selection rejection depend on these meanings.
  • Keep runtime-specific profiles aligned with the device and provider that the executable really opens. Do not infer a native route from the parent PyTorch device. For audio.cpp, keep device-list parsing, provider-family mapping, explicit overrides, and CPU recovery aligned.
  • Keep the GGUF GPU offer eligibility, licence gate, remembered answer, weight-download state, and engine selection atomic from the user's point of view. An offer must not silently download weights or save an engine that lacks them.
  • When adding a sidecar operation, update both protocol allowlists and parent handling rules. Do not allow a child to select an arbitrary executable or parent action.
  • Keep the sidecar frame stream isolated from model-library output. A new engine must preserve the clean protocol channel and the matching frame cap on both sides.
  • When changing sidecar install layout, update interpreter probing, readiness checks, persisted paths, and user-managed install protection as one contract.
  • When changing managed repair or promotion, keep generation markers, path validation, preserved source copying, final selection, failed-generation cleanup, and sidecar revision updates aligned. The active generation must remain usable until its replacement passes verification.
  • When changing compatibility repairs, keep the source constraint file and generated compatible copy aligned with the resolver's relative-path rules. Do not turn a known pin repair into a broad dependency rewrite.
  • When changing ROCm sidecar support, keep host package selection, wheel metadata checks, routing status, and install health checks aligned. A CUDA or CPU wheel in a private environment must not be reported as a verified ROCm route.
  • When changing remote task support, update worker capability declarations and local placement rules together so unsupported work is not queued as runnable.
  • When changing a native runtime build, keep platform binary names, architecture selection, provider names, shared-library artifacts, and loader paths aligned.
  • When changing native device discovery, preserve the difference between automatic CPU recovery and explicit override errors. Do not reuse a parent VRAM value for an unmatched native device. For audio.cpp, keep the single-device name match rule and software-adapter treatment intact.
  • When changing process ownership, preserve both parent-liveness signaling and nested process-tree cleanup.
  • Keep the faster-whisper sidecar's compute-type candidates and model-selection environment names aligned with the parent ASR path. A mismatch can load a different model or turn a supported host into a false failure.
  • Keep ASR's CTranslate2 availability probes, ROCm exclusion, free-VRAM preflight, compute-type chain, and CPU recovery aligned. A change in one can turn a safe fallback into a native crash.
  • Keep ASR timeout handling aligned with pool ownership. An in-process timeout must not cause an overlapping retry, and the isolated-engine recommendation must not become an automatic engine switch.
  • Keep ASR auto-detection's shallow probes, deep-load fallback records, candidate-specific installed-model checks, and explicit-engine error behavior aligned. A change can turn a recoverable broken import into a startup failure or an unexpected model download.
  • Keep TTS model readiness, closed-client recovery, and generation-time engine resolution aligned. A loader retry must not bypass the availability or routing gate, and an unavailable selected engine must not silently become OmniVoice.
  • Keep the OmniVoice MPS resolver's public engine identity and controls aligned with the subprocess implementation. The placement can change without changing saved settings or product behavior. Keep its ready and receive budgets long enough for valid cold starts, reference-audio transcription, and generation while retaining hard-kill recovery for wedged native work. Keep reference-audio transcription inside the same child boundary.
  • Keep MOSS-TTS-Nano's dedicated environment, CUDA-or-CPU capability declaration, public engine id, in-process fallback, sample rate, and bounded cold-load timeout aligned. A mismatch can make the isolated route appear ready while its runtime cannot start or can break parity with the established engine.
  • Keep VoxCPM2's private-environment readiness, in-process fallback, reference-audio handling, retry policy, and fixed 48 kHz output aligned. The two placement modes must expose the same engine contract.
  • Keep IndexTTS's ready handshake, lazy model load, progress frames, output sample rate, accepted model config names, ROCm runtime claim, and BF16 safety fallback aligned with the parent engine contract. A change in one side can look like a timeout, false acceleration, or a bad audio result to the parent.
  • Keep Confucius4's ready handshake, clone-only reference requirement, language normalization, accelerator selection, MPS-to-CPU rule, and output sample rate aligned with its catalogue capability and parent contract.
  • Keep the GGUF default resolver's binary and runtime-library preflight, checksum and launch probe, native-provider verification, quant-map selection, CPU crash pin, timeout, and in-process fallback aligned with the compatibility view. A native runtime failure must not block startup or silently change an explicitly selected engine.
  • Keep whisper.cpp's declared native providers, binary and model readiness checks, native device overrides, process deadline, and runtime profile aligned. Until provider discovery is added, do not report its Vulkan or CUDA capability as verified acceleration.
  • Keep the single-engine residency policy aligned with both in-process caches and sidecar cleanup. A new engine can still cause memory pressure if its unload path does not release its process or model.

Important failure modes

TriggerConsequenceGuard
A host lacks the engine's only accelerator family.Selection is rejected before a later inference fails.unavailable routing status and selection gate.
An engine supports another accelerator but not the host family.Inference runs on CPU and can be much slower.cpu_fallback notice names the missing path.
A separate sidecar torch build cannot be checked on a ROCm host.The catalogue could claim a GPU route without proof.Report an unverified route until metadata is known; remove ROCm only when a non-HIP wheel is proven.
A native provider probe cannot find a device.Automatic native execution can fail or select the wrong runtime.Native discovery maps provider devices to hardware families and falls back to CPU only in auto mode.
A native CLI advertises a provider but does not verify the opened device.Routing can assign GPU timing or memory assumptions to a CPU run.The runtime profile reports CPU-only or unverified until provider discovery proves the device.
audio.cpp reports a software Vulkan adapter or a malformed device list.Automatic routing can claim GPU work or choose the wrong native device.Treat software adapters as CPU work and fail closed on malformed or unknown device entries.
audio.cpp device names do not identify the same unique host device.Native routing can use the wrong VRAM estimate.Keep native VRAM unknown unless the normalized name matches one native peer.
Runtime architecture is absent from the torch build.A kernel may fail after an apparently valid accelerator selection.Shared architecture check adds a kernel-risk caveat.
CTranslate2 is pointed at ROCm or lacks a required native library.ASR can crash during model load or falsely claim GPU support.CUDA-only capability declaration plus cuDNN and executable-stack availability checks route to another engine or CPU.
ASR free VRAM cannot hold the selected model and compute type.A native CUDA out-of-memory abort can take down the backend.Free-VRAM preflight lowers precision or selects CPU before model load.
An ASR transcribe thread exceeds its wall-clock limit.The request fails while the native call may still hold its worker and VRAM.Guarded timeout, no overlapping retry, pool reset only for killable callers, and an isolated-engine recommendation after repeated timeouts.
ASR auto-detection finds a broken deep import chain.A usable later ASR engine may be missed or a startup path may fail.Record the broken candidate, check the next candidate's installed model, and preserve errors for explicitly pinned engines.
IndexTTS BF16 appears supported but its ROCm kernel fails.A first model operation can crash the sidecar.A child-process BF16 probe selects FP32 when the operation fails or times out.
The native runtime binary or its listed shared library is missing or invalid.The native engine cannot start.Availability preflight and a named unavailable result.
GGUF model weights are not cached when the engine is selected.The first generation can fail or start a network download.Keep weight readiness separate from binary readiness; resolve the pinned pair at generation and return an install command on failure.
A GGUF native GPU run crashes.The request can fail and later GPU requests can repeat the crash.Retry once on CPU and pin later GGUF runs to CPU for the session.
A GGUF binary executes an instruction this CPU does not support.Every generation can fail until the binary is replaced.Cache the binary identity as incompatible and direct the user to a portable rebuild or the in-process engine.
A verified Vulkan adapter is available but the user declines the GGUF offer.The app stays on its current engine and does not use the native GPU path.Persisted decline state prevents a repeated offer or silent engine change.
The GGUF offer starts with an unaccepted model licence.The engine cannot switch until the licence is accepted.Licence check runs before engine selection and exposes the licence dialog path.
The GGUF weight download cannot start or another quant is downloading.The engine could be saved without the weights it needs.Start or reuse the matching download first and save the engine only after an accepted download result.
A native device is inferred from the parent PyTorch probe.Routing can report acceleration for a native process that will use CPU.Native runtime profile reports acceleration only after its own device is verified.
An audio.cpp listener is not the server created by the app.Speech text or reference paths could reach an unrelated local process.Loopback binding plus a launch-specific model identity check.
A sidecar import or environment bootstrap is slow.A working install could be falsely reported as missing or a valid request could lose its time budget.Tri-state probing and resolution heartbeats.
A sidecar library writes logs or progress bytes to the protocol stream.The parent reads corrupted frame lengths and loses the sidecar session.Duplicate a private frame descriptor, redirect standard output to standard error, and cap incoming frames.
A transient VoxCPM2 checkpoint download fails.A cold sidecar load stops even though the cache may resume.Bounded retries for classified network failures.
Supertonic-3 is offered as an accelerated engine.The product reports a GPU route that the SDK cannot run.CPU-only capability declaration and sidecar health text.
Supertonic-3 has no accepted license or installed package.The engine cannot be selected even if the host can run its CPU path.Availability gate requires the package and stored license acceptance.
MOSS-TTS-v1.5 has only a slow or unverified environment probe.A valid user install can be replaced or reported as missing.Tri-state probe keeps unproven candidates eligible after all candidates are checked.
MOSS-TTS-v1.5 is bootstrapped on a non-NVIDIA host.The CUDA dependency install cannot provide a usable one-click route.Host gate refuses the managed install and points to the manual CPU path.
A custom MOSS-TTS-v1.5 model uses mutable remote code.The sidecar could execute code that was not reviewed.Custom models require explicit trust and a 40-character revision SHA.
A resident GGUF server fails during a request.A reusable native process can return a bad result or block later requests.Stop and restart it once, then fall back to the per-request native process; do not retry after a timeout with spent budget.

Key files

FileWhy to read it
backend/…/engine_routing.pyDefines the common routing verdicts, runtime profile hook, native-versus-parent device distinction, VRAM caveat, and user notice rules.
backend/…/device_caps.pyDefines the host capability snapshot and hardware compatibility checks.
backend/…/tts_backend.pyDefines the TTS engine contract, readiness and download recovery, generation-time resolution, and capability metadata used by routing.
backend/…/subprocess_backend.pyDefines sidecar placement, runtime verification, environment revision handling, protocol lifecycle, timeout ownership, and idle resource release.
backend/…/sidecar_rocm_metadata.pyShows the conservative check that distinguishes a private ROCm torch build from an unverified sidecar runtime.
backend/…/sidecar_install.pyDefines host gates, resumable isolated engine installation, ROCm dependency selection, completion checks, managed repair, and user-install protection.
backend/…/sidecar_generations.pyDefines safe replacement generations for managed sidecar repairs.
backend/…/sidecar_revisions.pyDefines the revision signal that makes running sidecars follow a newly promoted installation.
backend/…/engines.pyShows how engine readiness, routing verdicts, sidecar installation, GGUF quant choices, and the explicit GPU offer reach selection APIs.
backend/…/asr_backend.pyDefines ASR capability declarations, device-aware auto-selection, native dependency checks, memory and compute-type fallback, deep-load fallback, and timeout recovery.
backend/…/main.pyShows crash-isolated ASR placement, parent-aligned device choice, compute-type fallback, and framed protocol handling.
backend/…/backend.pyShows native ASR binary and model readiness, process placement, device overrides, and the current unverified runtime profile.
backend/…/main.pyShows a private-environment sidecar with progress reporting, clean protocol output, and local reference-path checks.
backend/…/main.pyShows private-environment loading, transient download retry, cold-load progress, and the sidecar protocol.
backend/…/main.pyShows lazy IndexTTS loading, BF16 safety probing, liveness heartbeats, model-version compatibility, and clean framed output.
backend/…/main.pyShows dedicated-environment loading, transient model-load retry, public engine parity, and bounded cold-load timing.
backend/…/bootstrap.pyShows user-first environment resolution, CUDA-aware bootstrap, tri-state import probing, and cache invalidation.
backend/…/main.pyShows lazy model loading, device safety rules, pinned model sources, progress frames, and the sidecar protocol.
backend/…/backend.pyShows CPU-only capability reporting, license readiness, environment selection, and bounded sidecar timing.
backend/…/sidecar.pyShows pinned model loading, lazy CPU ONNX startup, progress reporting, request allowlisting, and framed output.
backend/…/__init__.pyShows killable OmniVoice placement, MPS-specific resolution, ready and receive timeout policy, memory-pressure recovery, and public engine identity.
backend/…/main.pyShows lazy model and reference-audio loading, clean framed output, liveness heartbeats across long stages, request validation, and the resident OmniVoice wire protocol.
backend/…/backend.pyShows native binary and shared-library preflight, checksum and launch checks, quant and weight handling, fresh or resident native placement, GPU-crash recovery, and default-engine fallback.
backend/…/compute.pyShows native Vulkan device verification, runtime routing metadata, memory-based quant tiering, CPU crash pin behavior, and GPU-offer eligibility.
backend/…/gpu_offer.pyShows the one-time user consent flow that prevents silent promotion to native GPU execution.
backend/…/quants.pyShows quant status, installed-weight checks, explicit downloads, and the relationship between the selected hardware and model weights.
backend/…/bootstrap.pyShows native binary discovery, model resolution, provider detection, device selection, matching native memory to the host, and CPU fallback.
backend/…/main.pyShows isolated lazy loading, accelerator selection, MPS-to-CPU fallback, and clean framed output.
backend/…/main.pyShows lazy sidecar loading, precision selection, and clean protocol output.
backend/…/bootstrap.pyShows user-first environment resolution, tri-state probing, and lazy bootstrap.
backend/…/install.pyShows narrow repairs for known incompatible dependency pins.
backend/…/contained_subprocess.pyDefines ownership and cleanup for nested engine and installer process trees.
backend/…/parent_liveness.pyDefines the desktop parent-loss signal for backend shutdown.
backend/…/engine_memory.pyExplains model residency control when TTS engines change.