Skip to content

vllm_omni.diffusion.models.cosmos3.guardrails

Cosmos3 guardrail hooks for vllm-omni.

Thin adapter around the cosmos_guardrail package's CosmosSafetyChecker (Blocklist + Qwen3Guard for text, RetinaFace face-blur for video).

Enabled by default. Disable server-wide with --cosmos3-no-guardrails (which sets od_config.model_config["guardrails"] = False); per-request overrides ride on sampling_params.extra_args["guardrails"].

TextGuardrailFn module-attribute

TextGuardrailFn = Callable[[str], None]

VideoGuardrailFn module-attribute

VideoGuardrailFn = Callable[[ndarray], ndarray]

logger module-attribute

logger = init_logger(__name__)

check_text_safety

check_text_safety(prompt: str) -> None

check_video_safety

check_video_safety(video_tensor: Tensor) -> Tensor

ensure_initialized

ensure_initialized(od_config: OmniDiffusionConfig) -> None

is_guardrails_enabled

is_guardrails_enabled(
    od_config: OmniDiffusionConfig,
    sampling_params: OmniDiffusionSamplingParams
    | None = None,
) -> bool

Resolve the active guardrail gate.

Server-level od_config.model_config["guardrails"] decides whether the guardrail models are loaded at all (eager load at pipeline build time). When that is False, no per-request override can turn checks back on, because the singletons in this module are never populated.

When the server gate is on, sampling_params.extra_args["guardrails"] may override on a per-request basis: False skips the check for that request, anything else (or missing) keeps the default behavior.