From b4349f217922e9fb90ab3ce2fb648e936408fe91 Mon Sep 17 00:00:00 2001 From: Mohammad Othman Date: Fri, 14 Nov 2025 20:17:36 +0200 Subject: [PATCH 1/3] Add type hints to IntermediateTensors.__init__ Signed-off-by: Mohammad Othman --- vllm/sequence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vllm/sequence.py b/vllm/sequence.py index 6bcc94ad5c62..111f963a3fd7 100644 --- a/vllm/sequence.py +++ b/vllm/sequence.py @@ -60,7 +60,7 @@ class IntermediateTensors: tensors: dict[str, torch.Tensor] kv_connector_output: KVConnectorOutput | None - def __init__(self, tensors): + def __init__(self, tensors: dict[str, torch.Tensor]) -> None: # manually define this function, so that # Dynamo knows `IntermediateTensors()` comes from this file. # Otherwise, dataclass will generate this function by evaluating From 5d1b6f11ad8cf6e2010697f1ecc4f0c1e3f62fc1 Mon Sep 17 00:00:00 2001 From: Mohammad Othman Date: Fri, 14 Nov 2025 20:33:57 +0200 Subject: [PATCH 2/3] Initialize kv_connector_output field in __init__ Signed-off-by: Mohammad Othman --- vllm/sequence.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vllm/sequence.py b/vllm/sequence.py index 111f963a3fd7..fa68791113ee 100644 --- a/vllm/sequence.py +++ b/vllm/sequence.py @@ -60,12 +60,13 @@ class IntermediateTensors: tensors: dict[str, torch.Tensor] kv_connector_output: KVConnectorOutput | None - def __init__(self, tensors: dict[str, torch.Tensor]) -> None: + def __init__(self, tensors: dict[str, torch.Tensor], kv_connector_output: KVConnectorOutput | None = None) -> None: # manually define this function, so that # Dynamo knows `IntermediateTensors()` comes from this file. # Otherwise, dataclass will generate this function by evaluating # a string, and we will lose the information about the source file. self.tensors = tensors + self.kv_connector_output = kv_connector_output def __getitem__(self, key: str | slice): if isinstance(key, str): From 194efc82df81d0d6c171f0d5e5e6c48a685c544c Mon Sep 17 00:00:00 2001 From: Mohammad Othman Date: Fri, 14 Nov 2025 20:42:08 +0200 Subject: [PATCH 3/3] Fix line length to comply with ruff formatter Signed-off-by: Mohammad Othman --- vllm/sequence.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vllm/sequence.py b/vllm/sequence.py index fa68791113ee..6d20ca9aac22 100644 --- a/vllm/sequence.py +++ b/vllm/sequence.py @@ -60,7 +60,11 @@ class IntermediateTensors: tensors: dict[str, torch.Tensor] kv_connector_output: KVConnectorOutput | None - def __init__(self, tensors: dict[str, torch.Tensor], kv_connector_output: KVConnectorOutput | None = None) -> None: + def __init__( + self, + tensors: dict[str, torch.Tensor], + kv_connector_output: KVConnectorOutput | None = None, + ) -> None: # manually define this function, so that # Dynamo knows `IntermediateTensors()` comes from this file. # Otherwise, dataclass will generate this function by evaluating