Fix broken Llama4 accuracy in MoE part#40609
Merged
Cyrilvallez merged 2 commits intohuggingface:mainfrom Sep 4, 2025
Merged
Conversation
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 2, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Until we upgrade to a new HF transformers version containing the fix, we will monkey patch HF transformers to make these tests pass again. Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
1 task
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 2, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Until we upgrade to a new HF transformers version containing the fix, we will monkey patch HF transformers to make these tests pass again. Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
Member
|
cc @ArthurZucker! |
1 task
4 tasks
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 3, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Until we upgrade to a new HF transformers version containing the fix, we will monkey patch HF transformers to make these tests pass again. Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
|
Confirmed with the given repro that this issue also affects Llama4 CPU execution on transformers v4.54, v4.55, and v4.56. The output is accurate on v4.53. |
Contributor
Author
|
@ArthurZucker Could you review this? Thanks! |
Llama4 accuracy is broken by a bug in huggingface#39501 . It forgot to transpose the router_scores before applying it to routed_in, causing Llama4 to generate garbage output. This PR fixes that issue by adding back the transpose() and adding some comments explaining why the transpose() is needed. Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
004dd11 to
4bebe5a
Compare
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 4, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Until we upgrade to a new HF transformers version containing the fix, we will monkey patch HF transformers to make these tests pass again. Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
Cyrilvallez
approved these changes
Sep 4, 2025
Member
Cyrilvallez
left a comment
There was a problem hiding this comment.
Indeed, this got lost! Thanks a lot for the fix!!
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: llama4 |
Cyrilvallez
added a commit
that referenced
this pull request
Sep 4, 2025
* Fix broken Llama4 accuracy in MoE part Llama4 accuracy is broken by a bug in #39501 . It forgot to transpose the router_scores before applying it to routed_in, causing Llama4 to generate garbage output. This PR fixes that issue by adding back the transpose() and adding some comments explaining why the transpose() is needed. Signed-off-by: Po-Han Huang <pohanh@nvidia.com> * remove comment --------- Signed-off-by: Po-Han Huang <pohanh@nvidia.com> Co-authored-by: Cyril Vallez <cyril.vallez@gmail.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 17, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 17, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 18, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 19, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 19, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 23, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 24, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 24, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 24, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 25, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 25, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 25, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
nvpohanh
added a commit
to nvpohanh/TensorRT-LLM
that referenced
this pull request
Sep 26, 2025
… failures The test_modeling_llama_min_latency.py::test_llama_allclose_to_hf tests are failing with latest HF transformers due to a bug in their code. A PR has been submitted to fix it in upstream repo: huggingface/transformers#40609 Signed-off-by: Po-Han Huang <pohanh@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Llama4 accuracy is broken by a bug in
#39501 . It forgot to transpose the router_scores before applying it to routed_in, causing Llama4 to generate garbage output.
This PR fixes that issue by adding back the transpose() and adding some comments explaining why the transpose() is needed.
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@ArthurZucker please review since #39501 was made by you. Thanks!
Accuracy tests
Test script:
Before the fix on H200:
After the fix on H200: