Skip to content

Conversation

@SunMarc
Copy link
Member

@SunMarc SunMarc commented May 22, 2025

What does this PR do?

This PR fixes an issue when the torch distributed is already initialized. current_device is referenced before assignment.

Getting the following traceback in accelerate when testing tp training.

[rank1]:     tp_plan, device_map, device_mesh = initialize_tensor_parallelism(tp_plan, tp_size=None)
[rank1]:   File "/home/marc/transformers/src/transformers/integrations/tensor_parallel.py", line 79, in initialize_tensor_parallelism
[rank1]:     index = current_device.current_device() if device_type != "cpu" else None
[rank1]: UnboundLocalError: local variable 'current_device' referenced before assignment

@SunMarc SunMarc requested a review from ArthurZucker May 22, 2025 10:01
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks ! 🤗

@ArthurZucker ArthurZucker added the for patch Tag issues / labels that should be included in the next patch label May 22, 2025
@SunMarc SunMarc merged commit 03a4c02 into main May 22, 2025
22 checks passed
@SunMarc SunMarc deleted the fix-tp branch May 22, 2025 10:34
ArthurZucker pushed a commit that referenced this pull request May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

for patch Tag issues / labels that should be included in the next patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants