-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance woq model loading & support hf woq model loading
Signed-off-by: yuwenzho <yuwen.zhou@intel.com>
- Loading branch information
Showing
8 changed files
with
529 additions
and
31 deletions.
There are no files selected for viewing
476 changes: 469 additions & 7 deletions
476
neural_compressor/torch/algorithms/weight_only/save_load.py
Large diffs are not rendered by default.
Oops, something went wrong.
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
17 changes: 17 additions & 0 deletions
17
test/3x/torch/quantization/weight_only/test_load_woq_hf_model.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,17 @@ | ||
import torch | ||
from transformers import AutoTokenizer | ||
from neural_compressor.torch.utils import accelerator | ||
|
||
device = accelerator.current_device_name() | ||
|
||
class TestHFModelLoad: | ||
def setup_class(self): | ||
self.model_name = "TheBloke/TinyLlama-1.1B-python-v0.1-GPTQ" | ||
self.example_inputs = torch.tensor([[10, 20, 30, 40, 50, 60]], dtype=torch.long).to(device) | ||
|
||
def test_load_hf_woq_model(self): | ||
from neural_compressor.torch.quantization import load | ||
|
||
qmodel = load(self.model_name, format="huggingface") | ||
output = qmodel(self.example_inputs)[0] | ||
assert len(output) > 0, "Not loading the model correctly" |
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