-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SparseML Compression Pt 3: SparseAutoModel interface & inferring para…
…ms (#2190) * initial classes * WIP * compression working * unit tests and README * docstrings * README and fix test * add bitmask source * initial commit * compression working * formatting * cleanup * dtype tests * oops fix test * tests * add bfloat16 * unit tests * docstrings * update README * initial commit * messy but working * move statements to debug * warn on conflicts, store device * merge conflict * fix typing * helper fn for setting layers * expand cuda memory helper * update example and tests * update docstrings * use iterator * unit tests and cleanup * docstrings and tests * remove unneeded file * Update src/sparseml/pytorch/model_load/helpers.py Co-authored-by: dbogunowicz <[email protected]> * Update README.md * move constant * PR comments * Pr comments: helper fns * slight refactor save_dense to save_compressed * update tests for dtype checks * fix conflict * Compression UI Changes + One-shot/Finetune Support (#2194) * working implementation * remove unneeded file * update README * clean up and docstrings * finetuning and one-shot interface * update README * update save * update README * logs for sparsity calculations * logger change * remove save_compressed * log for quantized models --------- Co-authored-by: dbogunowicz <[email protected]>
- Loading branch information
1 parent
b2cbece
commit 85b0e72
Showing
22 changed files
with
629 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
32 changes: 32 additions & 0 deletions
32
src/sparseml/transformers/compression/compressors/dense.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from typing import Dict, Generator, Tuple | ||
|
||
from torch import Tensor | ||
|
||
from sparseml.transformers.compression.compressors import ModelCompressor | ||
|
||
|
||
@ModelCompressor.register(name="dense_sparsity") | ||
class DenseCompressor(ModelCompressor): | ||
""" | ||
Identity compressor for dense models, returns the original state_dict | ||
""" | ||
|
||
def compress(self, model_state: Dict[str, Tensor]) -> Dict[str, Tensor]: | ||
return model_state | ||
|
||
def decompress(self, model_path: str) -> Generator[Tuple[str, Tensor], None, None]: | ||
return iter([]) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,6 @@ | |
|
||
# flake8: noqa | ||
|
||
from .compress_save import * | ||
from .helpers import * | ||
from .safetensors_load import * |
Oops, something went wrong.