Skip to content

PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度

fix cuda UT torch_dtype (#423)

WeiweiZhang1db8088b2ae5a
diff --git a/test_cuda/test_support_vlms.py b/test_cuda/test_support_vlms.py
index a2627df3c..b84836a80 100644
--- a/test_cuda/test_support_vlms.py
+++ b/test_cuda/test_support_vlms.py
@@ -35,7 +35,7 @@ class TestSupportVLMS(unittest.TestCase):
from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
model = Qwen2VLForConditionalGeneration.from_pretrained(
quantized_model_path,
- torch_dtype="auto",
+ torch_dtype="float16",
device_map=f"cuda:{self.device}",
)
processor = AutoProcessor.from_pretrained(quantized_model_path)
@@ -92,7 +92,7 @@ class TestSupportVLMS(unittest.TestCase):
quantized_model_path,
device_map=f"cuda:{self.device}",
trust_remote_code=True,
- torch_dtype="auto"
+ torch_dtype="float16",
)
processor = AutoProcessor.from_pretrained(quantized_model_path,
trust_remote_code=True,
@@ -244,7 +244,7 @@ class TestSupportVLMS(unittest.TestCase):
quantized_model_path = os.path.join(self.save_dir, "Llama-3.2-11B-Vision-Instruct-w4g128-auto_round")
model = MllamaForConditionalGeneration.from_pretrained(
quantized_model_path,
- torch_dtype="auto",
+ torch_dtype="float16",
device_map=f"cuda:{self.device}",
)
processor = AutoProcessor.from_pretrained(quantized_model_path)
@@ -288,7 +288,7 @@ class TestSupportVLMS(unittest.TestCase):
)
model = AutoModelForCausalLM.from_pretrained(
quantized_model_path,
- torch_dtype="auto",
+ torch_dtype="float16",
trust_remote_code=True,
device_map=DEVICE,
).to(DEVICE).eval()
@@ -352,7 +352,7 @@ class TestSupportVLMS(unittest.TestCase):
quantized_model_path,
trust_remote_code=True,
device_map=f"cuda:{self.device}",
- torch_dtype="auto",
+ torch_dtype="float16",
)
vl_gpt = vl_gpt.eval()
@@ -399,3 +399,4 @@ class TestSupportVLMS(unittest.TestCase):
if __name__ == "__main__":
unittest.main()
+
diff --git a/test_cuda/test_vlms.py b/test_cuda/test_vlms.py
index b40322da5..ab0438e0d 100644
--- a/test_cuda/test_vlms.py
+++ b/test_cuda/test_vlms.py
@@ -46,7 +46,7 @@ class TestAutoRound(unittest.TestCase):
processor = AutoProcessor.from_pretrained(quantized_model_dir, trust_remote_code=True)
model = Qwen2VLForConditionalGeneration.from_pretrained(
quantized_model_dir,
- torch_dtype="auto",
+ torch_dtype="float16",
device_map="auto",
##revision="df7f44c" ##AutoGPTQ format
)
@@ -94,7 +94,7 @@ class TestAutoRound(unittest.TestCase):
## load the model
model_name = "/models/Qwen2-VL-2B-Instruct"
model = Qwen2VLForConditionalGeneration.from_pretrained(
- model_name, trust_remote_code=True)
+ model_name, trust_remote_code=True, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_name)
processor = AutoProcessor.from_pretrained(model_name, trust_remote_code=True)
@@ -120,7 +120,7 @@ class TestAutoRound(unittest.TestCase):
quantized_model_path,
device_map="auto",
trust_remote_code=True,
- torch_dtype="auto"
+ torch_dtype="float16",
)
processor = AutoProcessor.from_pretrained(quantized_model_path,
trust_remote_code=True,
@@ -198,3 +198,4 @@ class TestAutoRound(unittest.TestCase):
if __name__ == "__main__":
unittest.main()
+