[Callbacks] Remove pre_initialize_structure#1160
Merged
Conversation
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
|
👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review. Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed. |
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
…initialize-structure
dsikka
added a commit
that referenced
this pull request
Feb 25, 2025
## Purpose ## * Simplify all methods of saving into one point, namely the wrapped `save_pretrained` function * Precursor to #1160 * Needed for having a single point for saving on top of existing recipes ## Background ## All the things needed to be done during saving 1. Save the model weights, potentially compressed 2. Save the processor 3. Update the recipe checkpoint 4. Copy any necessary python files from the model cache 5. Only save on the main process After these changes, (1, 2, 3, 4) will be done within the `save_pretrained` function, and (5) will be the responsibility of the caller. (3) will be implemented by #1160 so as not to conflict with existing logic in pre_init All of the places where a model is saved are * If an output dir is specified, at the end of the main function * Between stages of the stage runner * Between epochs of the HF Trainer * By the user after oneshot/training completes After these changes, all of these will be replaced by a single `save_checkpoint` function which calls `save_pretrained` to do all the necessary things ## Changes ## * Remove `save_model_and_recipe` * Saving recipes is now done by `save_pretrained` function * Implement `save_checkpoint` * Single entrypoint for saving a model and its processor * Performs actions (1, 2, 4) * Replace all locations where a model is saved with `save_checkpoint` * All applicable callers with only saving on the main process (5) * Remove support for `modify_fsdp_model_save_pretrained` and `unwrap_and_export_model`, to be added back in a future release --------- Signed-off-by: Kyle Sayers <kylesayrs@gmail.com> Co-authored-by: Dipika Sikka <dipikasikka1@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
brian-dellabetta
previously approved these changes
Feb 25, 2025
Collaborator
brian-dellabetta
left a comment
There was a problem hiding this comment.
looking good, but i'm going off an assumption that none of this deleted code we actually need
Collaborator
Author
|
@brian-dellabetta The PR description lists all of the functionality that was needed by preinitialize and where that functionality now lives |
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
horheynm
approved these changes
Feb 26, 2025
dsikka
approved these changes
Feb 26, 2025
src/llmcompressor/transformers/sparsification/compressed_tensors_utils.py
Show resolved
Hide resolved
brian-dellabetta
approved these changes
Feb 26, 2025
kylesayrs
added a commit
that referenced
this pull request
Mar 11, 2025
## Purpose ## * Fix staged 2of4 example ## Background ## * When #1160 landed, this change introduced a bug in the recipe container which meant that the recipe was not recompiled after `append`ing. This caused sgpt to initialize twice and gptq to never initialize, leading to a sparsity-only quantization config * At some point, a changed was introduced which causes previous stages to become reconstructed after recipe recompilation. This means that without resetting the session in between stages, previous stages will initialize twice. * In order to avoid this issue, this PR introduces `session.reset()` in between stages * This change has the consequence of creating `recipe.yaml` files which do not have the full recipe history. However, I believe this is acceptable for the time being, as the stage runner and this work flow will be removed in the next release. --------- Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
kylesayrs
added a commit
that referenced
this pull request
Mar 15, 2025
## 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 <kylesayrs@gmail.com>
kylesayrs
added a commit
that referenced
this pull request
Apr 16, 2025
## Purpose ## * Code documentation ## Prerequisites ## * #1160 --------- Signed-off-by: Kyle Sayers <kylesayrs@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Prerequisites
Follow-ups
Changes
The preinitialization step used to fulfill a few purposes
initializeinitializeis called. In these cases, we can pass the model directlyProvide a way for modifiers to influence the model after they have already been applied
Create quantization modifier on GPTQ
on_initializefunctionRemove
EventType.order()method which is unusedExtend the
Recipe.simplify_recipeclass method to support stringsLifecycle
create_session()(doesn't do much and can be hidden behindinitialize)initialize(model=..., recipe=...)startmodifiersLifecycleCallback.event(...)start/endmodifiersfinalize()Regression Evaluation
Main
This branch