Adds a script to convert HF checkpoints to NeoX 2.0 with mp and pp sharding #907
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The "convert_hf_to_sequential.py" script allows users to convert model checkpoints from HF format to NeoX 2.0 and cache them in the specified (by the config file) pipe-parallel-size and model-parallel-size.
The main use case is to enable simple caching of pre-trained models for fine-tuning in NeoX 2.0.
Included functionality:
- convert_hf_to_sequential() conversion function tested with the Pythia suite
- sharding for (MP=1, PP=0), (MP=1,PP=1), (MP>1,PP=0), (MP>1,PP>1)
- logit testing for comparing with HF models (only available for world_size=1)
Playing with the script and logit testing uncovers some interesting findings:
1. Disabling flash attention for the converted Pythia 70M model leads to numerical overflow in NeoX 2.0.
2. Even with flash attention enabled, the forward pass between the NeoX 2.0 model and the HF model is not identical (we found this to be caused by a difference in applying the rotary embedding).