Skip to content

Commit 606b93b

Browse files
committed
remove session function
Signed-off-by: Kyle Sayers <[email protected]>
1 parent 574ae57 commit 606b93b

File tree

5 files changed

+2
-32
lines changed

5 files changed

+2
-32
lines changed

src/llmcompressor/core/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
finalize,
1717
initialize,
1818
reset_session,
19-
update_state,
2019
)
2120
from llmcompressor.core.state import Data, Hardware, ModifiedState, State
2221

@@ -37,7 +36,6 @@
3736
"active_session",
3837
"reset_session",
3938
"initialize",
40-
"update_state",
4139
"finalize",
4240
"apply",
4341
"callbacks",

src/llmcompressor/core/lifecycle.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ def initialize(
8484
:return: List of data returned from initialization of modifiers
8585
:rtype: List[Any]
8686
"""
87-
self.state.update(**kwargs)
8887
if self.initialized_:
8988
raise ValueError(
9089
"Initialize was called twice. To update state values after "
9190
"initialization, please use "
9291
"`llmcompressor.core.session_functions.update_state`"
9392
)
9493

94+
self.state.update(**kwargs)
9595
logger.debug("Initializing compression lifecycle")
9696
self.recipe_container.append(recipe, recipe_stage, recipe_args)
9797
self.modifiers = self.recipe_container.get_modifiers()
@@ -111,13 +111,6 @@ def initialize(
111111

112112
return mod_data
113113

114-
def update_state(self, **kwargs):
115-
"""
116-
Update the lifecycle state with new values
117-
"""
118-
logger.info(f"Updated state with {kwargs}")
119-
self.state.update(**kwargs)
120-
121114
def finalize(self, **kwargs) -> List[Any]:
122115
"""
123116
Finalize the compression lifecycle.

src/llmcompressor/core/session.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,6 @@ def initialize(
143143
modifier_data=mod_data,
144144
)
145145

146-
def update_state(self, **kwargs) -> ModifiedState:
147-
"""
148-
Update the lifecycle state with new values
149-
"""
150-
self._lifecycle.update_state(**kwargs)
151-
152-
return ModifiedState(
153-
model=self.state.model,
154-
optimizer=self.state.optimizer,
155-
loss=self.state.loss,
156-
)
157-
158146
def finalize(self, **kwargs) -> ModifiedState:
159147
"""
160148
Finalize the session for compression. This will run the finalize method

src/llmcompressor/core/session_functions.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"active_session",
1313
"reset_session",
1414
"initialize",
15-
"update_state",
1615
"finalize",
1716
"callbacks",
1817
"LifecycleCallbacks",
@@ -122,13 +121,6 @@ def initialize(
122121
)
123122

124123

125-
def update_state(**kwargs) -> ModifiedState:
126-
"""
127-
Update the session state with new values
128-
"""
129-
return active_session().update_state(**kwargs)
130-
131-
132124
def finalize(**kwargs) -> ModifiedState:
133125
"""
134126
Method to finalize the active session for sparsification

src/llmcompressor/transformers/finetune/session_mixin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
create_session,
1818
finalize,
1919
initialize,
20-
update_state,
2120
)
2221
from llmcompressor.metrics import LoggerManager
2322
from llmcompressor.modifiers.distillation.utils.pytorch.model_wrapper import (
@@ -223,7 +222,7 @@ def create_optimizer(self):
223222
len(self.train_dataset) / total_batch_size
224223
)
225224

226-
update_state(
225+
active_session().state.update(
227226
optimizer=self.optimizer, steps_per_epoch=self.total_steps_per_epoch
228227
)
229228

0 commit comments

Comments
 (0)