Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions unsloth_zoo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from packaging.version import Version as TrueVersion
import torch
import torch.distributed as dist

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

While this import fixes the use of the dist alias in distributed_function, it will cause an AttributeError on lines 81-83, which use torch.distributed directly. import torch.distributed as dist does not bind the name torch.distributed. To ensure both references work correctly, you can import the module and then create the alias separately.

A more comprehensive fix would be to consistently use either dist or torch.distributed throughout the file, but that would require changes outside of this diff.

Suggested change
import torch.distributed as dist
import torch.distributed
dist = torch.distributed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is already import torch directly so there should be no error on lines 81-83. Alternatively, dist on lines 120 and 122 could be replaced with a direct torch.distributed call

import os
import time
import contextlib
Expand Down