-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Fix EventPublisherFactory logic for disabled KV cache events and publisher is "null" #27257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix EventPublisherFactory logic for disabled KV cache events and publisher is "null" #27257
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses a logic flaw in the EventPublisherFactory.create method. The changes correctly ensure that a NullEventPublisher is returned when KV cache events are disabled (enable_kv_cache_events=False) or when the publisher is explicitly set to "null". This prevents a TypeError that would occur when trying to instantiate NullEventPublisher with unexpected arguments. The fix is implemented cleanly by adjusting the initial conditional check. Furthermore, a new test suite has been added, which thoroughly validates the factory's behavior across various configurations, including disabled events, different publisher types, and default settings. The changes are correct, well-tested, and improve the robustness of the event publisher creation logic.
caef5e7 to
1264fa6
Compare
…isher is "null" Signed-off-by: Bradley <[email protected]>
1264fa6 to
2cb60cd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
A suggestion for better (IMO) improvement inline
| config_dict = asdict(config) | ||
|
|
||
| kind = config_dict.pop("publisher", "null") | ||
| kind = config_dict.pop("publisher") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an observation, not a problem with this PR - if we ever add another publisher other than ZmqEventPublisher it will be required to accept all the members of KEventsConfig as constructor parameters, which doesn't make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, new EventPublisher may not need to implement all parameters of KEventsConfig
| not config | ||
| or not config.enable_kv_cache_events | ||
| or config.publisher == "null" | ||
| ): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this whole NullEventPublisher thing just isn't very useful ... we could just return None and make scheduler like this:
self.kv_event_publisher = EventPublisherFactory.create(
self.kv_events_config,
self.parallel_config.data_parallel_rank,
)
self.kv_cache_manager = KVCacheManager(
...
enable_kv_cache_events=self.kv_event_publisher is not None,
...
)
# publish collected KV cache events
if events:
assert self.kv_event_publisher is not None
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markmc Wow, perfect, I completely agree with this revision direction. It has the following benefits:
Scheduler: Avoids redundant checks for whether KV Cache Event is enabled.
self.enable_kv_cache_events = (
self.kv_events_config is not None
and self.kv_events_config.enable_kv_cache_events
)KVCacheManager: The parameterenable_kv_cache_eventsonly stores events in the event queue when anEventPublisherexists, so assigning this parameter based onself.kv_event_publisher is not Noneis reasonable.
I understand that the original author intended to use the Null Object Design Pattern, returning a NullEventPublisher to avoid redundant null-check logic. However, using None directly seems simpler.
|
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: dongbo910220 <[email protected]>
…vllm-project#27262) Signed-off-by: Harry Mellor <[email protected]>
Signed-off-by: JartX <[email protected]>
…ted code (vllm-project#27213) Signed-off-by: Pavani Majety <[email protected]>
…ile (vllm-project#27206) Signed-off-by: Micah Williamson <[email protected]>
Signed-off-by: yewentao256 <[email protected]>
…ct#27196) Signed-off-by: David Whyte-Gray <[email protected]>
Signed-off-by: Nick Hill <[email protected]>
…m-project#27144) Signed-off-by: Tao He <[email protected]> Signed-off-by: Lucas Wilkinson <[email protected]> Co-authored-by: Lucas Wilkinson <[email protected]>
Co-authored-by: Luka Govedič <[email protected]>
…_experts" inside FusedMoE (vllm-project#26440) Signed-off-by: Alexander Matveev <[email protected]>
…roject#27253) Signed-off-by: CNE Pierre FICHEPOIL <[email protected]> Signed-off-by: ExtReMLapin <[email protected]> Co-authored-by: CNE Pierre FICHEPOIL <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…oject#26821) Signed-off-by: Benjamin Chislett <[email protected]>
Signed-off-by: Tyler Michael Smith <[email protected]> Signed-off-by: Tyler Michael Smith <[email protected]>
Signed-off-by: Siyuan Fu <[email protected]> Signed-off-by: Daniel Campora <[email protected]> Signed-off-by: Lain <[email protected]> Co-authored-by: Daniel Campora <[email protected]>
Signed-off-by: vllmellm <[email protected]>
Signed-off-by: NickLucche <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
…nabled (vllm-project#27146) Signed-off-by: zjy0516 <[email protected]>
Signed-off-by: wangxiyuan <[email protected]>
Signed-off-by: Huy Do <[email protected]>
…m-project#27260) Signed-off-by: Harry Mellor <[email protected]>
…4108) Signed-off-by: CNE Pierre FICHEPOIL <[email protected]> Signed-off-by: ExtReMLapin <[email protected]> Co-authored-by: CNE Pierre FICHEPOIL <[email protected]> Co-authored-by: Chauncey <[email protected]>
|
Documentation preview: https://vllm--27257.org.readthedocs.build/en/27257/ |
|
Looks like a bad merge has occurred and everyone has been notified. I think this issue should be already fixed by #26915. Please make a PR if I am wrong. |
Purpose
Fixed a logic flaw in the
EventPublisherFactory.create()method to ensure it properly returnsNullEventPublisherwhenenable_kv_cache_events=Falseorpublisher="null".Changes
EventPublisherFactory.create()methodNullEventPublisher()to avoid calling the constructor.Otherwise, the code will attempt to retrieve the constructor of
NullEventPublisherfrom the registry and call it with parameters. However,NullEventPublisherdoes not accept these parameters, resulting in aTypeError.Test Plan
Test Result
Pass
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.