[Model] YuE2: async single-stage synthesis and CUDA graph acceleration (#8407)
Signed-off-by: Sy03 <1370724210@qq.com> Signed-off-by: princepride <wangzhipeng628@gmail.com> Signed-off-by: Wang Zhipeng <wangzhipeng628@gmail.com> Co-authored-by: princepride <wangzhipeng628@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
12 files changed
+2182
-296
No files matched your search
@@ -16,6 +16,7 @@ import pytest
|
||||
import torch
|
||||
from vllm.sampling_params import SamplingParams
|
||||
from vllm.v1.sample.metadata import SamplingMetadata
|
||||
from vllm.v1.utils import CpuGpuBuffer
|
||||
from vllm.v1.worker import gpu_input_batch
|
||||
from vllm.v1.worker.gpu_input_batch import CachedRequestState, InputBatch
|
||||
|
||||
@@ -1885,3 +1886,63 @@ class TestPreferModelSamplerNoneFallback:
|
||||
"least tolerates -- that fallback, then add its directory name to "
|
||||
"`expected` above. If you REMOVED one, drop its name."
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("accepts_extra_args", [False, True])
|
||||
def test_prepare_hook_keeps_legacy_signature_and_orders_opt_in_metadata(accepts_extra_args: bool) -> None:
|
||||
runner = object.__new__(GPUARModelRunner)
|
||||
runner.model = torch.nn.Module()
|
||||
runner.model.accepts_runner_sampling_extra_args = accepts_extra_args
|
||||
runner.requests = {
|
||||
rid: CachedRequestState(
|
||||
req_id=rid,
|
||||
prompt_token_ids=[1],
|
||||
mm_features=[],
|
||||
sampling_params=params,
|
||||
generator=None,
|
||||
block_ids=([],),
|
||||
num_computed_tokens=0,
|
||||
output_token_ids=[],
|
||||
)
|
||||
for rid, params in (
|
||||
("a", SamplingParams(extra_args={"seed": 7})),
|
||||
("b", None),
|
||||
("unused", SamplingParams(extra_args={"seed": 9})),
|
||||
)
|
||||
}
|
||||
runner.discard_request_mask = CpuGpuBuffer(3, dtype=torch.bool, device=torch.device("cpu"), pin_memory=False)
|
||||
runner.discard_request_mask.np[:] = [True, False, True]
|
||||
ids, positions = torch.tensor([3, 4]), torch.tensor([0, 1])
|
||||
step_inputs = dict(
|
||||
input_ids=ids,
|
||||
positions=positions,
|
||||
inputs_embeds=None,
|
||||
num_computed_tokens=np.array([0, 1]),
|
||||
num_scheduled_tokens=np.array([1, 1]),
|
||||
input_ids_buffer=ids,
|
||||
)
|
||||
seen = {}
|
||||
|
||||
def legacy_hook(
|
||||
*, input_ids, positions, inputs_embeds, req_ids, num_computed_tokens, num_scheduled_tokens, input_ids_buffer
|
||||
):
|
||||
seen["req_ids"] = req_ids
|
||||
return input_ids, positions
|
||||
|
||||
def opt_in_hook(*, sampling_extra_args, discard_mask, **kwargs):
|
||||
seen["extra_args"] = sampling_extra_args
|
||||
seen["discard"] = discard_mask.tolist()
|
||||
return legacy_hook(**kwargs)
|
||||
|
||||
out = runner._call_prepare_runner_inputs(
|
||||
opt_in_hook if accepts_extra_args else legacy_hook,
|
||||
req_ids=["b", "a"],
|
||||
**step_inputs,
|
||||
)
|
||||
assert out[0] is ids and out[1] is positions
|
||||
assert seen["req_ids"] == ["b", "a"]
|
||||
if accepts_extra_args:
|
||||
assert seen["extra_args"] == [{}, {"seed": 7}]
|
||||
assert seen["discard"] == [True, False]
|
||||
else:
|
||||
assert set(seen) == {"req_ids"}
|
||||
Reference in new issue
Block a user