[BugFix] Fix ascend config check (#1092)
Fix the ascend config check logic:
1. refactor check_ascend_config to make it clear:
1. torchair graph should not work with enforce_eager=True
2. aclgraph should not work with torchair graph
3. add refresh config for rlhf case
4. fix a typo in model runner
5. change expert_tensor_parallel_size default to 0 to keep the same as
before
Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>
This commit is contained in:
@@ -13,10 +13,13 @@
|
||||
# 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 pytest
|
||||
|
||||
from tests.conftest import VllmRunner
|
||||
from vllm_ascend.ascend_config import clear_ascend_config, get_ascend_config
|
||||
from vllm_ascend.ascend_config import (clear_ascend_config, get_ascend_config,
|
||||
init_ascend_config)
|
||||
|
||||
|
||||
def _clean_up_ascend_config(func):
|
||||
@@ -39,12 +42,15 @@ def test_run_without_ascend_config():
|
||||
assert ascend_config.torchair_graph_config.graph_batch_sizes == []
|
||||
assert not ascend_config.torchair_graph_config.graph_batch_sizes_init
|
||||
assert not ascend_config.ascend_scheduler_config.enabled
|
||||
assert ascend_config.expert_tensor_parallel_size == 1
|
||||
assert ascend_config.expert_tensor_parallel_size == 0
|
||||
|
||||
|
||||
@_clean_up_ascend_config
|
||||
def test_run_with_ascend_config():
|
||||
input_additional_config = {
|
||||
if os.getenv("VLLM_USE_V1") == "0":
|
||||
pytest.skip("graph only works on v1")
|
||||
|
||||
input_additional_config_1 = {
|
||||
"torchair_graph_config": {
|
||||
# torchair graph only works with deepseek. The e2e test should be added
|
||||
# in multicard test with deepseek models.
|
||||
@@ -52,6 +58,7 @@ def test_run_with_ascend_config():
|
||||
"use_cached_graph": True,
|
||||
"graph_batch_sizes": [1, 2, 4, 8],
|
||||
"graph_batch_sizes_init": False,
|
||||
"enable_multistream_shared_expert": True,
|
||||
},
|
||||
"ascend_scheduler_config": {
|
||||
"enabled": True,
|
||||
@@ -59,8 +66,11 @@ def test_run_with_ascend_config():
|
||||
},
|
||||
"expert_tensor_parallel_size": 1
|
||||
}
|
||||
|
||||
# check passed with eager mode
|
||||
with VllmRunner("facebook/opt-125m",
|
||||
additional_config=input_additional_config):
|
||||
enforce_eager=True,
|
||||
additional_config=input_additional_config_1):
|
||||
ascend_config = get_ascend_config()
|
||||
|
||||
assert not ascend_config.torchair_graph_config.enabled
|
||||
@@ -69,6 +79,7 @@ def test_run_with_ascend_config():
|
||||
1, 2, 4, 8
|
||||
]
|
||||
assert not ascend_config.torchair_graph_config.graph_batch_sizes_init
|
||||
assert ascend_config.torchair_graph_config.enable_multistream_shared_expert
|
||||
assert ascend_config.ascend_scheduler_config.enabled
|
||||
assert ascend_config.ascend_scheduler_config.enable_chunked_prefill
|
||||
assert ascend_config.expert_tensor_parallel_size == 1
|
||||
@@ -83,6 +94,8 @@ def test_ascend_config_init_error():
|
||||
|
||||
@_clean_up_ascend_config
|
||||
def test_ascend_config_load_error():
|
||||
if os.getenv("VLLM_USE_V1") == "0":
|
||||
pytest.skip("graph only works on v1")
|
||||
# graph_batch_sizes should be list.
|
||||
with pytest.raises(TypeError):
|
||||
input_additional_config_fake_1 = {
|
||||
@@ -117,3 +130,60 @@ def test_ascend_config_load_error():
|
||||
enforce_eager=False,
|
||||
additional_config=input_additional_config_fake_2):
|
||||
pass
|
||||
|
||||
# torchair graph should not be enabled with eager mode
|
||||
with pytest.raises(RuntimeError):
|
||||
input_additional_config_fake_3 = {
|
||||
"torchair_graph_config": {
|
||||
"enabled": True,
|
||||
},
|
||||
}
|
||||
with VllmRunner("facebook/opt-125m",
|
||||
enforce_eager=True,
|
||||
additional_config=input_additional_config_fake_3):
|
||||
pass
|
||||
|
||||
|
||||
@_clean_up_ascend_config
|
||||
def test_check_ascend_config_v0():
|
||||
if os.getenv("VLLM_USE_V1") == "1":
|
||||
pytest.skip("graph only works on v1, this is the test for v0")
|
||||
with pytest.raises(NotImplementedError):
|
||||
input_additional_config_fake_1 = {
|
||||
"torchair_graph_config": {
|
||||
"enabled": True,
|
||||
},
|
||||
}
|
||||
with VllmRunner("facebook/opt-125m",
|
||||
additional_config=input_additional_config_fake_1):
|
||||
pass
|
||||
|
||||
|
||||
@_clean_up_ascend_config
|
||||
def test_ascend_config_refresh():
|
||||
from vllm.config import get_current_vllm_config
|
||||
vllm_config = get_current_vllm_config()
|
||||
# set additional_config with none
|
||||
init_ascend_config(vllm_config)
|
||||
|
||||
input_additional_config = {
|
||||
"torchair_graph_config": {
|
||||
"enabled": False,
|
||||
"use_cached_graph": True,
|
||||
"graph_batch_sizes": [1, 2, 4, 8],
|
||||
"graph_batch_sizes_init": False,
|
||||
},
|
||||
"refresh": True,
|
||||
}
|
||||
|
||||
# refresh ascend config
|
||||
with VllmRunner("facebook/opt-125m",
|
||||
additional_config=input_additional_config):
|
||||
ascend_config = get_ascend_config()
|
||||
|
||||
assert not ascend_config.torchair_graph_config.enabled
|
||||
assert ascend_config.torchair_graph_config.use_cached_graph
|
||||
assert ascend_config.torchair_graph_config.graph_batch_sizes == [
|
||||
1, 2, 4, 8
|
||||
]
|
||||
assert not ascend_config.torchair_graph_config.graph_batch_sizes_init
|
||||
|
||||
Reference in New Issue
Block a user