#273·gpt-oss

Responses API Triton backend binds CUDA devices using global rank

Author: sylvesterkaczmarekCreated Aug 16, 2026Updated Aug 16, 2026

Summary

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

python
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.