{"record":{"id":"4e936e6362e5e6ef","repo":"sgl-project/sglang","slug":"replica-broadcast-of-batch-extra-key-r-got-none","errorCode":null,"errorMessage":"replica broadcast of batch.extra[{key!r}] got None","messagePattern":"replica broadcast of batch\\.extra\\[(.+?)\\] got None","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/stages/replica_broadcast.py","lineNumber":38,"sourceCode":"    group = get_replica_group()\n    return int(group.world_size), int(group.rank_in_group)\n\n\ndef minimax_h3_replica_broadcast_extra(batch: Any, key: str) -> None:\n    world, rank = minimax_h3_replica_ctx()\n    if world <= 1:\n        return\n\n    from sglang.multimodal_gen.runtime.distributed.parallel_state import (\n        get_replica_group,\n    )\n\n    group = get_replica_group()\n    payload = {\"value\": batch.extra.get(key)} if rank == 0 else None\n    payload = group.broadcast_tensor_dict(payload, src=0)\n    value = payload.get(\"value\") if isinstance(payload, dict) else None\n    if value is None:\n        raise RuntimeError(f\"replica broadcast of batch.extra[{key!r}] got None\")\n    if rank != 0:\n        batch.extra[key] = value\n\n\ndef minimax_h3_replica_broadcast_error(error: str | None) -> str | None:\n    world, rank = minimax_h3_replica_ctx()\n    if world <= 1:\n        return error\n\n    from sglang.multimodal_gen.runtime.distributed.parallel_state import (\n        get_replica_group,\n    )\n\n    group = get_replica_group()\n    return group.broadcast_object(error if rank == 0 else None, src=0)\n\n\n__all__ = [","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/model_specific_stages/minimax_h3/stages/replica_broadcast.py#L20-L56","documentation":"In data-parallel replica mode, rank 0 broadcasts batch.extra[key] via broadcast_tensor_dict; a None payload on any rank means the key was absent (or explicitly None) on the source rank. The RuntimeError surfaces the fact that non-owner replicas cannot proceed without the value.","triggerScenarios":"minimax_h3_replica_broadcast_extra is called with a key not present in batch.extra on rank 0, or the tensor-dict broadcast returned a payload whose 'value' is None (broadcast failure or key omission).","commonSituations":"A stage that only runs on rank 0 (e.g. reference encoding) forgot to set the extra key before broadcast; calling broadcast for a key that was never populated on this pipeline path; NCCL group misconfiguration returning empty dicts.","solutions":["Make sure the owner rank populates batch.extra[key] before calling minimax_h3_replica_broadcast_extra","Guard: only broadcast keys you know were produced on rank 0; skip the call if batch.extra.get(key) is None on rank 0","Check the replica group is initialized with all ranks and src=0 is the actual producer rank"],"exampleFix":"// before\nminimax_h3_replica_broadcast_extra(batch, KEY)\n// after\nif batch.extra.get(KEY) is not None:\n    minimax_h3_replica_broadcast_extra(batch, KEY)","handlingStrategy":"validation","validationCode":"if rank == 0 and batch.extra.get(key) is None:\n    raise RuntimeError(f\"{key} not produced on rank 0; skip broadcast or fix producer stage\")","typeGuard":null,"tryCatchPattern":"try:\n    minimax_h3_replica_broadcast_extra(batch, key)\nexcept RuntimeError as e:\n    if \"got None\" in str(e):\n        handle_missing_extra_on_owner(key)\n    else:\n        raise","preventionTips":["Only broadcast extras the owner rank actually produced","Add a rank-0 pre-check before every replica broadcast"],"tags":["minimax-h3","replica-broadcast","distributed","distributed-communication"],"backgroundTag":"distributed-broadcast-failure","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}