Spaces:
Running
on
A100
Running
on
A100
MekkCyber
commited on
Commit
·
1e73d78
1
Parent(s):
d3bbedc
testing gpu
Browse files
app.py
CHANGED
|
@@ -63,10 +63,11 @@ def quantize_model(model_name, quantization_type, group_size=128, auth_token=Non
|
|
| 63 |
print(f"Quantizing model: {quantization_type}")
|
| 64 |
if quantization_type == "int4_weight_only" :
|
| 65 |
quantization_config = TorchAoConfig(quantization_type, group_size=group_size)
|
|
|
|
| 66 |
else :
|
| 67 |
quantization_config = TorchAoConfig(quantization_type)
|
| 68 |
-
|
| 69 |
-
|
| 70 |
return model
|
| 71 |
|
| 72 |
def save_model(model, model_name, quantization_type, group_size=128, username=None, auth_token=None, quantized_model_name=None):
|
|
@@ -111,7 +112,7 @@ def quantize_and_save(profile: gr.OAuthProfile | None, oauth_token: gr.OAuthToke
|
|
| 111 |
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
| 112 |
gr.Markdown(
|
| 113 |
"""
|
| 114 |
-
# 🚀 Model Quantization App
|
| 115 |
|
| 116 |
Quantize your favorite Hugging Face models and save them to your profile!
|
| 117 |
"""
|
|
|
|
| 63 |
print(f"Quantizing model: {quantization_type}")
|
| 64 |
if quantization_type == "int4_weight_only" :
|
| 65 |
quantization_config = TorchAoConfig(quantization_type, group_size=group_size)
|
| 66 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="cuda", torch_dtype=torch.bfloat16, quantization_config=quantization_config, use_auth_token=auth_token.token)
|
| 67 |
else :
|
| 68 |
quantization_config = TorchAoConfig(quantization_type)
|
| 69 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="cpu", torch_dtype=torch.bfloat16, quantization_config=quantization_config, use_auth_token=auth_token.token)
|
| 70 |
+
|
| 71 |
return model
|
| 72 |
|
| 73 |
def save_model(model, model_name, quantization_type, group_size=128, username=None, auth_token=None, quantized_model_name=None):
|
|
|
|
| 112 |
with gr.Blocks(theme=gr.themes.Soft()) as app:
|
| 113 |
gr.Markdown(
|
| 114 |
"""
|
| 115 |
+
# 🚀 Model Quantization App :hugging-torch:
|
| 116 |
|
| 117 |
Quantize your favorite Hugging Face models and save them to your profile!
|
| 118 |
"""
|