Skip to content

Make actor runtime device-agnostic (support XPU alongside CUDA)#4307

Open
songhappy wants to merge 1 commit into
meta-pytorch:mainfrom
songhappy:xpu-upstream
Open

Make actor runtime device-agnostic (support XPU alongside CUDA)#4307
songhappy wants to merge 1 commit into
meta-pytorch:mainfrom
songhappy:xpu-upstream

Conversation

@songhappy

Copy link
Copy Markdown

Summary

Remove three CUDA-only assumptions from the actor runtime (Layer 1) so Monarch works on any
accelerator supported by torch.accelerator:

  • device_utils.py: replace /dev/nvidia* scanning with torch.accelerator.device_count()
  • proc_mesh.py: add XPU env vars to env-change monitoring; generalize initialized-check to dispatch
    by torch.accelerator.current_accelerator()
  • job.py: wrap distributed_telemetry imports in try/except so ProcessJob loads on actors-only
    builds
  • setup.py: gate distributed_sql_telemetry behind USE_TENSOR_ENGINE

No Layer 2 changes. CUDA remains the default. 5 files, +600/-31.

Test plan

  • 6 unit tests (mocked, no hardware) -- pass on any machine
  • 11 integration tests (XPU hardware) -- spawn actors, verify env propagation, ping-pong messaging,
    SPMD elastic env, GRPO convergence, FSDP2 over xccl
  • All existing upstream tests pass unmodified (59/59 on UAN)
  • Validated on Intel Data Center GPU Max (PVC), torch 2.12.0+xpu, 12 tiles

Run: pytest python/tests/test_xpu.py -v

Remove three CUDA-only assumptions from Layer 1 so Monarch's actor
runtime works on any accelerator supported by torch.accelerator:

- device_utils.py: replace /dev/nvidia* scanning with
  torch.accelerator.device_count()
- proc_mesh.py: add XPU env vars (ZE_AFFINITY_MASK, etc.) to
  env-change monitoring; generalize _torch_cuda_already_initialized
  to dispatch by torch.accelerator.current_accelerator()
- job.py: wrap distributed_telemetry imports in try/except so
  ProcessJob loads on actors-only builds (USE_TENSOR_ENGINE=0)
- setup.py: gate distributed_sql_telemetry behind USE_TENSOR_ENGINE

No new environment variables. No Layer 2 changes. CUDA remains the
default. Includes test_xpu.py with 17 tests (6 unit/mocked + 11
integration requiring XPU hardware).

Tested on Intel Data Center GPU Max (PVC) with torch 2.12.0+xpu,
xccl backend, 12 tiles. All upstream tests pass unmodified.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 26, 2026
@songhappy

Copy link
Copy Markdown
Author

@shayne-fletcher would you please kindly have somebody review this PR?

@shayne-fletcher shayne-fletcher added the enhancement New feature or request label Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants