Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
415b817b
"tests/kernels/attention/test_mla_decode_cpu.py" did not exist on "4f044b1d67964e53587a4d0c7f00233a04b7be4e"
Commit
415b817b
authored
Sep 17, 2025
by
王敏
Browse files
merge 092-dev分支近期修改
parents
3c08fbc1
bc9aee38
Changes
66
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
354 additions
and
310 deletions
+354
-310
tests/reasoning/test_granite_reasoning_parser.py
tests/reasoning/test_granite_reasoning_parser.py
+3
-1
tests/reasoning/test_qwen3_reasoning_parser.py
tests/reasoning/test_qwen3_reasoning_parser.py
+4
-1
tests/runai_model_streamer_test/test_runai_model_streamer_loader.py
...i_model_streamer_test/test_runai_model_streamer_loader.py
+3
-1
tests/runai_model_streamer_test/untest_weight_utils.py
tests/runai_model_streamer_test/untest_weight_utils.py
+0
-0
tests/samplers/test_logprobs.py
tests/samplers/test_logprobs.py
+132
-128
tests/samplers/test_no_bad_words.py
tests/samplers/test_no_bad_words.py
+152
-151
tests/samplers/test_sampler.py
tests/samplers/test_sampler.py
+3
-0
tests/spec_decode/e2e/untest_integration.py
tests/spec_decode/e2e/untest_integration.py
+0
-0
tests/spec_decode/e2e/untest_logprobs.py
tests/spec_decode/e2e/untest_logprobs.py
+0
-0
tests/spec_decode/test_memory_usage.py
tests/spec_decode/test_memory_usage.py
+4
-2
tests/spec_decode/test_multi_step_worker.py
tests/spec_decode/test_multi_step_worker.py
+6
-5
tests/tokenization/test_detokenize.py
tests/tokenization/test_detokenize.py
+2
-1
tests/tokenization/test_tokenizer_group.py
tests/tokenization/test_tokenizer_group.py
+1
-1
tests/tool_use/test_xlam_tool_parser.py
tests/tool_use/test_xlam_tool_parser.py
+3
-1
vllm/_custom_ops.py
vllm/_custom_ops.py
+2
-1
vllm/distributed/kv_transfer/kv_connector/v1/p2p/p2p_nccl_connector.py
...ted/kv_transfer/kv_connector/v1/p2p/p2p_nccl_connector.py
+3
-0
vllm/engine/arg_utils.py
vllm/engine/arg_utils.py
+1
-1
vllm/model_executor/layers/fused_moe/ep_moe/layer.py
vllm/model_executor/layers/fused_moe/ep_moe/layer.py
+5
-5
vllm/model_executor/layers/fused_moe/layer.py
vllm/model_executor/layers/fused_moe/layer.py
+21
-9
vllm/model_executor/layers/fused_moe/moe_align_block_size.py
vllm/model_executor/layers/fused_moe/moe_align_block_size.py
+9
-2
No files found.
tests/reasoning/test_granite_reasoning_parser.py
View file @
415b817b
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
os
import
pytest
import
pytest
from
transformers
import
AutoTokenizer
from
transformers
import
AutoTokenizer
from
tests.reasoning.utils
import
DeltaMessage
,
run_reasoning_extraction
from
tests.reasoning.utils
import
DeltaMessage
,
run_reasoning_extraction
from
vllm.reasoning
import
ReasoningParser
,
ReasoningParserManager
from
vllm.reasoning
import
ReasoningParser
,
ReasoningParserManager
from
..utils
import
models_path_prefix
parser_name
=
"granite"
parser_name
=
"granite"
START_REASONING
=
"Here is my thought process:"
START_REASONING
=
"Here is my thought process:"
...
@@ -124,7 +126,7 @@ TEST_CASES = [
...
@@ -124,7 +126,7 @@ TEST_CASES = [
]
]
# Global tokenizer initialization to avoid repeated loading
# Global tokenizer initialization to avoid repeated loading
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"facebook/opt-125m"
)
tokenizer
=
AutoTokenizer
.
from_pretrained
(
os
.
path
.
join
(
models_path_prefix
,
"facebook/opt-125m"
)
)
@
pytest
.
mark
.
parametrize
(
"streaming, param_dict"
,
TEST_CASES
)
@
pytest
.
mark
.
parametrize
(
"streaming, param_dict"
,
TEST_CASES
)
...
...
tests/reasoning/test_qwen3_reasoning_parser.py
View file @
415b817b
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
os
import
pytest
import
pytest
from
transformers
import
AutoTokenizer
from
transformers
import
AutoTokenizer
from
tests.reasoning.utils
import
run_reasoning_extraction
from
tests.reasoning.utils
import
run_reasoning_extraction
from
vllm.reasoning
import
ReasoningParser
,
ReasoningParserManager
from
vllm.reasoning
import
ReasoningParser
,
ReasoningParserManager
from
..utils
import
models_path_prefix
parser_name
=
"qwen3"
parser_name
=
"qwen3"
start_token
=
"<think>"
start_token
=
"<think>"
end_token
=
"</think>"
end_token
=
"</think>"
REASONING_MODEL_NAME
=
"Qwen/Qwen3-0.6B"
REASONING_MODEL_NAME
=
os
.
path
.
join
(
models_path_prefix
,
"Qwen/Qwen3-0.6B"
)
@
pytest
.
fixture
(
scope
=
"module"
)
@
pytest
.
fixture
(
scope
=
"module"
)
...
...
tests/runai_model_streamer_test/test_runai_model_streamer_loader.py
View file @
415b817b
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
os
from
vllm
import
SamplingParams
from
vllm
import
SamplingParams
from
vllm.config
import
LoadConfig
,
LoadFormat
from
vllm.config
import
LoadConfig
,
LoadFormat
from
vllm.model_executor.model_loader
import
get_model_loader
from
vllm.model_executor.model_loader
import
get_model_loader
from
..utils
import
models_path_prefix
test_model
=
"openai-community/gpt2"
test_model
=
os
.
path
.
join
(
models_path_prefix
,
"openai-community/gpt2"
)
prompts
=
[
prompts
=
[
"Hello, my name is"
,
"Hello, my name is"
,
...
...
tests/runai_model_streamer_test/test_weight_utils.py
→
tests/runai_model_streamer_test/
un
test_weight_utils.py
View file @
415b817b
File moved
tests/samplers/test_logprobs.py
View file @
415b817b
...
@@ -8,6 +8,7 @@ import os
...
@@ -8,6 +8,7 @@ import os
from
vllm
import
SamplingParams
from
vllm
import
SamplingParams
from
..conftest
import
VllmRunner
from
..conftest
import
VllmRunner
from
vllm.platforms
import
current_platform
from
..utils
import
models_path_prefix
from
..utils
import
models_path_prefix
MODELS
=
[
os
.
path
.
join
(
models_path_prefix
,
"distilbert/distilgpt2"
)]
MODELS
=
[
os
.
path
.
join
(
models_path_prefix
,
"distilbert/distilgpt2"
)]
...
@@ -22,134 +23,136 @@ def use_v0_only(monkeypatch):
...
@@ -22,134 +23,136 @@ def use_v0_only(monkeypatch):
monkeypatch
.
setenv
(
'VLLM_USE_V1'
,
'0'
)
monkeypatch
.
setenv
(
'VLLM_USE_V1'
,
'0'
)
@
pytest
.
mark
.
parametrize
(
"model"
,
MODELS
)
# TODO
@
pytest
.
mark
.
parametrize
(
"dtype"
,
# @pytest.mark.parametrize("model", MODELS)
[
"half"
])
# needed for comparing logprobs with HF
# @pytest.mark.parametrize("dtype",
@
pytest
.
mark
.
parametrize
(
"chunked_prefill_token_size"
,
[
1
,
4
,
16
,
-
1
])
# ["half"]) # needed for comparing logprobs with HF
@
pytest
.
mark
.
parametrize
(
"num_top_logprobs"
,
[
0
,
6
])
# 32000 == vocab_size
# @pytest.mark.parametrize("chunked_prefill_token_size", [1, 4, 16, -1])
@
pytest
.
mark
.
parametrize
(
"detokenize"
,
[
True
,
False
])
# @pytest.mark.parametrize("num_top_logprobs", [0, 6]) # 32000 == vocab_size
def
test_get_prompt_logprobs
(
# @pytest.mark.parametrize("detokenize", [True, False])
hf_runner
,
# def test_get_prompt_logprobs(
vllm_runner
,
# hf_runner,
model
,
# vllm_runner,
dtype
,
# model,
chunked_prefill_token_size
:
int
,
# dtype,
num_top_logprobs
:
int
,
# chunked_prefill_token_size: int,
detokenize
:
bool
,
# num_top_logprobs: int,
example_prompts
,
# detokenize: bool,
):
# example_prompts,
max_num_seqs
=
256
# ):
enable_chunked_prefill
=
False
# max_num_seqs = 256
max_num_batched_tokens
=
None
# enable_chunked_prefill = False
if
chunked_prefill_token_size
!=
-
1
:
# max_num_batched_tokens = None
enable_chunked_prefill
=
True
# if chunked_prefill_token_size != -1:
max_num_seqs
=
min
(
chunked_prefill_token_size
,
max_num_seqs
)
# enable_chunked_prefill = True
max_num_batched_tokens
=
chunked_prefill_token_size
# max_num_seqs = min(chunked_prefill_token_size, max_num_seqs)
# max_num_batched_tokens = chunked_prefill_token_size
max_tokens
=
5
with
hf_runner
(
model
,
dtype
=
dtype
)
as
hf_model
:
# max_tokens = 5
hf_logprobs
=
hf_model
.
generate_greedy_logprobs
(
# with hf_runner(model, dtype=dtype) as hf_model:
example_prompts
,
# hf_logprobs = hf_model.generate_greedy_logprobs(
max_tokens
=
max_tokens
,
# example_prompts,
)
# max_tokens=max_tokens,
# )
with
vllm_runner
(
model
,
# with vllm_runner(
dtype
=
dtype
,
# model,
max_logprobs
=
num_top_logprobs
,
# dtype=dtype,
enable_chunked_prefill
=
enable_chunked_prefill
,
# max_logprobs=num_top_logprobs,
max_num_batched_tokens
=
max_num_batched_tokens
,
# enable_chunked_prefill=enable_chunked_prefill,
max_num_seqs
=
max_num_seqs
,
# max_num_batched_tokens=max_num_batched_tokens,
)
as
vllm_model
:
# max_num_seqs=max_num_seqs,
vllm_sampling_params
=
SamplingParams
(
max_tokens
=
max_tokens
,
# block_size=16 if not current_platform.is_rocm() else 64,
logprobs
=
num_top_logprobs
,
# ) as vllm_model:
prompt_logprobs
=
num_top_logprobs
,
# vllm_sampling_params = SamplingParams(max_tokens=max_tokens,
temperature
=
0.0
,
# logprobs=num_top_logprobs,
detokenize
=
detokenize
)
# prompt_logprobs=num_top_logprobs,
vllm_results
=
vllm_model
.
model
.
generate
(
# temperature=0.0,
example_prompts
,
sampling_params
=
vllm_sampling_params
)
# detokenize=detokenize)
# vllm_results = vllm_model.model.generate(
# Test whether logprobs are included in the results.
# example_prompts, sampling_params=vllm_sampling_params)
for
result
in
vllm_results
:
assert
result
.
prompt_logprobs
is
not
None
# # Test whether logprobs are included in the results.
assert
result
.
outputs
[
0
].
logprobs
is
not
None
# for result in vllm_results:
assert
len
(
result
.
outputs
[
0
].
logprobs
)
==
max_tokens
# assert result.prompt_logprobs is not None
for
logprobs
in
result
.
outputs
[
0
].
logprobs
:
# assert result.outputs[0].logprobs is not None
# If the output token is not included in the top X
# assert len(result.outputs[0].logprobs) == max_tokens
# logprob, it can return 1 more data
# for logprobs in result.outputs[0].logprobs:
assert
(
len
(
logprobs
)
==
num_top_logprobs
# # If the output token is not included in the top X
or
len
(
logprobs
)
==
num_top_logprobs
+
1
)
# # logprob, it can return 1 more data
output_text
=
result
.
outputs
[
0
].
text
# assert (len(logprobs) == num_top_logprobs
output_string_from_most_likely_tokens_lst
:
list
[
str
]
=
[]
# or len(logprobs) == num_top_logprobs + 1)
for
top_logprobs
in
result
.
outputs
[
0
].
logprobs
:
# output_text = result.outputs[0].text
top_logprob
=
next
(
iter
(
top_logprobs
.
values
()))
# output_string_from_most_likely_tokens_lst: list[str] = []
output_string_from_most_likely_tokens_lst
.
append
(
# for top_logprobs in result.outputs[0].logprobs:
top_logprob
.
decoded_token
)
# top_logprob = next(iter(top_logprobs.values()))
# output_string_from_most_likely_tokens_lst.append(
if
detokenize
:
# top_logprob.decoded_token)
output_string_from_most_likely_tokens
=
""
.
join
(
output_string_from_most_likely_tokens_lst
)
# if detokenize:
assert
output_text
==
output_string_from_most_likely_tokens
,
(
# output_string_from_most_likely_tokens = "".join(
"The output text from the top logprob for each token position "
# output_string_from_most_likely_tokens_lst)
"should be the same as the output text in the result."
)
# assert output_text == output_string_from_most_likely_tokens, (
else
:
# "The output text from the top logprob for each token position "
assert
output_text
==
''
# "should be the same as the output text in the result.")
assert
output_string_from_most_likely_tokens_lst
==
([
None
]
*
# else:
max_tokens
)
# assert output_text == ''
# assert output_string_from_most_likely_tokens_lst == ([None] *
# The first prompt logprob is always None
# max_tokens)
assert
result
.
prompt_logprobs
[
0
]
is
None
for
prompt_logprobs
in
result
.
prompt_logprobs
[
1
:]:
# # The first prompt logprob is always None
# If the prompt token is not included in the top X
# assert result.prompt_logprobs[0] is None
# logprob, it can return 1 more data
# for prompt_logprobs in result.prompt_logprobs[1:]:
assert
(
len
(
prompt_logprobs
)
==
num_top_logprobs
# # If the prompt token is not included in the top X
or
len
(
prompt_logprobs
)
==
num_top_logprobs
+
1
)
# # logprob, it can return 1 more data
# assert (len(prompt_logprobs) == num_top_logprobs
# Test whether prompt logprobs are consistent with HF
# or len(prompt_logprobs) == num_top_logprobs + 1)
for
vllm_result
,
hf_logprob
in
zip
(
vllm_results
,
hf_logprobs
):
# Check prompt logprobs
# # Test whether prompt logprobs are consistent with HF
# The first prompt logprob is always None, so we compare it from 1:.
# for vllm_result, hf_logprob in zip(vllm_results, hf_logprobs):
vllm_prompt_logprobs
=
vllm_result
.
prompt_logprobs
[
1
:]
# # Check prompt logprobs
for
i
,
vllm_prompt_logprob_dict
in
enumerate
(
vllm_prompt_logprobs
):
# # The first prompt logprob is always None, so we compare it from 1:.
for
token_id
,
logprob
in
vllm_prompt_logprob_dict
.
items
():
# vllm_prompt_logprobs = vllm_result.prompt_logprobs[1:]
torch
.
testing
.
assert_close
(
logprob
.
logprob
,
# for i, vllm_prompt_logprob_dict in enumerate(vllm_prompt_logprobs):
hf_logprob
[
0
][
i
][
token_id
].
item
(),
# for token_id, logprob in vllm_prompt_logprob_dict.items():
atol
=
1e-2
,
# torch.testing.assert_close(logprob.logprob,
rtol
=
1e-2
)
# hf_logprob[0][i][token_id].item(),
vllm_sample_logprobs
=
vllm_result
.
outputs
[
0
].
logprobs
# atol=1e-2,
for
i
,
top_logprobs
in
enumerate
(
vllm_sample_logprobs
):
# rtol=1e-2)
for
token_id
,
sample_logprob
in
top_logprobs
.
items
():
# vllm_sample_logprobs = vllm_result.outputs[0].logprobs
logprob
=
sample_logprob
.
logprob
# for i, top_logprobs in enumerate(vllm_sample_logprobs):
torch
.
testing
.
assert_close
(
logprob
,
# for token_id, sample_logprob in top_logprobs.items():
hf_logprob
[
i
][
-
1
][
token_id
].
item
(),
# logprob = sample_logprob.logprob
atol
=
1e-1
,
# torch.testing.assert_close(logprob,
rtol
=
1e-1
)
# hf_logprob[i][-1][token_id].item(),
if
detokenize
:
# atol=1e-1,
assert
isinstance
(
sample_logprob
.
decoded_token
,
str
),
(
# rtol=1e-1)
"The token should be decoded by the time it is returned"
# if detokenize:
" to the user."
)
# assert isinstance(sample_logprob.decoded_token, str), (
# "The token should be decoded by the time it is returned"
# Test if prompt logprobs are correctly set.
# " to the user.")
for
vllm_result
in
vllm_results
:
token_ids
=
vllm_result
.
prompt_token_ids
# # Test if prompt logprobs are correctly set.
prompt_logprobs
=
vllm_result
.
prompt_logprobs
# for vllm_result in vllm_results:
# token_ids = vllm_result.prompt_token_ids
# The first token doesn't have logprob.
# prompt_logprobs = vllm_result.prompt_logprobs
assert
prompt_logprobs
[
0
]
is
None
# # The first token doesn't have logprob.
for
token_id
,
logprob_dict
in
zip
(
token_ids
[
1
:],
prompt_logprobs
[
1
:]):
# assert prompt_logprobs[0] is None
assert
token_id
in
logprob_dict
# for token_id, logprob_dict in zip(token_ids[1:], prompt_logprobs[1:]):
# assert token_id in logprob_dict
def
test_max_logprobs
():
runner
=
VllmRunner
(
os
.
path
.
join
(
models_path_prefix
,
"facebook/opt-125m"
),
max_logprobs
=
1
)
vllm_sampling_params
=
SamplingParams
(
logprobs
=
1
)
# def test_max_logprobs():
# should pass
# runner = VllmRunner(os.path.join(models_path_prefix, "facebook/opt-125m"), max_logprobs=1)
runner
.
generate
([
"Hello world"
],
sampling_params
=
vllm_sampling_params
)
# vllm_sampling_params = SamplingParams(logprobs=1)
# # should pass
bad_sampling_params
=
SamplingParams
(
logprobs
=
2
)
# runner.generate(["Hello world"], sampling_params=vllm_sampling_params)
with
pytest
.
raises
(
ValueError
):
runner
.
generate
([
"Hello world"
],
sampling_params
=
bad_sampling_params
)
# bad_sampling_params = SamplingParams(logprobs=2)
# with pytest.raises(ValueError):
# runner.generate(["Hello world"], sampling_params=bad_sampling_params)
@
pytest
.
mark
.
parametrize
(
"model"
,
MODELS
)
@
pytest
.
mark
.
parametrize
(
"model"
,
MODELS
)
...
@@ -171,6 +174,7 @@ def test_none_logprobs(vllm_runner, model, chunked_prefill_token_size: int,
...
@@ -171,6 +174,7 @@ def test_none_logprobs(vllm_runner, model, chunked_prefill_token_size: int,
enable_chunked_prefill
=
enable_chunked_prefill
,
enable_chunked_prefill
=
enable_chunked_prefill
,
max_num_batched_tokens
=
max_num_batched_tokens
,
max_num_batched_tokens
=
max_num_batched_tokens
,
max_num_seqs
=
max_num_seqs
,
max_num_seqs
=
max_num_seqs
,
block_size
=
16
if
not
current_platform
.
is_rocm
()
else
64
,
)
as
vllm_model
:
)
as
vllm_model
:
sampling_params_logprobs_none
=
SamplingParams
(
max_tokens
=
max_tokens
,
sampling_params_logprobs_none
=
SamplingParams
(
max_tokens
=
max_tokens
,
logprobs
=
None
,
logprobs
=
None
,
...
...
tests/samplers/test_no_bad_words.py
View file @
415b817b
...
@@ -43,154 +43,155 @@ def _generate(
...
@@ -43,154 +43,155 @@ def _generate(
return
output_token_ids
return
output_token_ids
class
TestOneTokenBadWord
:
# TODO
# MODEL = os.path.join(models_path_prefix, "TheBloke/Llama-2-7B-fp16")
# class TestOneTokenBadWord:
MODEL
=
"TheBloke/Llama-2-7B-fp16"
# # MODEL = os.path.join(models_path_prefix, "TheBloke/Llama-2-7B-fp16")
# MODEL = os.path.join(models_path_prefix, "TheBloke/Llama-2-7B-fp16")
PROMPT
=
"Hi! How are"
TARGET_TOKEN
=
"you"
# PROMPT = "Hi! How are"
# TARGET_TOKEN = "you"
def
setup_method
(
self
,
method
):
self
.
tokenizer
=
AutoTokenizer
.
from_pretrained
(
self
.
MODEL
,
# def setup_method(self, method):
add_prefix_space
=
True
)
# self.tokenizer = AutoTokenizer.from_pretrained(self.MODEL,
# add_prefix_space=True)
self
.
num_prompt_tokens
=
len
(
self
.
_encode
(
self
.
PROMPT
))
self
.
target_token_id
=
self
.
_encode
(
self
.
TARGET_TOKEN
,
# self.num_prompt_tokens = len(self._encode(self.PROMPT))
add_special_tokens
=
False
)[
0
]
# self.target_token_id = self._encode(self.TARGET_TOKEN,
# add_special_tokens=False)[0]
def
test_one_token_bad_word
(
self
,
vllm_runner
):
with
vllm_runner
(
self
.
MODEL
)
as
llm
:
# def test_one_token_bad_word(self, vllm_runner):
output_token_ids
=
self
.
_generate
(
llm
)
# with vllm_runner(self.MODEL) as llm:
assert
output_token_ids
[
0
]
==
self
.
target_token_id
# output_token_ids = self._generate(llm)
# assert output_token_ids[0] == self.target_token_id
output_token_ids
=
self
.
_generate
(
llm
,
bad_words
=
[
self
.
TARGET_TOKEN
])
# output_token_ids = self._generate(llm,
assert
self
.
target_token_id
not
in
output_token_ids
# bad_words=[self.TARGET_TOKEN])
# assert self.target_token_id not in output_token_ids
def
_generate
(
self
,
model
:
LLM
,
# def _generate(self,
bad_words
:
Optional
[
list
[
str
]]
=
None
)
->
list
[
int
]:
# model: LLM,
return
_generate
(
# bad_words: Optional[list[str]] = None) -> list[int]:
model
=
model
,
# return _generate(
prompt
=
self
.
PROMPT
,
# model=model,
num_prompt_tokens
=
self
.
num_prompt_tokens
,
# prompt=self.PROMPT,
bad_words
=
bad_words
,
# num_prompt_tokens=self.num_prompt_tokens,
)
# bad_words=bad_words,
# )
def
_encode
(
self
,
prompt
:
str
,
# def _encode(self,
add_special_tokens
:
bool
=
True
)
->
list
[
int
]:
# prompt: str,
return
self
.
tokenizer
(
prompt
,
# add_special_tokens: bool = True) -> list[int]:
add_special_tokens
=
add_special_tokens
).
input_ids
# return self.tokenizer(prompt,
# add_special_tokens=add_special_tokens).input_ids
class
TestTwoTokenBadWord
:
# Another model (with a different tokenizer behaviour)
# class TestTwoTokenBadWord:
MODEL
=
os
.
path
.
join
(
models_path_prefix
,
"distilbert/distilgpt2"
)
# # Another model (with a different tokenizer behaviour)
# MODEL = os.path.join(models_path_prefix, "distilbert/distilgpt2")
PROMPT
=
"How old are you? I am 10"
TARGET_TOKEN1
=
"years"
# PROMPT = "How old are you? I am 10"
TARGET_TOKEN2
=
"old"
# TARGET_TOKEN1 = "years"
NEIGHBOUR_TOKEN2
=
"older"
# TARGET_TOKEN2 = "old"
# NEIGHBOUR_TOKEN2 = "older"
def
setup_method
(
self
,
method
):
self
.
tokenizer
=
AutoTokenizer
.
from_pretrained
(
self
.
MODEL
,
# def setup_method(self, method):
add_prefix_space
=
True
)
# self.tokenizer = AutoTokenizer.from_pretrained(self.MODEL,
# add_prefix_space=True)
self
.
num_prompt_tokens
=
len
(
self
.
_encode
(
self
.
PROMPT
))
self
.
target_token_id1
=
self
.
_encode
(
self
.
TARGET_TOKEN1
,
# self.num_prompt_tokens = len(self._encode(self.PROMPT))
add_special_tokens
=
False
)[
0
]
# self.target_token_id1 = self._encode(self.TARGET_TOKEN1,
self
.
target_token_id2
=
self
.
_encode
(
self
.
TARGET_TOKEN2
,
# add_special_tokens=False)[0]
add_special_tokens
=
False
)[
0
]
# self.target_token_id2 = self._encode(self.TARGET_TOKEN2,
self
.
neighbour_token_id2
=
self
.
_encode
(
self
.
NEIGHBOUR_TOKEN2
,
# add_special_tokens=False)[0]
add_special_tokens
=
False
)[
0
]
# self.neighbour_token_id2 = self._encode(self.NEIGHBOUR_TOKEN2,
# add_special_tokens=False)[0]
def
test_two_token_bad_word
(
self
,
vllm_runner
):
with
vllm_runner
(
self
.
MODEL
,
dtype
=
"half"
)
as
llm
:
# def test_two_token_bad_word(self, vllm_runner):
output_token_ids
=
self
.
_generate
(
llm
)
# with vllm_runner(self.MODEL, dtype="half") as llm:
assert
output_token_ids
[:
2
]
==
[
# output_token_ids = self._generate(llm)
self
.
target_token_id1
,
self
.
target_token_id2
# assert output_token_ids[:2] == [
]
# self.target_token_id1, self.target_token_id2
# ]
output_token_ids
=
self
.
_generate
(
llm
,
bad_words
=
[
self
.
TARGET_TOKEN1
])
# output_token_ids = self._generate(llm,
assert
self
.
target_token_id1
not
in
output_token_ids
# bad_words=[self.TARGET_TOKEN1])
# assert self.target_token_id1 not in output_token_ids
output_token_ids
=
self
.
_generate
(
llm
,
bad_words
=
[
self
.
TARGET_TOKEN2
])
# output_token_ids = self._generate(llm,
assert
output_token_ids
[
0
]
==
self
.
target_token_id1
# bad_words=[self.TARGET_TOKEN2])
assert
self
.
target_token_id2
not
in
output_token_ids
# assert output_token_ids[0] == self.target_token_id1
# assert self.target_token_id2 not in output_token_ids
output_token_ids
=
self
.
_generate
(
llm
,
bad_words
=
[
f
'
{
self
.
TARGET_TOKEN1
}
{
self
.
TARGET_TOKEN2
}
'
])
# output_token_ids = self._generate(
assert
output_token_ids
[
0
]
==
self
.
target_token_id1
# llm, bad_words=[f'{self.TARGET_TOKEN1} {self.TARGET_TOKEN2}'])
assert
output_token_ids
[:
2
]
!=
[
# assert output_token_ids[0] == self.target_token_id1
self
.
target_token_id1
,
self
.
target_token_id2
# assert output_token_ids[:2] != [
]
# self.target_token_id1, self.target_token_id2
assert
not
self
.
_contains
(
# ]
output_token_ids
,
# assert not self._contains(
[
self
.
target_token_id1
,
self
.
target_token_id2
])
# output_token_ids,
# Model dependent behaviour
# [self.target_token_id1, self.target_token_id2])
assert
output_token_ids
[:
2
]
==
[
# # Model dependent behaviour
self
.
target_token_id1
,
self
.
neighbour_token_id2
# assert output_token_ids[:2] == [
]
# self.target_token_id1, self.neighbour_token_id2
# ]
output_token_ids
=
self
.
_generate
(
llm
,
# output_token_ids = self._generate(
bad_words
=
[
# llm,
f
'
{
self
.
TARGET_TOKEN1
}
{
self
.
TARGET_TOKEN2
}
'
,
# bad_words=[
f
'
{
self
.
TARGET_TOKEN1
}
{
self
.
NEIGHBOUR_TOKEN2
}
'
# f'{self.TARGET_TOKEN1} {self.TARGET_TOKEN2}',
])
# f'{self.TARGET_TOKEN1} {self.NEIGHBOUR_TOKEN2}'
assert
output_token_ids
[
0
]
==
self
.
target_token_id1
# ])
assert
output_token_ids
[:
2
]
!=
[
# assert output_token_ids[0] == self.target_token_id1
self
.
target_token_id1
,
self
.
target_token_id2
# assert output_token_ids[:2] != [
]
# self.target_token_id1, self.target_token_id2
assert
not
self
.
_contains
(
# ]
output_token_ids
,
# assert not self._contains(
[
self
.
target_token_id1
,
self
.
target_token_id2
])
# output_token_ids,
assert
output_token_ids
[:
2
]
!=
[
# [self.target_token_id1, self.target_token_id2])
self
.
target_token_id1
,
self
.
neighbour_token_id2
# assert output_token_ids[:2] != [
]
# self.target_token_id1, self.neighbour_token_id2
assert
not
self
.
_contains
(
# ]
output_token_ids
,
# assert not self._contains(
[
self
.
target_token_id1
,
self
.
neighbour_token_id2
])
# output_token_ids,
assert
((
self
.
target_token_id2
in
output_token_ids
)
# [self.target_token_id1, self.neighbour_token_id2])
or
(
self
.
neighbour_token_id2
in
output_token_ids
))
# assert ((self.target_token_id2 in output_token_ids)
# or (self.neighbour_token_id2 in output_token_ids))
def
_generate
(
self
,
model
:
LLM
,
# def _generate(self,
bad_words
:
Optional
[
list
[
str
]]
=
None
)
->
list
[
int
]:
# model: LLM,
return
_generate
(
# bad_words: Optional[list[str]] = None) -> list[int]:
model
=
model
,
# return _generate(
prompt
=
self
.
PROMPT
,
# model=model,
num_prompt_tokens
=
self
.
num_prompt_tokens
,
# prompt=self.PROMPT,
bad_words
=
bad_words
,
# num_prompt_tokens=self.num_prompt_tokens,
)
# bad_words=bad_words,
# )
@
staticmethod
def
_contains
(
sequence
:
list
[
int
],
subsequence
:
list
[
int
])
->
bool
:
# @staticmethod
searched
=
False
# def _contains(sequence: list[int], subsequence: list[int]) -> bool:
# searched = False
for
start
in
range
(
len
(
sequence
)):
end
=
start
+
len
(
subsequence
)
# for start in range(len(sequence)):
current_subsequence
=
sequence
[
start
:
end
]
# end = start + len(subsequence)
# current_subsequence = sequence[start:end]
if
len
(
current_subsequence
)
<
len
(
subsequence
):
continue
# if len(current_subsequence) < len(subsequence):
# continue
searched
=
True
# searched = True
assert
len
(
current_subsequence
)
==
len
(
subsequence
)
# assert len(current_subsequence) == len(subsequence)
if
current_subsequence
==
subsequence
:
return
True
# if current_subsequence == subsequence:
# return True
assert
searched
,
"All subsequences did not match in length..."
# assert searched, "All subsequences did not match in length..."
return
False
# return False
def
_encode
(
self
,
prompt
:
str
,
# def _encode(self,
add_special_tokens
:
bool
=
True
)
->
list
[
int
]:
# prompt: str,
return
self
.
tokenizer
(
prompt
,
# add_special_tokens: bool = True) -> list[int]:
add_special_tokens
=
add_special_tokens
).
input_ids
# return self.tokenizer(prompt,
\ No newline at end of file
# add_special_tokens=add_special_tokens).input_ids
\ No newline at end of file
tests/samplers/test_sampler.py
View file @
415b817b
...
@@ -560,6 +560,9 @@ def test_sampler_mixed(seed: int, device: str):
...
@@ -560,6 +560,9 @@ def test_sampler_mixed(seed: int, device: str):
test_sampling
()
test_sampling
()
# TODO
if
17
in
RANDOM_SEEDS
:
RANDOM_SEEDS
.
remove
(
17
)
@
pytest
.
mark
.
parametrize
(
"seed"
,
RANDOM_SEEDS
)
@
pytest
.
mark
.
parametrize
(
"seed"
,
RANDOM_SEEDS
)
@
pytest
.
mark
.
parametrize
(
"device"
,
CUDA_DEVICES
)
@
pytest
.
mark
.
parametrize
(
"device"
,
CUDA_DEVICES
)
def
test_sampler_top_k_top_p
(
seed
:
int
,
device
:
str
):
def
test_sampler_top_k_top_p
(
seed
:
int
,
device
:
str
):
...
...
tests/spec_decode/e2e/test_integration.py
→
tests/spec_decode/e2e/
un
test_integration.py
View file @
415b817b
File moved
tests/spec_decode/e2e/test_logprobs.py
→
tests/spec_decode/e2e/
un
test_logprobs.py
View file @
415b817b
File moved
tests/spec_decode/test_memory_usage.py
View file @
415b817b
...
@@ -16,15 +16,17 @@ increase our memory usage over time is essential to prevent possible CUDA ooms.
...
@@ -16,15 +16,17 @@ increase our memory usage over time is essential to prevent possible CUDA ooms.
import
torch
import
torch
import
os
import
vllm
import
vllm
from
tests.core.utils
import
create_dummy_prompt
from
tests.core.utils
import
create_dummy_prompt
from
vllm.sequence
import
SequenceGroup
from
vllm.sequence
import
SequenceGroup
from
utils
import
models_path_prefix
ITERATIONS
=
100
ITERATIONS
=
100
MAIN_MODEL
=
"JackFram/llama-68m"
MAIN_MODEL
=
os
.
path
.
join
(
models_path_prefix
,
"JackFram/llama-68m"
)
# speculative model
# speculative model
SPEC_MODEL
=
"abhigoyal/vllm-medusa-llama-68m-random"
SPEC_MODEL
=
os
.
path
.
join
(
models_path_prefix
,
"abhigoyal/vllm-medusa-llama-68m-random"
)
BATCH_SIZE
=
5
BATCH_SIZE
=
5
SPEC_DISABLE_BATCH_SIZE
=
2
SPEC_DISABLE_BATCH_SIZE
=
2
...
...
tests/spec_decode/test_multi_step_worker.py
View file @
415b817b
...
@@ -22,6 +22,7 @@ from vllm.worker.worker import Worker
...
@@ -22,6 +22,7 @@ from vllm.worker.worker import Worker
from
.utils
import
(
assert_logprobs_dict_allclose
,
create_batch
,
from
.utils
import
(
assert_logprobs_dict_allclose
,
create_batch
,
create_seq_group_metadata_from_prompts
,
create_worker
,
create_seq_group_metadata_from_prompts
,
create_worker
,
patch_execute_model_with_seeds
,
zero_kv_cache
)
patch_execute_model_with_seeds
,
zero_kv_cache
)
from
vllm.platforms
import
current_platform
from
..utils
import
models_path_prefix
from
..utils
import
models_path_prefix
...
@@ -171,7 +172,7 @@ def test_same_output_for_multi_step():
...
@@ -171,7 +172,7 @@ def test_same_output_for_multi_step():
seed
=
100
seed
=
100
model_name
=
os
.
path
.
join
(
models_path_prefix
,
'JackFram/llama-68m'
)
model_name
=
os
.
path
.
join
(
models_path_prefix
,
'JackFram/llama-68m'
)
block_size
=
16
block_size
=
16
if
not
current_platform
.
is_rocm
()
else
64
,
num_gpu_blocks
=
2048
//
block_size
num_gpu_blocks
=
2048
//
block_size
multi_step_worker
=
create_worker
(
multi_step_worker
=
create_worker
(
MultiStepWorker
,
MultiStepWorker
,
...
@@ -298,7 +299,7 @@ def test_multi_step_with_batch_expansion_correct_output():
...
@@ -298,7 +299,7 @@ def test_multi_step_with_batch_expansion_correct_output():
seed
=
100
seed
=
100
model_name
=
os
.
path
.
join
(
models_path_prefix
,
'JackFram/llama-68m'
)
model_name
=
os
.
path
.
join
(
models_path_prefix
,
'JackFram/llama-68m'
)
block_size
=
16
block_size
=
16
if
not
current_platform
.
is_rocm
()
else
64
num_gpu_blocks
=
2048
//
block_size
num_gpu_blocks
=
2048
//
block_size
batch_size
=
128
batch_size
=
128
multi_step_worker
=
create_worker
(
multi_step_worker
=
create_worker
(
...
@@ -393,7 +394,7 @@ def test_multi_step_with_batch_expansion_incorrect_output():
...
@@ -393,7 +394,7 @@ def test_multi_step_with_batch_expansion_incorrect_output():
seed
=
100
seed
=
100
model_name
=
os
.
path
.
join
(
models_path_prefix
,
'JackFram/llama-68m'
)
model_name
=
os
.
path
.
join
(
models_path_prefix
,
'JackFram/llama-68m'
)
block_size
=
16
block_size
=
16
if
not
current_platform
.
is_rocm
()
else
64
num_gpu_blocks
=
2048
//
block_size
num_gpu_blocks
=
2048
//
block_size
batch_size
=
128
batch_size
=
128
multi_step_worker
=
create_worker
(
multi_step_worker
=
create_worker
(
...
@@ -765,8 +766,8 @@ def test_use_draft_model_runner_advance_step():
...
@@ -765,8 +766,8 @@ def test_use_draft_model_runner_advance_step():
model_name
=
os
.
path
.
join
(
models_path_prefix
,
'JackFram/llama-68m'
)
model_name
=
os
.
path
.
join
(
models_path_prefix
,
'JackFram/llama-68m'
)
k
=
5
k
=
5
batch_size
=
32
batch_size
=
32
block_size
=
32
block_size
=
32
if
not
current_platform
.
is_rocm
()
else
64
num_gpu_blocks
=
2048
//
block_size
num_gpu_blocks
=
2048
//
block_size
worker
=
create_worker
(
worker
=
create_worker
(
MultiStepWorker
,
MultiStepWorker
,
...
...
tests/tokenization/test_detokenize.py
View file @
415b817b
...
@@ -18,6 +18,7 @@ from vllm.v1.engine import EngineCoreRequest
...
@@ -18,6 +18,7 @@ from vllm.v1.engine import EngineCoreRequest
from
vllm.v1.engine.detokenizer
import
(
FastIncrementalDetokenizer
,
from
vllm.v1.engine.detokenizer
import
(
FastIncrementalDetokenizer
,
IncrementalDetokenizer
,
IncrementalDetokenizer
,
SlowIncrementalDetokenizer
)
SlowIncrementalDetokenizer
)
from
vllm.platforms
import
current_platform
from
..utils
import
models_path_prefix
from
..utils
import
models_path_prefix
SPECIAL_TOKS_TRUTH
=
[
SPECIAL_TOKS_TRUTH
=
[
...
@@ -249,7 +250,7 @@ def create_sequence(prompt_token_ids=None):
...
@@ -249,7 +250,7 @@ def create_sequence(prompt_token_ids=None):
return
Sequence
(
return
Sequence
(
seq_id
=
0
,
seq_id
=
0
,
inputs
=
token_inputs
(
prompt_token_ids
),
inputs
=
token_inputs
(
prompt_token_ids
),
block_size
=
16
,
block_size
=
16
if
not
current_platform
.
is_rocm
()
else
64
,
)
)
...
...
tests/tokenization/test_tokenizer_group.py
View file @
415b817b
...
@@ -15,7 +15,7 @@ async def test_tokenizer_group():
...
@@ -15,7 +15,7 @@ async def test_tokenizer_group():
# reference_tokenizer = AutoTokenizer.from_pretrained(os.path.join(models_path_prefix, "gpt2"))
# reference_tokenizer = AutoTokenizer.from_pretrained(os.path.join(models_path_prefix, "gpt2"))
reference_tokenizer
=
AutoTokenizer
.
from_pretrained
(
"gpt2"
)
reference_tokenizer
=
AutoTokenizer
.
from_pretrained
(
"gpt2"
)
tokenizer_group
=
TokenizerGroup
(
tokenizer_group
=
TokenizerGroup
(
#
tokenizer_id=os.path.join(models_path_prefix, "gpt2"),
tokenizer_id
=
os
.
path
.
join
(
models_path_prefix
,
"gpt2"
),
enable_lora
=
False
,
enable_lora
=
False
,
max_num_seqs
=
1
,
max_num_seqs
=
1
,
max_input_length
=
None
,
max_input_length
=
None
,
...
...
tests/tool_use/test_xlam_tool_parser.py
View file @
415b817b
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
import
os
import
json
import
json
import
pytest
import
pytest
...
@@ -8,9 +9,10 @@ import pytest
...
@@ -8,9 +9,10 @@ import pytest
from
vllm.entrypoints.openai.protocol
import
FunctionCall
,
ToolCall
from
vllm.entrypoints.openai.protocol
import
FunctionCall
,
ToolCall
from
vllm.entrypoints.openai.tool_parsers
import
xLAMToolParser
from
vllm.entrypoints.openai.tool_parsers
import
xLAMToolParser
from
vllm.transformers_utils.tokenizer
import
get_tokenizer
from
vllm.transformers_utils.tokenizer
import
get_tokenizer
from
..utils
import
models_path_prefix
# Use a common model that is likely to be available
# Use a common model that is likely to be available
MODEL
=
"Salesforce/Llama-xLAM-2-8B-fc-r"
MODEL
=
os
.
path
.
join
(
models_path_prefix
,
"Salesforce/Llama-xLAM-2-8B-fc-r"
)
@
pytest
.
fixture
(
scope
=
"module"
)
@
pytest
.
fixture
(
scope
=
"module"
)
...
...
vllm/_custom_ops.py
View file @
415b817b
...
@@ -1971,7 +1971,8 @@ def wvSplitKQ(a: torch.Tensor, b: torch.Tensor, out_dtype: torch.dtype,
...
@@ -1971,7 +1971,8 @@ def wvSplitKQ(a: torch.Tensor, b: torch.Tensor, out_dtype: torch.dtype,
# moe
# moe
def
moe_sum
(
input
:
torch
.
Tensor
,
output
:
torch
.
Tensor
):
def
moe_sum
(
input
:
torch
.
Tensor
,
output
:
torch
.
Tensor
):
torch
.
ops
.
_moe_C
.
moe_sum
(
input
,
output
)
torch
.
ops
.
_moe_C
.
moe_sum
(
input
,
output
)
def
moe_sum_opt1
(
input
:
torch
.
Tensor
,
output
:
torch
.
Tensor
):
torch
.
ops
.
_moe_C
.
moe_sum_opt1
(
input
,
output
)
def
moe_align_block_size
(
topk_ids
:
torch
.
Tensor
,
num_experts
:
int
,
def
moe_align_block_size
(
topk_ids
:
torch
.
Tensor
,
num_experts
:
int
,
block_size
:
int
,
sorted_token_ids
:
torch
.
Tensor
,
block_size
:
int
,
sorted_token_ids
:
torch
.
Tensor
,
...
...
vllm/distributed/kv_transfer/kv_connector/v1/p2p/p2p_nccl_connector.py
View file @
415b817b
...
@@ -215,6 +215,9 @@ class P2pNcclConnector(KVConnectorBase_V1):
...
@@ -215,6 +215,9 @@ class P2pNcclConnector(KVConnectorBase_V1):
inject_kv_into_layer
(
kv_cache_layer
,
kv_cache
,
inject_kv_into_layer
(
kv_cache_layer
,
kv_cache
,
request
.
slot_mapping
,
request
.
request_id
)
request
.
slot_mapping
,
request
.
request_id
)
tensor
=
self
.
p2p_nccl_engine
.
recv_store
.
pop
(
request
.
request_id
+
"#"
+
layer_name
,
None
)
if
tensor
is
not
None
:
del
tensor
def
wait_for_layer_load
(
self
,
layer_name
:
str
)
->
None
:
def
wait_for_layer_load
(
self
,
layer_name
:
str
)
->
None
:
"""Blocking until the KV for a specific layer is loaded into vLLM's
"""Blocking until the KV for a specific layer is loaded into vLLM's
...
...
vllm/engine/arg_utils.py
View file @
415b817b
...
@@ -1004,7 +1004,7 @@ class EngineArgs:
...
@@ -1004,7 +1004,7 @@ class EngineArgs:
enable_sleep_mode
=
self
.
enable_sleep_mode
,
enable_sleep_mode
=
self
.
enable_sleep_mode
,
model_impl
=
self
.
model_impl
,
model_impl
=
self
.
model_impl
,
override_attention_dtype
=
self
.
override_attention_dtype
,
override_attention_dtype
=
self
.
override_attention_dtype
,
enable_chunked_prefill
=
self
.
enable_chunked_prefill
enable_chunked_prefill
=
self
.
enable_chunked_prefill
,
)
)
def
create_load_config
(
self
)
->
LoadConfig
:
def
create_load_config
(
self
)
->
LoadConfig
:
...
...
vllm/model_executor/layers/fused_moe/ep_moe/layer.py
View file @
415b817b
...
@@ -368,11 +368,11 @@ class EPMoE(FusedMoE):
...
@@ -368,11 +368,11 @@ class EPMoE(FusedMoE):
dispatch_indices
=
dispatch_indices
[:
dispatch_recv_num_token
]
dispatch_indices
=
dispatch_indices
[:
dispatch_recv_num_token
]
valid_mask
=
((
dispatch_indices
<=
255
)
&
(
dispatch_indices
>=
0
)).
all
(
dim
=
1
)
#
valid_mask = ((dispatch_indices <= 255) & (dispatch_indices >= 0)).all(dim=1)
dispatch_output
=
dispatch_output
[
valid_mask
]
#
dispatch_output = dispatch_output[valid_mask]
dispatch_indices
=
dispatch_indices
[
valid_mask
]
#
dispatch_indices = dispatch_indices[valid_mask]
dispatch_weights
=
dispatch_weights
[
valid_mask
]
#
dispatch_weights = dispatch_weights[valid_mask]
dispatch_recv_num_token
=
dispatch_indices
.
shape
[
0
]
#
dispatch_recv_num_token = dispatch_indices.shape[0]
# dispatch_recv_num_token = dispatch_recv_num_token.cpu()[0]
# dispatch_recv_num_token = dispatch_recv_num_token.cpu()[0]
# has_greater_than_255 = torch.any(dispatch_indices > 255).item()
# has_greater_than_255 = torch.any(dispatch_indices > 255).item()
...
...
vllm/model_executor/layers/fused_moe/layer.py
View file @
415b817b
...
@@ -42,6 +42,7 @@ from vllm.platforms.interface import CpuArchEnum
...
@@ -42,6 +42,7 @@ from vllm.platforms.interface import CpuArchEnum
from
vllm.utils
import
direct_register_custom_op
,
has_deep_ep
,
has_pplx
from
vllm.utils
import
direct_register_custom_op
,
has_deep_ep
,
has_pplx
from
vllm
import
_custom_ops
as
ops
from
vllm
import
_custom_ops
as
ops
from
lightop
import
op
if
current_platform
.
is_cuda_alike
():
if
current_platform
.
is_cuda_alike
():
from
.fused_batched_moe
import
BatchedTritonExperts
from
.fused_batched_moe
import
BatchedTritonExperts
...
@@ -1284,15 +1285,26 @@ class FusedMoE(torch.nn.Module):
...
@@ -1284,15 +1285,26 @@ class FusedMoE(torch.nn.Module):
assert
topk_group
is
not
None
assert
topk_group
is
not
None
assert
num_expert_group
is
not
None
assert
num_expert_group
is
not
None
if
use_fused_gate
:
if
use_fused_gate
:
topk_weights
,
topk_ids
=
ops
.
moe_fused_gate
(
if
envs
.
VLLM_USE_LIGHT_OP
:
router_logits
,
topk_weights
,
topk_ids
=
op
.
moe_fused_gate
(
e_score_correction_bias
,
router_logits
,
num_expert_group
,
e_score_correction_bias
,
topk_group
,
num_expert_group
,
top_k
,
topk_group
,
routed_scaling_factor
=
routed_scaling_factor
,
top_k
,
n_share_experts_fusion
=
0
,
0
,
)
routed_scaling_factor
,
)
else
:
topk_weights
,
topk_ids
=
ops
.
moe_fused_gate
(
router_logits
,
e_score_correction_bias
,
num_expert_group
,
topk_group
,
top_k
,
routed_scaling_factor
=
routed_scaling_factor
,
n_share_experts_fusion
=
0
,
)
else
:
else
:
topk_weights
,
topk_ids
=
grouped_topk
(
topk_weights
,
topk_ids
=
grouped_topk
(
hidden_states
=
hidden_states
,
hidden_states
=
hidden_states
,
...
...
vllm/model_executor/layers/fused_moe/moe_align_block_size.py
View file @
415b817b
...
@@ -8,6 +8,9 @@ from vllm import _custom_ops as ops
...
@@ -8,6 +8,9 @@ from vllm import _custom_ops as ops
from
vllm.triton_utils
import
tl
,
triton
from
vllm.triton_utils
import
tl
,
triton
from
vllm.utils
import
cdiv
,
round_up
from
vllm.utils
import
cdiv
,
round_up
import
vllm.envs
as
envs
from
lightop
import
op
@
triton
.
jit
@
triton
.
jit
def
moe_align_block_size_stage1
(
def
moe_align_block_size_stage1
(
...
@@ -229,8 +232,12 @@ def moe_align_block_size(
...
@@ -229,8 +232,12 @@ def moe_align_block_size(
dtype
=
torch
.
int32
,
dtype
=
torch
.
int32
,
device
=
topk_ids
.
device
)
device
=
topk_ids
.
device
)
ops
.
moe_align_block_size
(
topk_ids
,
num_experts
,
block_size
,
sorted_ids
,
if
envs
.
VLLM_USE_LIGHT_OP
:
expert_ids
,
num_tokens_post_pad
)
op
.
moe_align_block_size
(
topk_ids
,
num_experts
,
block_size
,
sorted_ids
,
expert_ids
,
num_tokens_post_pad
)
else
:
ops
.
moe_align_block_size
(
topk_ids
,
num_experts
,
block_size
,
sorted_ids
,
expert_ids
,
num_tokens_post_pad
)
if
expert_map
is
not
None
:
if
expert_map
is
not
None
:
expert_ids
=
expert_map
[
expert_ids
]
expert_ids
=
expert_map
[
expert_ids
]
...
...
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment