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

Skip model saving during precompilation, provide option to skip cache push #365

Merged
merged 4 commits into from
Dec 15, 2023

Conversation

5cp
Copy link
Contributor

@5cp 5cp commented Dec 6, 2023

This PR contains 2 changes:

  • skip model saving during neuron_parallel_compile in order to speed up precompilation by a few minutes and avoid writing large, unusable checkpoints to disk.
  • provide training arg --skip_cache_push so we can avoid pushing compilation artifacts to the hub cache when this step isn't required. This saves a few minutes for llama2-7B. (Perhaps skipping the push should be the default behaviour?).

Tested with Llama-2-7b-hf using run_clm.py.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@dacorvo
Copy link
Collaborator

dacorvo commented Dec 11, 2023

Thank you very much for the pull-request. Tagging @michaelbenayoun which is the main maintainer for this code.

@5cp 5cp changed the title Skip model saving during precompilation Skip model saving during precompilation, provide option to skip cache push Dec 13, 2023
Comment on lines +424 to +434
if not os.environ.get("NEURON_PARALLEL_COMPILE"): # Avoid unnecessary model saving during precompilation
if output_dir is None:
output_dir = self.args.output_dir

self._save_xla(output_dir)
self._save_xla(output_dir)

# Push to the Hub when `save_model` is called by the user.
if self.args.push_to_hub and not _internal_call:
self.push_to_hub(commit_message="Model save")
# Push to the Hub when `save_model` is called by the user.
if self.args.push_to_hub and not _internal_call:
self.push_to_hub(commit_message="Model save")
else:
logger.info("Skipping trainer.save_model() while running under neuron_parallel_compile")
Copy link
Member

Choose a reason for hiding this comment

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

I'm okay with this, but wont it trigger compilation when saving during actual training?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there is a very quick incidental compilation related to checkpointing - I will time it to see if it's significant and update here.

This is really meant to avoid the several minutes waiting and 38GB storage used up by checkpointing during neuron_parallel_compile. We do something similar for neuronx-nemo-megatron

Copy link
Member

Choose a reason for hiding this comment

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

Alright, then let's do it!

@michaelbenayoun michaelbenayoun merged commit 51d7793 into main Dec 15, 2023
7 checks passed
@michaelbenayoun michaelbenayoun deleted the 5cp_fixes branch December 15, 2023 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants