Skip to content

Add pathlib Path support to idist broadcast#3755

Open
nightcityblade wants to merge 1 commit into
pytorch:masterfrom
nightcityblade:fix/issue-3025
Open

Add pathlib Path support to idist broadcast#3755
nightcityblade wants to merge 1 commit into
pytorch:masterfrom
nightcityblade:fix/issue-3025

Conversation

@nightcityblade
Copy link
Copy Markdown
Contributor

Fixes #3025

Description:

Adds pathlib.Path support to idist.broadcast by encoding paths through the existing string broadcast path and decoding them back to Path objects, including safe-mode placeholder handling.

Check list:

  • New tests are added (if a new feature is added)
  • New doc strings: description and/or example code are in RST format
  • Documentation is updated (if required)

@github-actions github-actions Bot added the module: distributed Distributed module label May 21, 2026
Comment on lines 282 to +287
if tensor_to_str:
list_str = self._decode_str(tensor)
return list_str[0]
if tensor_to_path:
list_str = self._decode_str(tensor)
return Path(list_str[0])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We can merge these two cases into a single one and just apply Path on str if tensor_to_path is True

Copy link
Copy Markdown
Collaborator

@vfdev-5 vfdev-5 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @nightcityblade
As a quick solution this may work. Later we can probably support more types with dist.broadcast_object_list (and this method is present in pytorch 2.2 min supported version by ignite, so we can keep bc etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: distributed Distributed module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extension of ignite.distributed.utils.broadcast for pathlib.Path datatype

2 participants