Skip to content
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

[Bugfix] Fix saving offloaded state dict #172

Merged
merged 19 commits into from
Oct 4, 2024
Merged

Conversation

kylesayrs
Copy link
Collaborator

@kylesayrs kylesayrs commented Sep 12, 2024

Purpose

  • Fix bug with saving the entire state dict of an offloaded model, even if it does not have a compressor
  • Properly infer sparsity and quantization of offloaded models

Changes

  • Load the entire offloaded state dict before checking for a compressor and before inferring global sparsity
  • Remove explicit override of save_safetensors kwarg, since the original save_pretrained function already defaults its value to True

Testing

  • Added test which throws error when trying to save an offloaded model without compression. This test fails on main but passes on this branch

Main

FAILED tests/llmcompressor/transformers/sparsification/test_compress_tensor_utils.py::test_model_reload[True-torch_dtype3-False-cpu] - NotImplementedError: Cannot copy out of meta tensor; no data!
FAILED tests/llmcompressor/transformers/sparsification/test_compress_tensor_utils.py::test_model_reload[True-torch_dtype5-False-cuda:0] - NotImplementedError: Cannot copy out of meta tensor; no data!
FAILED tests/llmcompressor/transformers/sparsification/test_compress_tensor_utils.py::test_model_reload[True-torch_dtype6-True-cuda:0] - NotImplementedError: Cannot copy out of meta tensor; no data!
FAILED tests/llmcompressor/transformers/sparsification/test_compress_tensor_utils.py::test_model_reload[True-torch_dtype7-True-cuda:0] - NotImplementedError: Cannot copy out of meta tensor; no data!
======================================= 4 failed, 4 passed, 12 deselected in 9.03s =======================================

This branch

============================================ 8 passed, 12 deselected in 8.89s ============================================

Copy link

👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review.

rahul-tuli
rahul-tuli previously approved these changes Sep 12, 2024
@kylesayrs kylesayrs marked this pull request as draft September 13, 2024 21:42
@kylesayrs
Copy link
Collaborator Author

I'm pretty sure this should be merged, but I want to fully test checkpoint loading before this is merged in

@kylesayrs kylesayrs changed the title Fix saving offloaded state dict [bugfix] Fix saving offloaded state dict Sep 24, 2024
@kylesayrs kylesayrs changed the title [bugfix] Fix saving offloaded state dict [Bugfix] Fix saving offloaded state dict Sep 24, 2024
@kylesayrs kylesayrs self-assigned this Sep 24, 2024
@kylesayrs kylesayrs marked this pull request as ready for review September 25, 2024 18:54
horheynm
horheynm previously approved these changes Sep 26, 2024
dsikka
dsikka previously approved these changes Sep 27, 2024
Copy link
Collaborator

@dsikka dsikka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just one confirmation question

@kylesayrs kylesayrs dismissed stale reviews from dsikka and horheynm via 00791b6 September 27, 2024 21:13
@dsikka
Copy link
Collaborator

dsikka commented Sep 30, 2024

@kylesayrs can you resolve the conflict

@dsikka
Copy link
Collaborator

dsikka commented Oct 1, 2024

@kylesayrs Seems like some of the errors for the sparsification tests are new?

@kylesayrs
Copy link
Collaborator Author

kylesayrs commented Oct 1, 2024

I addressed the cuda errors by separating out GPU-dependent tests
There are other, new failures which are likely caused by upstream CT changes, but they are unrelated and outside of the scope of this PR, which only aims to address the newly added tests test_model_reload and to precursor other test fixes

Copy link
Collaborator

@rahul-tuli rahul-tuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgoin mgoin merged commit 91eed2f into main Oct 4, 2024
6 of 7 checks passed
@mgoin mgoin deleted the kylesayrs/fix-offloaded-saving branch October 4, 2024 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants