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

Add monkey patch for Qwen2 models #69

Merged
merged 2 commits into from
Aug 24, 2024
Merged

Conversation

chiwanpark
Copy link
Contributor

Summary

This PR adds a monkey patch script for Qwen2 models. I've copied the monkey patch script for Mixtral because the Qwen2 models have the same structure of Mixtral. Also, I've checked the forward method of Qwen2ForCausalLM class (link) to apply the fused linear cross entropy loss.

Testing Done

  • run make test to ensure correctness
  • run make checkstyle to ensure code style
  • run make test-convergence to ensure convergence
❯ make test
pytest --disable-warnings test/ --ignore=test/convergence
================================================ test session starts =================================================
platform linux -- Python 3.10.12, pytest-8.3.2, pluggy-1.5.0
rootdir: /data/ovis_915/bell/Liger-Kernel.git
plugins: anyio-4.4.0
collected 114 items                                                                                                  

test/transformers/test_cross_entropy.py ..........................................................             [ 50%]
test/transformers/test_fused_linear_cross_entropy.py ......                                                    [ 56%]
test/transformers/test_geglu.py ........                                                                       [ 63%]
test/transformers/test_rms_norm.py ................                                                            [ 77%]
test/transformers/test_rope.py ............                                                                    [ 87%]
test/transformers/test_swiglu.py ........                                                                      [ 94%]
test/transformers/test_trainer_integration.py ...                                                              [ 97%]
test/transformers/test_transformers_monkey_patch.py .                                                          [ 98%]
test/triton/test_triton_monkey_patch.py ..                                                                     [100%]

=========================================== 114 passed in 62.15s (0:01:02) ===========================================
❯ make checkstyle 
flake8 .; flake8_status=$?; \
isort .; isort_status=$?; \
black .; black_status=$?; \
if [ $flake8_status -ne 0 ] || [ $isort_status -ne 0 ] || [ $black_status -ne 0 ]; then \
        exit 1; \
fi
Skipped 1 files
All done! ✨ 🍰 ✨
52 files left unchanged.
❯ make test-convergence 
HF_DATASETS_OFFLINE=1 pytest --disable-warnings test/convergence
================================================ test session starts =================================================
platform linux -- Python 3.10.12, pytest-8.3.2, pluggy-1.5.0
rootdir: /data/ovis_915/bell/Liger-Kernel.git
plugins: anyio-4.4.0
collected 8 items                                                                                                    

test/convergence/test_mini_models.py ......                                                                    [ 75%]
test/convergence/test_mini_models_no_logits.py ..                                                              [100%]

================================================= 8 passed in 55.44s =================================================

Copy link
Collaborator

@ByronHsu ByronHsu left a comment

Choose a reason for hiding this comment

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

This shipping speed is crazy!

README.md Outdated Show resolved Hide resolved
Co-authored-by: Byron Hsu <[email protected]>
@lancerts lancerts requested a review from ByronHsu August 24, 2024 16:40
@ByronHsu ByronHsu merged commit 6782a77 into linkedin:main Aug 24, 2024
1 check passed
@chiwanpark chiwanpark deleted the qwen2 branch August 25, 2024 02:07
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.

3 participants