Skip to content

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

import gptqmodel in confest to avoid error in transformers (#1668)

Xin He106a32239319
diff --git a/test/conftest.py b/test/conftest.py
index f3761d66b..060b7e9a1 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -23,6 +23,18 @@ except ImportError:
pass
+try:
+ import torch
+
+ # When loaded via the "meta" device, `gptqmodel==6.0.3` raises an error because the
+ # internal loading process within the `transformers` library defaults to "meta" mode.
+ # Importing under a CPU device context avoids that failure during module loading.
+ with torch.device("cpu"):
+ import gptqmodel # pylint: disable=E0401
+except ImportError:
+ pass
+
+
### HPU related configuration, usage: `pytest --mode=compile/lazy``
def pytest_addoption(parser):
parser.addoption(