Skip to content
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

Make Mistral HF to NeMo checkpoint converter iterable to allow for lo… #9972

Merged
merged 2 commits into from
Aug 5, 2024

Conversation

akoumpa
Copy link
Member

@akoumpa akoumpa commented Jul 31, 2024

Makes the convert function of the checkpoint converter an iterator. This allows for reduced memory usage during conversion, in fact less memory usage than the total RAM requirements of a full checkpoint.

If the --low-mem CLI option is used, the converter will load only the requested layers from the HF checkpoint and upon conversion of a full layer (e.g. transformer) it will save it to disk. Next, it will load those partially converted checkpoints via mmap, thus only copying to ram layers that are being used.

During the model initialization stage the converter may need the full checkpoint ram, but due to memory mapping it can do with less ram also, thus reducing the ram requirements significantly.

What does this PR do ?

Add a one line overview of what this PR aims to accomplish.

Collection: [Note which collection this PR will affect]

Changelog

  • Add specific line by line info of high level changes in this PR.

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this 

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

The GitHub Actions CI will run automatically when the "Run CICD" label is added to the PR.
To re-run CI remove and add the label again.
To run CI on an untrusted fork, a NeMo user with write access must first click "Approve and run".

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

@akoumpa akoumpa self-assigned this Jul 31, 2024
@akoumpa akoumpa added CI and removed Run CICD labels Jul 31, 2024
@akoumpa akoumpa requested a review from yaoyu-33 August 1, 2024 18:31
…w memory usage during conversion

Signed-off-by: Alexandros Koumparoulis <[email protected]>
@akoumpa akoumpa force-pushed the akoumparouli/iterable_ckpt_converter_mistral_2407 branch from 7fa962d to 504e416 Compare August 2, 2024 06:14
@github-actions github-actions bot removed the CI label Aug 2, 2024
@akoumpa akoumpa added Run CICD and removed Run CICD labels Aug 2, 2024
@akoumpa akoumpa merged commit 7cfca95 into main Aug 5, 2024
355 of 437 checks passed
@akoumpa akoumpa deleted the akoumparouli/iterable_ckpt_converter_mistral_2407 branch August 5, 2024 17:19
adityavavre pushed a commit to adityavavre/NeMo that referenced this pull request Sep 15, 2024
NVIDIA#9972)

* Make Mistral HF to NeMo checkpoint converter iterable to allow for low memory usage during conversion

Signed-off-by: Alexandros Koumparoulis <[email protected]>

* Apply isort and black reformatting

Signed-off-by: akoumpa <[email protected]>

---------

Signed-off-by: Alexandros Koumparoulis <[email protected]>
Signed-off-by: akoumpa <[email protected]>
Co-authored-by: akoumpa <[email protected]>
Signed-off-by: adityavavre <[email protected]>
monica-sekoyan pushed a commit that referenced this pull request Oct 14, 2024
#9972)

* Make Mistral HF to NeMo checkpoint converter iterable to allow for low memory usage during conversion

Signed-off-by: Alexandros Koumparoulis <[email protected]>

* Apply isort and black reformatting

Signed-off-by: akoumpa <[email protected]>

---------

Signed-off-by: Alexandros Koumparoulis <[email protected]>
Signed-off-by: akoumpa <[email protected]>
Co-authored-by: akoumpa <[email protected]>
hainan-xv pushed a commit to hainan-xv/NeMo that referenced this pull request Nov 5, 2024
NVIDIA#9972)

* Make Mistral HF to NeMo checkpoint converter iterable to allow for low memory usage during conversion

Signed-off-by: Alexandros Koumparoulis <[email protected]>

* Apply isort and black reformatting

Signed-off-by: akoumpa <[email protected]>

---------

Signed-off-by: Alexandros Koumparoulis <[email protected]>
Signed-off-by: akoumpa <[email protected]>
Co-authored-by: akoumpa <[email protected]>
Signed-off-by: Hainan Xu <[email protected]>
XuesongYang pushed a commit to paarthneekhara/NeMo that referenced this pull request Jan 18, 2025
NVIDIA#9972)

* Make Mistral HF to NeMo checkpoint converter iterable to allow for low memory usage during conversion

Signed-off-by: Alexandros Koumparoulis <[email protected]>

* Apply isort and black reformatting

Signed-off-by: akoumpa <[email protected]>

---------

Signed-off-by: Alexandros Koumparoulis <[email protected]>
Signed-off-by: akoumpa <[email protected]>
Co-authored-by: akoumpa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants