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

Open
wants to merge 3 commits into
base: gh/ankitageorge/14/base
Choose a base branch
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.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ You can merge normally! (1 Unrelated Failure)

As of commit fac7914 with merge base f02b783 (image):

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fb-exported 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.

3 participants