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

Check for 2:4 structure when saving SparseAutoModel #2317

Merged
merged 3 commits into from
Jun 5, 2024

Conversation

dbogunowicz
Copy link
Contributor

@dbogunowicz dbogunowicz commented Jun 5, 2024

Feature request: explicitly check whether the SparseAutoModel saved with save_pretrained has 2:4 sparsity structure.

Example:

from sparseml.transformers import SparseAutoModelForCausalLM

model_path = "/network/eldar/models_to_share/llama2_7b_sp24_v1"
model = SparseAutoModelForCausalLM.from_pretrained(model_path, torch_dtype="auto")
model.save_pretrained("./some_funny_test")
Loading checkpoint shards: 100%|█████████████████████████████| 3/3 [00:03<00:00,  1.18s/it]
2024-06-05 13:11:10 sparseml.transformers.sparsification.compressed_tensors_utils INFO     Inferring a sparsity configuration requires a global sparsity calculation. This can be costly for large models. To skip the calculation of compression statistics set skip_compression_stats=True
Calculating model sparsity: 100%|████████████████████████| 291/291 [00:12<00:00, 23.31it/s]
Checking whether model follows 2:4 sparsity structure: 100%|| 225/225 [00:20<00:00, 10.88it/s]
cat some_funny_test/config.json 

...
"compression_config": {
    "sparsity_config": {
      "format": "dense",
      "global_sparsity": 48.05290754567787,
      "registry_requires_subclass": false,
      "sparsity_structure": "2:4"
    }
  },
...

@dbogunowicz dbogunowicz changed the title Update sparsity_config.py Check for 2:4 structure when saving SparseAutoModel Jun 5, 2024
Copy link

@Satrat Satrat left a comment

Choose a reason for hiding this comment

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

Nice work!

@dbogunowicz dbogunowicz merged commit 38a1214 into main Jun 5, 2024
17 checks passed
@dbogunowicz dbogunowicz deleted the dbogunowicz-patch-2 branch June 5, 2024 14: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.

3 participants