agora.fleet.vram
VRAM pre-flight check.
Probes the system’s free GPU VRAM and the model’s estimated memory footprint,
then decides whether the model will fit. Runs asynchronously via
asyncio.create_subprocess_exec so it never blocks the event loop.
Failure modes (probe returns None) are treated as “unknown” rather than
“fits” — callers log and skip unless the user has opted out of the check.
Functions
|
Decide whether |
|
Heuristic model-size estimate when Ollama has no better answer. |
|
Query Ollama for the model's on-disk size; fall back to the heuristic. |
|
Return free VRAM in MiB, or |
|
Raise |
|
Load the model into VRAM before the real timeout clock starts. |
Classes
Verdict of the pre-flight free-VRAM probe. |
- class agora.fleet.vram.VRAMCheck[source]
Bases:
objectVerdict of the pre-flight free-VRAM probe.
fitsis the go/no-go;free_mibisNonewhen the probe could not read the device (in which case the caller decides whether to proceed), andreasonis a human-readable explanation for the log/error path.- __init__(fits, free_mib, required_mib, reason)
- async agora.fleet.vram.probe_free_vram_mib(device_index=None)[source]
Return free VRAM in MiB, or
Noneif no probe worked.device_index(when set) restricts the query to that single GPU — used when_resolve_target_device()has identified the device Ollama is using. WhenNone(device unknown), the fallback sums free VRAM across all visible devices rather than taking themin(): “all visible devices, summed” is a less-wrong default than “the device with the least free”, which on a two-GPU box reports the wrong card whenever the other one is fuller (the June 30 09:58 false-rejection).
- agora.fleet.vram.estimate_model_size_mib(model)[source]
Heuristic model-size estimate when Ollama has no better answer.
- async agora.fleet.vram.get_model_size_mib(model, base_url)[source]
Query Ollama for the model’s on-disk size; fall back to the heuristic.
- async agora.fleet.vram.check_model_fits(model, base_url, safety_margin_mib=512)[source]
Decide whether
modelwill fit in the system’s free VRAM.fits=Truewhen we can prove it fits.fits=Truewithfree_mib=Nonewhen the probe failed (we do not block on unknown).fits=Falseonly when we can prove it will not fit.Special case: if
modelis already loaded into VRAM (visible in/api/ps), no fresh allocation is needed — we returnfits=Truewithout demanding more free VRAM. This avoids a false negative when a previous run or warmup left the model resident.
- agora.fleet.vram.raise_if_wont_fit(check, model)[source]
Raise
AgoraErrorwhen a check proved the model will not fit.
- async agora.fleet.vram.warmup(model, base_url, deadline_seconds=600.0, keep_alive='30m')[source]
Load the model into VRAM before the real timeout clock starts.
Sends a tiny
/api/generaterequest with the suppliedkeep_alive(default30m) so the model stays resident for the duration of the run. The keep_alive value should match whatever the runtime adapter uses — otherwise the model can evict between warm-up and the first real turn. The timeout here is independent fromllm_timeout_seconds— model loading can legitimately take minutes on cold disks, but we don’t want that budget to eat the actual generation time on the first real turn.Raises
AgoraErroron timeout or HTTP error so the orchestrator fails fast before creating identity rooms.