Skip to content

Request Validation

omnirt.validate() and the omnirt validate command check whether a request would run without touching the hardware: model existence, task compatibility, config field legality, dimension constraints, adapter / model compatibility.

Why validate before running on real hardware

  • Cheap: validation only reads the registry, presets, and schema — no weight loading, no GPU time
  • Predictable: a ValidationError points to the exact field, e.g. "width must be a multiple of 8", instead of a cryptic CUDA runtime error
  • Consistent: the same request validates identically on cpu-stub, cuda, and ascend

Minimal examples

from omnirt import validate
from omnirt.requests import text2image

req = text2image(model="sd15", prompt="a lighthouse", width=513)  # 513 isn't a multiple of 8
result = validate(req, backend="cpu-stub")
print(result.ok)          # False
print(result.errors)      # [("config.width", "must be a multiple of 8"), ...]
omnirt validate \
  --task text2image \
  --model sd15 \
  --prompt "a lighthouse" \
  --width 513 \
  --backend cpu-stub
# Non-zero exit code on failure; --json for machine-readable output
omnirt validate --config request.yaml --json

There is no separate /v1/validate endpoint yet; set "dry_run": true inside config to run validation only:

curl -sS http://localhost:8000/v1/generate \
  -H 'Content-Type: application/json' \
  -d '{
    "task": "text2image",
    "model": "sd15",
    "inputs": {"prompt": "a lighthouse"},
    "config": {"width": 513, "dry_run": true}
  }'

What validation covers

  1. Model existence — whether model (or an alias) is in the registry
  2. Task match — whether the model supports the task (via ModelCapabilities.tasks)
  3. Required fieldsprompt (text2image / text2video), image (image2image / image2video), audio (audio2video), etc.
  4. Numerical constraintswidth / height multiples, strength ∈ (0, 1], num_frames / fps ranges
  5. Preset legalitypreset ∈ {fast, balanced, quality, low-vram} and defined for this task + model
  6. Adapter compatibility — LoRA / ControlNet references must appear in ModelCapabilities.adapters
  7. Backend reachabilitybackend=cuda with torch.cuda.is_available()=False fails unless backend=auto

In production

The FastAPI server runs the same validate() before inference; a failure returns 400 Bad Request with the errors array.

  • Python API — full validate() / generate() signatures
  • Service Schema — field-level reference for GenerateRequest
  • CLIomnirt validate subcommand flags