Skip to content

Conversation

@FindHao
Copy link
Member

@FindHao FindHao commented Oct 20, 2025

fix #176

Changes

This PR adds device normalization logic to ensure all tensors are created on cuda:0, regardless of the device specified in the JSON configuration.

Modifications

1. load_tensor() function

  • Added device normalization before loading tensor from file
  • Any CUDA device string (e.g., cuda, cuda:1, cuda:2) is now mapped to cuda:0

2. _create_base_tensor() function

  • Added device normalization before creating new tensors
  • Applies to all tensor types: floating-point, integer, complex, and unsigned integer

Impact

  • Prevents multi-GPU issues: All tensors are now consistently created on the same device
  • Backward compatible: Non-CUDA devices (e.g., cpu) remain unchanged
  • Minimal code change: Only two strategic locations modified for maximum coverage

Testing

This change affects the template file used for generating reproducers. All generated test cases will now place tensors on cuda:0 by default.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 20, 2025
@meta-codesync
Copy link

meta-codesync bot commented Oct 20, 2025

@FindHao has imported this pull request. If you are a Meta employee, you can view this in D85061992.

@meta-codesync
Copy link

meta-codesync bot commented Oct 20, 2025

@FindHao merged this pull request in 197df27.

@FindHao FindHao deleted the findhao/fix_device branch October 30, 2025 03:11
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. Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

torch.AcceleratorError: CUDA error: invalid device ordinal

3 participants