Inference backends#
What you’ll learn: the canonical request form, the registered inference backends and their config knobs, deployment sampling vs. algorithm-tier sampling, the evaluation record store, and how to add a backend of your own.
The canonical request form#
Every backend speaks the same canonical form, an ordered list of messages whose content is a sequence of typed parts:
from eyas.backends.base import ChatRequest, ImagePart, TextPart, system_message, user_message
request = ChatRequest(
messages=(
system_message("You are a helpful assistant."),
user_message(ImagePart(image="/data/images/a.jpg"), TextPart("What color is the square?")),
),
request_id="a:identity",
)
ImagePart accepts a local path, a URL, or a preloaded LoadedImage payload. Template rendering is deliberately not part of this layer: the in-process engine (vLLM) renders the messages with the model’s chat template on the client side; the OpenAI-compatible backend sends the messages and lets the server render. That split is what keeps both shapes behaviorally identical for the same weights and template.
Responses are uniform too: ChatResponse.text is the clean answer (inline thinking is stripped into reasoning by the normalizing wrapper that sits in front of every engine), finish_reason records truncation/over-window events, and usage carries token counts.
The two inference backends#
Name |
Class |
Install |
Typical use |
|---|---|---|---|
|
In-process vLLM engine |
|
Throughput runs on your own GPU |
|
OpenAI-compatible HTTP client |
|
Any remote endpoint serving |
The registry carries one more entry beyond these two: the framework’s scripted in-repo test backend, the zero-GPU fixture the whole tests/ contract suite drives every task and strategy through (it is what the contract-test sections of the custom-task and custom-method tutorials point at).
In-process engine (vllm)#
backend:
name: vllm
params:
model_path: /path/to/Qwen3.5-9B # local checkpoint directory
max_inflight: 512 # client-side concurrency window
prefetch_workers: 8 # multiprocess image prefetch (0 = off)
engine_kwargs: # passed straight to the engine
enforce_eager: true
max_num_batched_tokens: 16384
sampling:
temperature: 0.0
max_new_tokens: 1024
max_inflightis the client-side in-flight window: requests slide in continuously, no batch barriers. Raise it until the engine saturates; theEYAS_MAX_INFLIGHTenvironment variable overrides it without touching the config (invalid values fail fast).prefetch_workers > 0enables the framework’s image prefetch loader: images are decoded in worker processes and handed to the engine as loaded payloads, so the GPU never waits on disk.engine_kwargsare engine-native; tune them for your card and serving profile.
WSL2 and small GPUs#
WSL2: vLLM 0.25 and later default to the V2 model runner, which requires CUDA
unified virtual addressing (UVA). WSL2’s GPU paravirtualization does not expose UVA, so
the engine fails at startup with RuntimeError: UVA is not available. Export
VLLM_USE_V2_MODEL_RUNNER=0 before launching to fall back to the V1 runner (same
results; slightly slower host-to-device staging). This is a vLLM variable, not an Eyas
one; native Linux is unaffected, and native Windows has no official vLLM build (its
WSL2/Docker path hits the same limitation).
Small cards: the lifecycle manager folds gpu_memory_utilization to measured free
memory minus the warmup reserve (EYAS_VLLM_WARMUP_RESERVE_GIB, default 4.5 GiB). On
an 8 GB card shared with a desktop, that default can fold the fraction below 0.5 and
the engine refuses to start. Lower the reserve (for example
EYAS_VLLM_WARMUP_RESERVE_GIB=1.0) and cap engine_kwargs.max_model_len /
max_num_seqs / max_num_batched_tokens. Measured here: a 2B INT4
(compressed-tensors) model over 74 pet images peaked at 7.4 of 8.2 GB and finished in
223 s; a 4B INT4 model needs noticeably more headroom.
OpenAI-compatible endpoints (openai)#
backend:
name: openai
params:
base_url: https://your-endpoint.example.com/v1/
model: qwen3.5-9b
api_key_env: MY_ENDPOINT_KEY # credentials come from the environment, never the config
max_inflight: 16
max_retries: 2
api_key_env names an environment variable holding the key: the backend fails fast at startup if it is unset, so secrets never land in configs or git. extra_body is the escape hatch for provider-specific request fields.
The fastest end-to-end path onto your own endpoint is the Getting started config: save quickstart_textvqa_opro.yaml, keep its openai backend section, fill base_url/model, and export the key named in api_key_env. Per-machine values can ride --set (--set backend.params.base_url=..., --set backend.params.model=...). Repository checkouts also have the docs story’s single-pass baseline pre-wired as the textvqa/raw cell’s openai variant: uv run eyas run --cell textvqa/raw --variant openai, or uv run eyas gen-configs --cell textvqa/raw --variant openai to export it as a file (developer path).
Sampling semantics: deployment layer vs. algorithm tiers#
backend.sampling sets deployment-level defaults (temperature, max_new_tokens, top_p, top_k, repetition_penalty, seed). The special three-state thinking flag (None = leave the server default, True/False = force on/off) controls reasoning-mode rendering.
Strategies that make optimizer-side generation calls (asking a model to propose or rewrite prompts) never hand-construct sampling configs. They call through a tier name (generate, evolve, gradient, …) and the framework merges:
the tier profile from the config’s
sampling_profilessection, algorithm intent only (temperature,top_p,max_new_tokens);deployment fields (
thinking,seed, …) always inherited frombackend.sampling.
sampling_profiles:
generate: { temperature: 0.9, max_new_tokens: 512 }
gradient: { temperature: 0.7, max_new_tokens: 1024 }
This is why a tier that forgot to set anything still respects your deployment defaults instead of silently reverting to server defaults, and why thinking/seed can never be overridden by algorithm code.
The evaluation record store#
In a run, requests and scores flow through the Evaluator, whose record store persists one durable record per (prompt, sample, split) (prediction plus scores), keyed by the prompt’s content hash. A store hit short-circuits inference entirely; that is the checkpoint mechanism described in Understanding results.
Watching throughput#
During large batches the scheduler emits [batch.progress] heartbeats (rate + ETA) and a [batch.stall] warning if 600 seconds pass with zero completions. A giant batch that is silently grinding is healthy: check for the heartbeat, not for console chatter. A watchdog terminates the process (exit 99) after 20 minutes of no activity at all, on the principle that a hung GPU job is worse than a dead one. Every threshold involved is tunable through the environment:
Environment-variable reference#
All knobs below are read from the process environment; unset means the listed default. The liveness defaults suit a local GPU engine. Slow remote endpoints need a raised watchdog threshold (a minutes-long remote round-trip is legitimate silence, not a hang; EYAS_WATCHDOG_STALL_SEC=3600 is the typical remote-endpoint setting).
Variable |
Default |
Effect |
|---|---|---|
|
|
Activity-watchdog threshold in seconds: no activity (engine interaction / batch completion) past it → hang diagnostics + |
|
|
Directory for the watchdog’s hang-diagnostics file ( |
|
|
Per-batch zero-progress alert: a dispatched batch with no new completion for this many seconds logs |
|
|
Minimum interval between repeated |
|
|
Poll interval of the zero-progress guard. |
|
|
Time backstop for |
|
unset (config value) |
Overrides |
|
|
Framework log level: |
|
|
GiB of GPU memory reserved for the vLLM warmup spike when the lifecycle manager folds |
|
unset |
Root directory for named-dataset path resolution when a task config omits explicit |
Two more environment facts, not user knobs: the vllm backend sets VLLM_USE_FLASHINFER_SAMPLER=0 at engine launch unless you already set it (the flashinfer sampler’s JIT fails in CUDA < 12.9 containers), and prefetch worker processes force CUDA_VISIBLE_DEVICES="" internally so media decode stays on CPU.
The GPU timing probe helper (scripts/probe_gpu_timing.py in a repository checkout) reads three variables of its own: EYAS_PROBE_MODEL_PATH (model weights directory), EYAS_PROBE_DATA_DIR (dataset JSON directory), and EYAS_PROBE_IMAGES_DIR (image directory). Their defaults are /path/to/... placeholders, so set all three to real paths before running the probe; the framework runtime never reads them.
Adding your own backend#
Implement the interface and register it:
from collections.abc import Sequence
from eyas.backends.base import ChatRequest, ChatResponse, InferenceBackend, SamplingConfig
from eyas.registry import register_backend
@register_backend("myengine")
class MyBackend(InferenceBackend):
async def agenerate(
self, requests: Sequence[ChatRequest], sampling: SamplingConfig
) -> list[ChatResponse]:
... # fan out, return one ChatResponse per request, in order
def close(self) -> None:
... # release engines/processes; optional — the run closes the backend after the loop
Rules of the road:
Return responses in input order, one per request; never raise for a single bad request if the batch can continue: encode per-request failure in the response (that is what
finish_reasonis for).Route sync calls through the provided
generate()helper: it uses the framework’s process-resident event loop; callingasyncio.runyourself will deadlock in-process engines.Bump the activity watchdog (
eyas.backends.vllmshows the pattern) on every engine interaction if you implement long-blocking calls.Verify backend-agnosticism: the same config with
nameswapped should produce statistically identical scores (the published benchmark’s backend-consistency experiment is exactly this check).
The worked example is examples/plugin_backend/ in a repository checkout: a third-party backend registered via the config plugins key (or entry points, for packaged plugins), with a runnable config and a CI test pinning the registration.
Next steps#
Reproducing the benchmark: both backend shapes exercised on public datasets.
Custom tasks covers the other side of the request: what gets asked.