Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,9 @@ from huggingface_hub import snapshot_download
|
|
| 3 |
from accelerate.utils import BnbQuantizationConfig
|
| 4 |
from accelerate.utils import load_and_quantize_model
|
| 5 |
from accelerate import Accelerator
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
model_path="marcsun13/gpt2-xl-linear-sharded"
|
| 8 |
|
|
@@ -13,6 +16,15 @@ def quantize(model_path=model_path):
|
|
| 13 |
bnb_quantization_config = BnbQuantizationConfig(load_in_8bit=True, llm_int8_threshold = 6)
|
| 14 |
#bnb_quantization_config = BnbQuantizationConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16, bnb_4bit_use_double_quant=True, bnb_4bit_quant_type="nf4")
|
| 15 |
print("3")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
quantized_model = load_and_quantize_model(empty_model, weights_location=weights_location, bnb_quantization_config=bnb_quantization_config, device_map = "auto")
|
| 17 |
print("4")
|
| 18 |
accelerate = Accelerator()
|
|
|
|
| 3 |
from accelerate.utils import BnbQuantizationConfig
|
| 4 |
from accelerate.utils import load_and_quantize_model
|
| 5 |
from accelerate import Accelerator
|
| 6 |
+
from accelerate import init_empty_weights
|
| 7 |
+
#from mingpt.model import GPT
|
| 8 |
+
|
| 9 |
|
| 10 |
model_path="marcsun13/gpt2-xl-linear-sharded"
|
| 11 |
|
|
|
|
| 16 |
bnb_quantization_config = BnbQuantizationConfig(load_in_8bit=True, llm_int8_threshold = 6)
|
| 17 |
#bnb_quantization_config = BnbQuantizationConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16, bnb_4bit_use_double_quant=True, bnb_4bit_quant_type="nf4")
|
| 18 |
print("3")
|
| 19 |
+
#model_config = GPT.get_default_config()
|
| 20 |
+
#model_config.model_type = 'gpt2-xl'
|
| 21 |
+
#model_config.vocab_size = 50257
|
| 22 |
+
#model_config.block_size = 1024
|
| 23 |
+
print(weights_location)
|
| 24 |
+
print(weights_location.config)
|
| 25 |
+
with init_empty_weights():
|
| 26 |
+
|
| 27 |
+
empty_model = weights_location(model_config)
|
| 28 |
quantized_model = load_and_quantize_model(empty_model, weights_location=weights_location, bnb_quantization_config=bnb_quantization_config, device_map = "auto")
|
| 29 |
print("4")
|
| 30 |
accelerate = Accelerator()
|