-
Notifications
You must be signed in to change notification settings - Fork 114
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
[Performance] Sequential onloading #1263
base: main
Are you sure you want to change the base?
Conversation
👋 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. |
src/llmcompressor/utils/helpers.py
Outdated
|
||
|
||
@contextlib.contextmanager | ||
def align_modules(modules: Iterable[torch.nn.Module]): |
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.
Why not keep this in compressed tensors with the other cpu offloading tools?
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! Implementing here before the next CT release
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.
# and is only used for capturing outputs from the newly compressed modules | ||
with HooksMixin.disable_hooks(): | ||
for batch_index in tqdm.tqdm(range(len(dataloader)), desc=prop_desc): | ||
with align_modules([layer]): |
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.
Seems like all we're doing is wrapping the forward passes in this context manager, if I'm reading this correctly?
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.
Yes. Rather than onloading then discarding for each of the 512 forward passes, we onload once for the layer and keep it onloaded through compression and propagation.
@@ -310,11 +313,13 @@ def partition_graph(model: Module, partitions: List[List[Node]]) -> List[Subgrap | |||
# save the subgraph for this partition | |||
graph.lint() | |||
input_names = set(node.name for node in graph.nodes if node.op == "placeholder") | |||
modules = get_subgraph_modules(graph, parent_graph) |
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.
Do you mind explaining what we're changing in our graph partition here?
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.
The graph partition doesn't change, this change just collects all the modules used by this subgraph for use in onloading/offloading by the sequential pipeline.
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.
sorry, i approved this thinking it was the one-liner removing clear-ml, will have to take a closer look
sorry, i approved this thinking it was the one-liner removing clear-ml, will have to take a closer look
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.
I am understanding this for the most part -- very cool!
SUMMARY: - Remove requirement for tokens and the one test which uses them Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
Co-authored-by: Brian Dellabetta <[email protected]> Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
cf09876
to
72e7683
Compare
Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
Signed-off-by: Kyle Sayers <[email protected]>
Purpose
oneshot_device
.Usage
When using the sequential pipeline, a few behaviors change
oneshot_device
argument is used to determine the onload device (this defaults to cuda if a cuda device is available)This policy encourages users to dispatch to the CPU when using the sequential pipeline, and to dispatch to "auto" when using the basic pipeline
Changes
Testing