Skip to content

Responses API Triton backend binds CUDA devices using global rank #273

Description

@sylvesterkaczmarek

Summary

The Responses API Triton backend independently selects its CUDA device from global RANK:

rank = int(os.environ.get("RANK", 0))
...
torch.cuda.set_device(rank)
device = torch.device(f"cuda:{rank}")

This backend does not use gpt_oss.torch.utils.init_distributed(), so the local-rank correction in #267 does not cover it.

Under standard multi-node torchrun, global ranks continue across nodes while each host's CUDA devices are indexed by node-local LOCAL_RANK. For example, a worker can have RANK=4, LOCAL_RANK=0 on a four-GPU host; the current backend attempts to bind cuda:4 instead of cuda:0.

Impact

The reference Responses API Triton backend can fail with an invalid CUDA device ordinal on nodes after the first in a standard multi-node launch.

Proposed resolution

Keep global RANK for distributed identity/logging, but use LOCAL_RANK for torch.cuda.set_device() and the CUDA device object. Fall back to RANK when LOCAL_RANK is absent to preserve existing single-node/custom launch behavior.

Add a CPU-only mocked regression with different global and local ranks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions