[ModelRunner V2] Speculative Decoding NGram GPU Implementations (#40704)
Signed-off-by: PatchouliTaisa <patchychen@tencent.com> Signed-off-by: PatchouliTaisa <pyramkar@gmail.com> Signed-off-by: Nick Hill <nickhill123@gmail.com> Signed-off-by: Xuanan Chen <xuananchenc@nvidia.com> Co-authored-by: PatchouliTaisa <patchychen@tencent.com> Co-authored-by: Nick Hill <nickhill123@gmail.com> Co-authored-by: Xuanan Chen <xuananchenc@nvidia.com> Co-authored-by: Giancarlo Delfin <32987265+TheEpicDolphin@users.noreply.github.com>
This commit is contained in:
co-authored by
PatchouliTaisa
Nick Hill
Xuanan Chen
Giancarlo Delfin
parent
dac35c5b66
commit
819852df6b
@@ -45,7 +45,8 @@ def test_init_speculator_dispatches_extract_hidden_states(monkeypatch):
|
||||
|
||||
monkeypatch.setattr(spec_module, "ExtractHiddenStatesSpeculator", fake_speculator)
|
||||
|
||||
assert init_speculator(vllm_config, device) == (vllm_config, device)
|
||||
speculator = init_speculator(vllm_config, device, cast(Any, None))
|
||||
assert speculator == (vllm_config, device)
|
||||
|
||||
|
||||
def test_propose_caches_hidden_states_and_returns_sampled_tokens(monkeypatch):
|
||||
|
||||
@@ -337,3 +337,23 @@ def test_capture_model_profile_only_skips_lock(monkeypatch):
|
||||
runner.capture_model(profile_only=True)
|
||||
|
||||
assert lock_calls == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("target_buffer", ["absent", "none", "tensor"])
|
||||
def test_get_drafter_hidden_states_tolerates_missing_target_buffer(target_buffer):
|
||||
"""Targets allocate the MTP hidden buffer only for hidden-state drafters."""
|
||||
runner = GPUModelRunner.__new__(GPUModelRunner)
|
||||
hidden_states = torch.zeros(4, 8)
|
||||
buffer = torch.arange(16 * 8, dtype=torch.float32).view(16, 8)
|
||||
if target_buffer == "absent":
|
||||
runner.model = SimpleNamespace()
|
||||
else:
|
||||
returned = buffer if target_buffer == "tensor" else None
|
||||
runner.model = SimpleNamespace(get_mtp_target_hidden_states=lambda: returned)
|
||||
|
||||
out = runner._get_drafter_hidden_states(hidden_states)
|
||||
|
||||
if target_buffer == "tensor":
|
||||
assert torch.equal(out, buffer[:4])
|
||||
else:
|
||||
assert out is hidden_states
|
||||
|
||||
Reference in New Issue
Block a user