Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions vllm/distributed/kv_transfer/kv_connector/v1/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def is_empty(self) -> bool:


class KVConnectorLogging:
def __init__(self, kv_tranfer_config: KVTransferConfig):
def __init__(self, kv_transfer_config: KVTransferConfig):
# This should be called on frontend process.
assert not has_kv_transfer_group()
# Instantiate the connector's stats class.
if kv_tranfer_config and kv_tranfer_config.kv_connector:
if kv_transfer_config and kv_transfer_config.kv_connector:
self.connector_cls = KVConnectorFactory.get_connector_class(
kv_tranfer_config
kv_transfer_config
)
self.reset()
Comment on lines +50 to 58
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The attribute self.connector_cls is only initialized within the if block. If the condition is false, self.connector_cls is never set. While the current call site for observe() seems to be safe, this can lead to an AttributeError in the future if observe() is called. It's best practice to initialize all instance attributes in __init__. Consider initializing self.connector_cls to None before the conditional block to make the class more robust.

Suggested change
def __init__(self, kv_transfer_config: KVTransferConfig):
# This should be called on frontend process.
assert not has_kv_transfer_group()
# Instantiate the connector's stats class.
if kv_tranfer_config and kv_tranfer_config.kv_connector:
if kv_transfer_config and kv_transfer_config.kv_connector:
self.connector_cls = KVConnectorFactory.get_connector_class(
kv_tranfer_config
kv_transfer_config
)
self.reset()
def __init__(self, kv_transfer_config: KVTransferConfig):
# This should be called on frontend process.
assert not has_kv_transfer_group()
# Instantiate the connector's stats class.
self.connector_cls = None
if kv_transfer_config and kv_transfer_config.kv_connector:
self.connector_cls = KVConnectorFactory.get_connector_class(
kv_transfer_config
)
self.reset()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not something introduced by this PR, and while not ideal, we would hit the AttributeError here:

assert self.connector_cls is not None

which is fine


Expand Down
4 changes: 2 additions & 2 deletions vllm/v1/metrics/loggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def __init__(self, vllm_config: VllmConfig, engine_index: int = 0):
# TODO: Make the interval configurable.
self.prefix_caching_metrics = PrefixCachingMetrics()
self.spec_decoding_logging = SpecDecodingLogging()
kv_tranfer_config = self.vllm_config.kv_transfer_config
self.kv_connector_logging = KVConnectorLogging(kv_tranfer_config)
kv_transfer_config = self.vllm_config.kv_transfer_config
self.kv_connector_logging = KVConnectorLogging(kv_transfer_config)
self.last_prompt_throughput: float = 0.0
self.last_generation_throughput: float = 0.0

Expand Down