@@ -1245,8 +1245,9 @@ def test_export_error(self):
1245
1245
def dummy_dataset_generator (nsamples , seqlen , vocab_size = 1000 ):
1246
1246
"""A generator that yields random numpy arrays for fast,
1247
1247
self-contained tests."""
1248
+ rng = np .random .default_rng (seed = 42 )
1248
1249
for _ in range (nsamples ):
1249
- yield np . random . randint ( 0 , vocab_size , size = (1 , seqlen ))
1250
+ yield rng . integers ( low = 0 , high = vocab_size , size = (1 , seqlen ))
1250
1251
1251
1252
1252
1253
# Helper function to build a simple transformer model that uses standard
@@ -1327,7 +1328,7 @@ def _run_gptq_test_on_dataset(self, dataset, **config_kwargs):
1327
1328
target_layer ,
1328
1329
"Test setup failed: No Dense layer found in 'ffn' block." ,
1329
1330
)
1330
- original_weights = np .copy (target_layer .kernel . numpy () )
1331
+ original_weights = np .copy (target_layer .kernel )
1331
1332
1332
1333
# Configure and run quantization
1333
1334
final_config = {** base_config , ** config_kwargs }
@@ -1336,7 +1337,7 @@ def _run_gptq_test_on_dataset(self, dataset, **config_kwargs):
1336
1337
model .quantize ("gptq" , quant_config = gptq_config )
1337
1338
1338
1339
# Assertions and verification
1339
- quantized_weights = target_layer .kernel . numpy ()
1340
+ quantized_weights = target_layer .kernel
1340
1341
1341
1342
self .assertNotAllClose (
1342
1343
original_weights ,
@@ -1353,7 +1354,7 @@ def test_quantize_gptq_on_different_datasets(self):
1353
1354
"""Tests GPTQ with various dataset types (string list, generator)."""
1354
1355
1355
1356
# Define the datasets to be tested
1356
- long_text = """auto- gptq is an easy-to-use model quantization library
1357
+ long_text = """gptq is an easy-to-use model quantization library
1357
1358
with user-friendly apis, based on GPTQ algorithm. The goal is to
1358
1359
quantize pre-trained models to 4-bit or even 3-bit precision with
1359
1360
minimal performance degradation.
@@ -1374,8 +1375,6 @@ def test_quantize_gptq_on_different_datasets(self):
1374
1375
1375
1376
# Loop through the datasets and run each as a sub-test
1376
1377
for dataset_name , dataset in datasets_to_test .items ():
1377
- # 'with self.subTest(...)' ensures that failures are reported
1378
- # for each specific dataset without stopping the whole test.
1379
1378
with self .subTest (dataset_type = dataset_name ):
1380
1379
self ._run_gptq_test_on_dataset (dataset )
1381
1380
0 commit comments