unilab.training.cuda_process_sharing¶
Fail-closed validation for CUDA process-sharing execution modes.
The off-policy learner and collector are separate processes on one rank-local GPU. CUDA MPS is an execution-sharing mode for that required topology: it lets their independent CUDA contexts overlap kernels instead of being arbitrated by coarse driver time-slicing.
This module never starts or stops an MPS daemon. An explicit request is either validated against the host state or rejected before UniLab constructs a learner, collector, or environment.
An unconfigured (null) request still records ambient host MPS state: an
environment-level daemon reachable through CUDA_MPS_PIPE_DIRECTORY (or the
default pipe directory) multiplexes this rank’s CUDA contexts transparently,
so every run must be able to self-report that state. Ambient observation is
best-effort and never fails closed; unresolvable facts record None.
Functions
Record process-sharing evidence in a producer-owned manifest mapping. |
|
|
Return the case- and dash-insensitive NVIDIA GPU UUID comparison token. |
|
Validate one rank's requested CUDA process-sharing mode. |
|
Return |
Classes
Structured per-rank evidence for a requested mode plus ambient state. |
- class unilab.training.cuda_process_sharing.CudaProcessSharingEvidence[source]¶
Bases:
objectStructured per-rank evidence for a requested mode plus ambient state.
pipe_directory_envis the rawCUDA_MPS_PIPE_DIRECTORYvalue (Nonewhen unset);pipe_directory/control_pipe/control_pipe_kind/server_piddescribe the effective pipe this rank’s CUDA contexts would use.ambient_serveris true only for an unconfigured run whose effective control pipe answered a daemon query — the transparent-MPS case.- __init__(configured, effective, validated, rank=0, world_size=1, learner_device=None, collector_device=None, learner_gpu_uuid=None, collector_gpu_uuid=None, pipe_directory_env=None, pipe_directory=None, control_pipe=None, control_pipe_kind=None, server_pid=None, ambient_server=False)¶
- unilab.training.cuda_process_sharing.apply_cuda_process_sharing_manifest(runtime_manifest, evidence)[source]¶
Record process-sharing evidence in a producer-owned manifest mapping.
- Parameters:
runtime_manifest (
MutableMapping[str,Any])evidence (
CudaProcessSharingEvidence)
- Return type:
- unilab.training.cuda_process_sharing.canonicalize_gpu_uuid(value)[source]¶
Return the case- and dash-insensitive NVIDIA GPU UUID comparison token.
Torch,
nvidia-smi, andCUDA_VISIBLE_DEVICESexpose the same UUID with different cases, dashes, and an optionalGPU-prefix; equality checks must compare this token rather than the raw strings. The persisted/display form staysGPU-<id>(seecuda_mps_cli).
- unilab.training.cuda_process_sharing.probe_cuda_process_sharing(requested, learner_device, collector_device, *, backend, rank=0, world_size=1, torch_module=None, run_command=<function run>)[source]¶
Validate one rank’s requested CUDA process-sharing mode.
- Parameters:
requested (
Any) – Owner valuenullormps.learner_device (
str) – Rank-local learner CUDA device.collector_device (
str|None) – Backend-bound collector CUDA device, when applicable.backend (
str) – Configured owner backend identity.rank (
int) – Current off-policy DP rank.world_size (
int) – Current single-host off-policy DP world size.torch_module (
Any|None) – Injectable Torch module for deterministic tests.run_command (
Callable[...,Any]) – Injectable subprocess runner for deterministic tests.
- Return type:
- Returns:
Evidence suitable for a per-rank runtime-manifest diagnostic section.
- Raises:
ValueError – The first unmet prerequisite for an explicit request.
- unilab.training.cuda_process_sharing.resolve_mps_visibility_entries(entries, *, run_command=<function run>)[source]¶
Return
CUDA_VISIBLE_DEVICESentries with numeric indices as UUIDs.A per-GPU MPS server enumerates only its own device, so a client whose one-entry visibility mask holds a nonzero numeric index overruns that namespace and fails CUDA initialization with “No CUDA GPUs are available”. UUID entries survive that server-side remapping, so an explicit
training.cuda_process_sharing=mpslaunch normalizes visibility before CUDA latches the mask. Non-numeric entries (UUID, MIG,-1) pass through unchanged; the returned UUIDs keep thenvidia-smidisplay form.