Skip to content

Commit 82b4bd2

Browse files
authored
[Callbacks] Remove EventLifecycle and on_start event (#1170)
## Purpose ## * Simplify code related to callbacks * Remove event lifecycle * Callback event lifecycle * Optimizer event lifecycle * Remove the concept of a "start_event", which was originally used because initialization sometimes requires triggering on_start, and on_start requires an event in order to get an index and index-related info * For now, we create a dummy event on initialization which has an index of zero * In the future, all start events will be triggered by events (never initialize) and all event events will be triggered by events or finalization ## Prerequisites ## * #1160 ## Changes ## * Instead of using event lifecycle as a proxy, pass events to modifiers directly ```python3 - self._check_setup_event_lifecycle(event_type) + event = Event(event_type=event_type) - for event in self.event_lifecycle.events_from_type(event_type): + for mod in self.modifiers: data = mod.update_event(state=self.state, event=event, **kwargs) ``` * This was originally needed for optimizer event lifecycle, that is now removed * Make silent noops into errors ```python3 if not self.initialized_: - return + raise RuntimeError("Cannot update an uninitialized modifier") ``` * Remove `check_initialized`, which was used to allow for checking in situations which required double initialization Signed-off-by: Kyle Sayers <[email protected]>
1 parent 0bb5076 commit 82b4bd2

File tree

21 files changed

+84
-1441
lines changed

21 files changed

+84
-1441
lines changed

src/llmcompressor/core/__init__.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
from llmcompressor.core.events import (
2-
CallbacksEventLifecycle,
3-
Event,
4-
EventLifecycle,
5-
EventType,
6-
OptimizerEventLifecycle,
7-
)
1+
from llmcompressor.core.events import Event, EventType
82
from llmcompressor.core.lifecycle import CompressionLifecycle
93
from llmcompressor.core.model_layer import ModelParameterizedLayer
104
from llmcompressor.core.session import CompressionSession
@@ -20,9 +14,6 @@
2014
__all__ = [
2115
"Event",
2216
"EventType",
23-
"EventLifecycle",
24-
"CallbacksEventLifecycle",
25-
"OptimizerEventLifecycle",
2617
"State",
2718
"Data",
2819
"Hardware",

src/llmcompressor/core/events/__init__.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,5 @@
88
"""
99

1010
from .event import Event, EventType
11-
from .event_lifecycle import EventLifecycle
12-
from .lifecycle_callbacks import CallbacksEventLifecycle
13-
from .lifecycle_optimizer import OptimizerEventLifecycle
1411

15-
__all__ = [
16-
"Event",
17-
"EventType",
18-
"EventLifecycle",
19-
"CallbacksEventLifecycle",
20-
"OptimizerEventLifecycle",
21-
]
12+
__all__ = ["Event", "EventType"]

src/llmcompressor/core/events/event_lifecycle.py

Lines changed: 0 additions & 171 deletions
This file was deleted.

0 commit comments

Comments
 (0)