sgl-project/sglang · error · ValueError

MiniMaxH3DiTModel.forward requires kwarg {key!r}

Error message

MiniMaxH3DiTModel.forward requires kwarg {key!r}

What it means

MiniMaxH3DiTModel.forward enforces an exhaustive keyword contract: every required key must be present and non-None in kwargs. _required_kwarg fetches a key and raises this error when it is missing or None, failing before any tensor work.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/dits/minimax_h3.py:164

    "video_patch_proj.bias",
    "audio_patch_proj.weight",
    "audio_patch_proj.bias",
    "time_embedder.proj_in.weight",
    "time_embedder.proj_in.bias",
    "time_embedder.proj_out.weight",
    "time_embedder.proj_out.bias",
    "final_layer.video_out.weight",
    "final_layer.video_out.bias",
    "final_layer.audio_out.weight",
    "final_layer.audio_out.bias",
)
MINIMAX_H3_FP32_PARAM_NAMES = frozenset(_MINIMAX_H3_FP32_PARAM_NAMES_IN_MODEL_ORDER)
MINIMAX_H3_FP32_BUFFER_NAMES = frozenset({"rope.inv_freq"})


def _required_kwarg(kwargs: dict[str, Any], key: str) -> Any:
    if key not in kwargs or kwargs[key] is None:
        raise ValueError(f"MiniMaxH3DiTModel.forward requires kwarg {key!r}")
    return kwargs[key]


# The exhaustive keyword contract of MiniMaxH3DiTModel.forward. Anything not
# listed here is rejected with a TypeError before any tensor work starts.
_FORWARD_SUPPORTED_KWARGS = frozenset(
    {
        "x",
        "audio_x",
        "img_position_ids",
        "rope_cache",
        "unique_timesteps",
        "inverse_indices",
        "update_mask",
        "update_audio_mask",
        "token_tags",
        "block_token_tags",
        "block_combined_indices",

View on GitHub (pinned to 0132848349)

Solutions

  1. Read _FORWARD_SUPPORTED_KWARGS / the forward signature and supply every required kwarg with a non-None value
  2. Fix the upstream caller to stop passing None for that key (populate it from request metadata instead of defaulting to None)
  3. Add a pre-flight check in your wrapper that walks required keys and fails with a clearer message

Example fix

# before
out = model(hidden_states, encoder_hidden_states=e)

# after
out = model(hidden_states, encoder_hidden_states=e,
            timestep=t, img_position_ids=pos_ids)
Defensive patterns

Strategy: validation

Validate before calling

REQUIRED = ('timestep', 'img_position_ids')  # per _FORWARD_SUPPORTED_KWARGS
missing = [k for k in REQUIRED if kwargs.get(k) is None]
assert not missing, f'missing required kwargs: {missing}'

Type guard

def kwargs_complete(kwargs: dict, required: tuple[str, ...]) -> bool:
    return all(kwargs.get(k) is not None for k in required)

Try / catch

try: model(**kwargs)\nexcept ValueError as e: raise PipelineConfigError(str(e)) from e

Prevention

When it happens

Trigger: Calling model.forward(**kwargs) without one of the contract kwargs (e.g. timestep, img_position_ids, or sequence metadata), or passing it explicitly as None from a pipeline default.

Common situations: Custom pipelines or refactored callers dropping a kwarg; optional-looking defaults (None) that are actually required for this model; conditional code paths that skip setting a key for some request types.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/0e935c2a6876d5bb. Report an issue: GitHub.