llmcompressor.core.session_functions
LifecycleCallbacks
A class for invoking lifecycle events for the active session
Source code in src/llmcompressor/core/session_functions.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
batch_end(**kwargs)
classmethod
Invoke a batch end event for the active session
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs | additional kwargs to pass to the current session's event method | {} |
Returns:
Type | Description |
---|---|
ModifiedState | the modified state of the active session after invoking the event |
Source code in src/llmcompressor/core/session_functions.py
batch_start(batch_data=None, **kwargs)
classmethod
Invoke a batch start event for the active session
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch_data | Optional[Any] | the batch data to use for the event | None |
kwargs | additional kwargs to pass to the current session's event method | {} |
Returns:
Type | Description |
---|---|
ModifiedState | the modified state of the active session after invoking the event |
Source code in src/llmcompressor/core/session_functions.py
calibration_epoch_end(**kwargs)
classmethod
Invoke a epoch end event for the active session during calibration. This event should be called after the model has been calibrated for one epoch
see src/llmcompressor/pipelines/basic/pipeline.py
for usage example
Source code in src/llmcompressor/core/session_functions.py
calibration_epoch_start(**kwargs)
classmethod
Invoke a epoch start event for the active session during calibration. This event should be called before calibration starts for one epoch
see src/llmcompressor/pipelines/basic/pipeline.py
for usage example
Source code in src/llmcompressor/core/session_functions.py
event(event_type, **kwargs)
classmethod
Invoke an event for the active session
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_type | EventType | the event type to invoke | required |
kwargs | additional kwargs to pass to the current session's event method | {} |
Returns:
Type | Description |
---|---|
ModifiedState | the modified state of the active session after invoking the event |
Source code in src/llmcompressor/core/session_functions.py
loss_calculated(loss=None, **kwargs)
classmethod
Invoke a loss calculated event for the active session
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loss | Optional[Any] | the loss to use for the event | None |
kwargs | additional kwargs to pass to the current session's event method | {} |
Returns:
Type | Description |
---|---|
ModifiedState | the modified state of the active session after invoking the event |
Source code in src/llmcompressor/core/session_functions.py
optim_post_step(**kwargs)
classmethod
Invoke an optimizer post-step event for the active session
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs | additional kwargs to pass to the current session's event method | {} |
Returns:
Type | Description |
---|---|
ModifiedState | the modified state of the active session after invoking the event |
Source code in src/llmcompressor/core/session_functions.py
optim_pre_step(**kwargs)
classmethod
Invoke an optimizer pre-step event for the active session
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs | additional kwargs to pass to the current session's event method | {} |
Returns:
Type | Description |
---|---|
ModifiedState | the modified state of the active session after invoking the event |
Source code in src/llmcompressor/core/session_functions.py
sequential_epoch_end(**kwargs)
classmethod
Invoke a sequential epoch end event for the active session. This event should be called after one sequential layer has been calibrated/trained for one epoch
This is called after a sequential layer has been calibrated with one batch, see src/llmcompressor/pipelines/sequential/pipeline.py
for usage example
Source code in src/llmcompressor/core/session_functions.py
active_session()
Returns:
Type | Description |
---|---|
CompressionSession | the active session for sparsification |
create_session()
Context manager to create and yield a new session for sparsification. This will set the active session to the new session for the duration of the context.
Returns:
Type | Description |
---|---|
Generator[CompressionSession, None, None] | the new session |