{"record":{"id":"a7d452a710382c82","repo":"sgl-project/sglang","slug":"num-inference-steps-is-required-for-dual-transform","errorCode":null,"errorMessage":"num_inference_steps is required for dual-transformer mode. Please provide it in CacheDitConfig.","messagePattern":"num_inference_steps is required for dual-transformer mode\\. Please provide it in CacheDitConfig\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/cache/cache_dit_integration.py","lineNumber":563,"sourceCode":"\n    Args:\n        primary_config: CacheDitConfig for primary transformer.\n        secondary_config: CacheDitConfig for secondary transformer.\n        sp_group: Sequence parallel process group (for Ulysses/Ring).\n        tp_group: Tensor parallel process group.\n    \"\"\"\n    adapter_spec = DUAL_TRANSFORMER_BLOCK_ADAPTER_SPECS.get(model_name)\n    if adapter_spec is None:\n        raise ValueError(\n            f\"Dual-transformer cache-dit is only supported for \"\n            f\"{sorted(DUAL_TRANSFORMER_BLOCK_ADAPTER_SPECS)}, got {model_name}.\"\n        )\n\n    if not primary_config.enabled:\n        return transformer, transformer_2\n\n    if primary_config.num_inference_steps is None:\n        raise ValueError(\n            \"num_inference_steps is required for dual-transformer mode. \"\n            \"Please provide it in CacheDitConfig.\"\n        )\n\n    # Build DBCacheConfig for primary transformer\n    primary_cache_config = DBCacheConfig(\n        num_inference_steps=primary_config.num_inference_steps,\n        Fn_compute_blocks=primary_config.Fn_compute_blocks,\n        Bn_compute_blocks=primary_config.Bn_compute_blocks,\n        max_warmup_steps=primary_config.max_warmup_steps,\n        residual_diff_threshold=primary_config.residual_diff_threshold,\n        max_continuous_cached_steps=primary_config.max_continuous_cached_steps,\n        steps_computation_mask=primary_config.steps_computation_mask,\n        steps_computation_policy=primary_config.steps_computation_policy,\n    )\n\n    # Build DBCacheConfig for secondary transformer\n    secondary_cache_config = DBCacheConfig(","sourceCodeStart":545,"sourceCodeEnd":581,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/cache/cache_dit_integration.py#L545-L581","documentation":"Raised by enable_cache_on_dual_transformer when caching is enabled for a dual-transformer model but primary_config.num_inference_steps is None. Dual-transformer cache-dit schedules cache reuse across a fixed step budget, so the total number of inference steps must be known up front via CacheDitConfig.","triggerScenarios":"Constructing CacheDitConfig(enabled=True) without setting num_inference_steps and calling enable_cache_on_dual_transformer (directly or through _maybe_enable_cache_dit) for a supported dual-transformer model.","commonSituations":"Reusing a single-transformer CacheDitConfig (where num_inference_steps is optional) for a dual-transformer model, or building the config from CLI args that omit the steps setting.","solutions":["Set num_inference_steps in CacheDitConfig to the sampler's total step count before enabling dual-transformer caching","If steps are not known ahead of time, disable caching (enabled=False) for the dual-transformer model","Ensure the runtime passes the sampler's num_inference_steps into the config when building it"],"exampleFix":"# before\nconfig = CacheDitConfig(enabled=True)  # num_inference_steps=None\n\n# after\nconfig = CacheDitConfig(enabled=True, num_inference_steps=50)  # match your sampler","handlingStrategy":"validation","validationCode":"if is_dual_model and config.cache_dit.enabled and config.cache_dit.num_inference_steps is None:\n    config.cache_dit.num_inference_steps = sampler.num_inference_steps\n    # or fail fast:\n    # raise ValueError(\"set CacheDitConfig.num_inference_steps for dual-transformer mode\")","typeGuard":"def dual_config_is_complete(cfg: CacheDitConfig) -> bool:\n    return (not cfg.enabled) or cfg.num_inference_steps is not None","tryCatchPattern":"try:\n    t1, t2 = enable_cache_on_dual_transformer(t1, t2, model_name, cfg, ...)\nexcept ValueError as e:\n    if \"num_inference_steps is required\" in str(e):\n        cfg.num_inference_steps = steps; retry once\n    else:\n        raise","preventionTips":["Always populate num_inference_steps from the sampler when building CacheDitConfig","Fail fast at config validation for dual-transformer models","Keep one config builder per model mode (single vs dual) so required fields are enforced"],"tags":["cache-dit","dual-transformer","missing-config","num-inference-steps"],"backgroundTag":"missing-required-config-field","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}