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

Do not upload NeuronModelForCausalLM weights when they can be reconstructed from the hub #413

Merged
merged 6 commits into from
Jan 18, 2024

Conversation

dacorvo
Copy link
Collaborator

@dacorvo dacorvo commented Jan 17, 2024

When serializing a model, the checkpoint files (i.e. the original
weights formatted for neuron) and the compiled artifacts are stored
under two folders in the model directory.
This modifies the NeuronForCausalLM.push_to_hub method to exclude
the folder containing the checkpoint files if they can be instead
reconstructed from a model on the hub.

Note that it is still possible to upload checkpoint files by using the
huggingface_cli directly on the saved model folder instead of
push_to_hub.

To allow optimum-neuron to fetch and reconstruct the checkpoint when
fetchin a neuron model from the hub, the original repository that was
used to export the model and its revision are stored in the neuron config.

Example model here:

https://huggingface.co/dacorvo/llama-2-7b-chat-hf-neuronx-bs1-seq2048-no-checkpoint/tree/main

"neuron": {
  "auto_cast_type": "fp16",
  "batch_size": 1,
  "checkpoint_id": "meta-llama/Llama-2-7b-chat-hf",
  "checkpoint_revision": "c1b0db933684edbfe29a06fa47eb19cc48025e93",
  "compiler_type": "neuronx-cc",
  "compiler_version": "2.12.54.0+f631c2365",
  "num_cores": 2,
  "sequence_length": 2048,
  "task": "text-generation"
}

@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.

When serializing a model, the checkpoint files (i.e. the original
weights formatted for neuron) and the compiled artifacts are stored
under two folder in the model directory.
This modifies the NeuronForCausalLM.push_to_hub method to exclude
the folder containing the checkpoint files if they can be instead
reconstructed from a model on the hub.

Note that it is still possible to upload checkpoint files by using the
huggingface_cli directly on the saved model folder instead of
push_to_hub.

To allow optimum-neuron to fetch and reconstruct the checkpoint when
fetchin a neuron model from the hub, the original repository that was
used to export the model and its revision are stored in the neuron config.
@dacorvo dacorvo force-pushed the do_not_upload_model_weights branch from 298c840 to 87c7341 Compare January 17, 2024 14:42
@dacorvo dacorvo force-pushed the do_not_upload_model_weights branch from 87c7341 to f07d0b1 Compare January 17, 2024 14:52
@dacorvo dacorvo marked this pull request as ready for review January 17, 2024 20:27
Copy link
Member

@michaelbenayoun michaelbenayoun left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@JingyaHuang JingyaHuang left a comment

Choose a reason for hiding this comment

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

LGTM!

"model_id, revision",
[
["dacorvo/tiny-random-gpt2-neuronx", "1b3456cf877cc42c053ee8464f1067021eccde4b"],
["dacorvo/tiny-random-gpt2-neuronx-no-checkpoint", "78eb2313ab7e149bbc22ff32257db93ba09e3033"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the test with no checkpoint, shall we check there is no checkpoint after push to hub?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is a download here: the check is done in the other test.

@dacorvo dacorvo merged commit c60935b into main Jan 18, 2024
6 of 7 checks passed
@dacorvo dacorvo deleted the do_not_upload_model_weights branch January 18, 2024 10:49
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