[V1] Make v1 more testable (#9888)
Signed-off-by: Joe Runde <Joseph.Runde@ibm.com>
This commit is contained in:
@@ -136,7 +136,7 @@ class FlashAttentionImpl(AttentionImpl):
|
||||
"key/v_scale is not supported in FlashAttention.")
|
||||
|
||||
output = torch.empty_like(query)
|
||||
torch.ops.vllm.unified_flash_attention(
|
||||
torch.ops.vllm.unified_v1_flash_attention(
|
||||
output,
|
||||
query,
|
||||
key,
|
||||
@@ -156,7 +156,7 @@ class FlashAttentionImpl(AttentionImpl):
|
||||
return output
|
||||
|
||||
|
||||
def unified_flash_attention(
|
||||
def unified_v1_flash_attention(
|
||||
output: torch.Tensor,
|
||||
query: torch.Tensor,
|
||||
key: torch.Tensor,
|
||||
@@ -222,7 +222,7 @@ def unified_flash_attention(
|
||||
output[:num_actual_tokens].copy_(attn_output)
|
||||
|
||||
|
||||
def unified_flash_attention_fake(
|
||||
def unified_v1_flash_attention_fake(
|
||||
output: torch.Tensor,
|
||||
query: torch.Tensor,
|
||||
key: torch.Tensor,
|
||||
@@ -243,8 +243,8 @@ def unified_flash_attention_fake(
|
||||
|
||||
|
||||
direct_register_custom_op(
|
||||
op_name="unified_flash_attention",
|
||||
op_func=unified_flash_attention,
|
||||
op_name="unified_v1_flash_attention",
|
||||
op_func=unified_v1_flash_attention,
|
||||
mutates_args=["kv_cache", "output"],
|
||||
fake_impl=unified_flash_attention_fake,
|
||||
fake_impl=unified_v1_flash_attention_fake,
|
||||
)
|
||||
|
||||
@@ -155,6 +155,12 @@ class LLMEngine:
|
||||
# GPU and CPU blocks, which are profiled in the distributed executor.
|
||||
self.scheduler = Scheduler(scheduler_config, cache_config, lora_config)
|
||||
|
||||
def __del__(self):
|
||||
# Small hack- implicit clean up of resources on garbage collect
|
||||
# TODO: this should probably be explicitly invoked when we're done with
|
||||
# the engine
|
||||
self.terminate_detokenizer()
|
||||
|
||||
def _initialize_kv_caches(self) -> None:
|
||||
num_gpu_blocks, _ = self.model_executor.determine_num_available_blocks(
|
||||
)
|
||||
|
||||
@@ -73,7 +73,7 @@ class Detokenizer:
|
||||
return None
|
||||
|
||||
def terminate(self) -> None:
|
||||
self.push_socket.send(b"", flags=zmq.NOBLOCK)
|
||||
self.detokenizer.kill()
|
||||
self.detokenizer.join()
|
||||
|
||||
|
||||
@@ -108,10 +108,10 @@ class DetokenizerProc(multiprocessing.Process):
|
||||
self.push_socket.bind(f"tcp://*:{self.push_port}")
|
||||
|
||||
while True:
|
||||
if self.pull_socket.poll(timeout=1000) == 0:
|
||||
# Nothing to read
|
||||
continue
|
||||
message = self.pull_socket.recv()
|
||||
if message == b"":
|
||||
# Terminate signal.
|
||||
break
|
||||
inputs = self.msgpack_decoder.decode(message)
|
||||
|
||||
for req_id in inputs.free_req_ids:
|
||||
|
||||
@@ -2,7 +2,6 @@ import os
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING, Dict, List, Optional, Set
|
||||
from unittest.mock import patch
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
@@ -26,7 +25,6 @@ from vllm.v1.attention.backends.flash_attn import (FlashAttentionBackend,
|
||||
FlashAttentionMetadata)
|
||||
from vllm.v1.outputs import ModelRunnerOutput
|
||||
from vllm.v1.sample.metadata import SamplingMetadata
|
||||
from vllm.v1.sample.sampler import Sampler
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from vllm.v1.core.scheduler import SchedulerOutput
|
||||
@@ -418,8 +416,7 @@ class GPUModelRunner:
|
||||
|
||||
logger.info("Starting to load model %s...", self.model_config.model)
|
||||
with DeviceMemoryProfiler() as m: # noqa: SIM117
|
||||
with patch("vllm.model_executor.layers.sampler.Sampler", Sampler):
|
||||
self.model = get_model(vllm_config=self.vllm_config)
|
||||
self.model = get_model(vllm_config=self.vllm_config)
|
||||
|
||||
self.model_memory_usage = m.consumed_memory
|
||||
logger.info("Loading model weights took %.4f GB",
|
||||
|
||||
Reference in New Issue
Block a user