-
Notifications
You must be signed in to change notification settings - Fork 696
[BugFix] PD reorder fix and add ut #6375
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
Open
bukejiyu
wants to merge
4
commits into
PaddlePaddle:develop
Choose a base branch
from
bukejiyu:e2e-ut
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| # Copyright (c) 2026 PaddlePaddle Authors. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import os | ||
| import sys | ||
|
|
||
| import pytest | ||
|
|
||
| current_dir = os.path.dirname(os.path.abspath(__file__)) | ||
| project_root = os.path.abspath(os.path.join(current_dir, "..")) | ||
| if project_root not in sys.path: | ||
| sys.path.insert(0, project_root) | ||
|
|
||
| from model_loader.utils import ( | ||
| form_model_get_output_topp0, | ||
| get_paddle_model_path, | ||
| run_with_timeout, | ||
| ) | ||
|
|
||
| os.environ["ENABLE_PD_REORDER"] = "1" | ||
|
|
||
| model_param_map = { | ||
| "ernie-4_5-21b-a3b-bf16-paddle": { | ||
| "tensor_parallel_size": 2, | ||
| "quantizations": [None], | ||
| "max_num_seqs": 3, | ||
| "graph_optimization_config": {"use_cudagraph": False}, | ||
| "env": {"ENABLE_PD_REORDER": "1"}, | ||
| } | ||
| } | ||
| prompts = [ | ||
| "解释下温故而知新", | ||
| "Hello, my name is", | ||
| "鲁迅是谁", | ||
| "将李白的静夜思改为现代诗歌", | ||
| "你好", | ||
| "请介绍下你自己", | ||
| ] | ||
|
|
||
| params = [] | ||
| for model, cfg in model_param_map.items(): | ||
| for q in cfg["quantizations"]: | ||
| if isinstance(q, dict): | ||
| quant, backend, env = q["quant_type"], q.get("backend", "default"), q.get("env", {}) | ||
| else: | ||
| quant, backend, env = q, "default", {} | ||
| params.append( | ||
| pytest.param( | ||
| model, | ||
| cfg.get("tensor_parallel_size", 1), | ||
| cfg.get("max_num_seqs", 1), | ||
| cfg.get("max_model_len", 1024), | ||
| quant, | ||
| cfg.get("max_tokens", 128), | ||
| env, | ||
| marks=[pytest.mark.core_model], | ||
| id=f"{model}.{quant}.{backend}", | ||
| ) | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "model_name_or_path,tensor_parallel_size,max_num_seqs,max_model_len,quantization,max_tokens,env", | ||
| params, | ||
| ) | ||
| def test_model_against_baseline( | ||
| fd_runner, | ||
| model_name_or_path: str, | ||
| tensor_parallel_size: int, | ||
| max_num_seqs: int, | ||
| max_model_len: int, | ||
| max_tokens: int, | ||
| quantization: str, | ||
| env, | ||
| monkeypatch, | ||
| ) -> None: | ||
| """ | ||
| Test that model output matches baseline file. | ||
| """ | ||
| model_path = get_paddle_model_path(model_name_or_path) | ||
| for k, v in env.items(): | ||
| monkeypatch.setenv(k, v) | ||
| # Run model | ||
| _ = run_with_timeout( | ||
| target=form_model_get_output_topp0, | ||
| args=( | ||
| fd_runner, | ||
| model_path, | ||
| tensor_parallel_size, | ||
| max_num_seqs, | ||
| max_model_len, | ||
| max_tokens, | ||
| quantization, | ||
| "dummy", | ||
| prompts, | ||
| ), | ||
| ) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里为什么要另外增加一个开启方式呢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不然没法加单测,现在attn 默认不重排的,又没发直接给append attn开重排,就加了个环境变量