Skip to content

Remove usage of fsspec in HF consolidation script #159392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from

Conversation

ankitageorge
Copy link
Contributor

@ankitageorge ankitageorge commented Jul 29, 2025

Stack from ghstack (oldest at bottom):

Moving towards just supporting local storage to take advantage of HF apis such as safe_open. This was already done in Storage component in #159405. This PR removes fsspec usages in consolidation script and relies on local storage only

Differential Revision: D78997975

cc @H-Huang @awgu @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @pragupta

Moving towards just supporting local storage to take advantage of HF apis such as safe_open. This PR removes fsspec usages and relies on local storage only

Differential Revision: [D78997975](https://our.internmc.facebook.com/intern/diff/D78997975/)

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Jul 29, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/159392

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit d3f0cda with merge base eed9dbf (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78997975

return f.read(end_offset - start_offset)
# Use mmap for efficient access
with open(file_path, "rb") as f:
with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as mm:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Put both context managers on the same with statement to reduce unnecessary indent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this doesn't work because the mmap call needs to be nested in the open

output_files_data[output_path] = _OutputFileData()

# Find all safetensors files in the input directory
safetensors_files = []
for file in input_fs.ls(input_dir, detail=False):
for file in os.listdir(input_dir):
Copy link
Collaborator

@Skylion007 Skylion007 Jul 30, 2025

Choose a reason for hiding this comment

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

Since this is now local, why not just glob or iglob with the suffix? Would remove the need for os.path joins below? Also would turn it into one line glob.glob(os.path.join(input_dir,f"*{SUFFIX}"))

Moving towards just supporting local storage to take advantage of HF apis such as safe_open. This PR removes fsspec usages and relies on local storage only

Differential Revision: [D78997975](https://our.internmc.facebook.com/intern/diff/D78997975/)

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta

[ghstack-poisoned]
ankitageorge added a commit that referenced this pull request Aug 1, 2025
Pull Request resolved: #159392

Moving towards just supporting local storage to take advantage of HF apis such as safe_open. This PR removes fsspec usages and relies on local storage only
ghstack-source-id: 300119133
@exported-using-ghexport

Differential Revision: [D78997975](https://our.internmc.facebook.com/intern/diff/D78997975/)
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78997975

Moving towards just supporting local storage to take advantage of HF apis such as safe_open. This PR removes fsspec usages and relies on local storage only

Differential Revision: [D78997975](https://our.internmc.facebook.com/intern/diff/D78997975/)

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78997975

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Aug 12, 2025
Moving towards just supporting local storage to take advantage of HF apis such as safe_open. This was already done in Storage component in #159405. This PR removes fsspec usages in consolidation script and relies on local storage only

Differential Revision: [D78997975](https://our.internmc.facebook.com/intern/diff/D78997975/)

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta

[ghstack-poisoned]
ankitageorge added a commit that referenced this pull request Aug 12, 2025
Pull Request resolved: #159392

Moving towards just supporting local storage to take advantage of HF apis such as safe_open. This PR removes fsspec usages and relies on local storage only
ghstack-source-id: 302105247
@exported-using-ghexport

Differential Revision: [D78997975](https://our.internmc.facebook.com/intern/diff/D78997975/)
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78997975

Moving towards just supporting local storage to take advantage of HF apis such as safe_open. This was already done in Storage component in #159405. This PR removes fsspec usages in consolidation script and relies on local storage only

Differential Revision: [D78997975](https://our.internmc.facebook.com/intern/diff/D78997975/)

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta

[ghstack-poisoned]
ankitageorge added a commit that referenced this pull request Aug 12, 2025
Pull Request resolved: #159392

Moving towards just supporting local storage to take advantage of HF apis such as safe_open. This PR removes fsspec usages and relies on local storage only
ghstack-source-id: 302468409
@exported-using-ghexport

Differential Revision: [D78997975](https://our.internmc.facebook.com/intern/diff/D78997975/)
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D78997975

@ankitageorge
Copy link
Contributor Author

@pytorchmergebot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request fb-exported Merged oncall: distributed Add this issue/PR to distributed oncall triage queue release notes: distributed (checkpoint)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants