PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度
fix test_evaluation and AutoTuner new issue (#1417)
Xin He520214a8edda
diff --git a/auto_round_extension/triton/__init__.py b/auto_round_extension/triton/__init__.pyindex 0d2740cdb..d932ae6b2 100644--- a/auto_round_extension/triton/__init__.py+++ b/auto_round_extension/triton/__init__.py@@ -11,3 +11,24 @@# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.+++def patch_triton_autotuner_if_needed():+ """Patch Autotuner if it's missing _cache_lock (compatibility fix for older triton versions)."""+ try:+ import threading+ from triton.runtime.autotuner import Autotuner++ if not hasattr(Autotuner, "_cache_lock"):+ Autotuner._cache_lock = threading.RLock()+ if not hasattr(Autotuner, "_cache_futures"):+ Autotuner._cache_futures = {}+ if not hasattr(Autotuner, "_cache"):+ Autotuner._cache = {}+ if not hasattr(Autotuner, "cache"):+ Autotuner.cache = {}+ except (ImportError, AttributeError):+ pass+++patch_triton_autotuner_if_needed()diff --git a/auto_round_extension/triton/triton_utils/dequant.py b/auto_round_extension/triton/triton_utils/dequant.pyindex d599289db..e1564daa3 100644--- a/auto_round_extension/triton/triton_utils/dequant.py+++ b/auto_round_extension/triton/triton_utils/dequant.py@@ -50,18 +50,6 @@ def make_dequant_configs(block_sizes, num_warps):DEFAULT_DEQUANT_CONFIGS = make_dequant_configs([128, 256, 512, 1024], [4, 8])-# Patch Autotuner if it's missing _cache_lock (compatibility fix for older triton versions)-try:- from triton.runtime.autotuner import Autotuner-- if not hasattr(Autotuner, "_cache_lock"):- # Add missing attributes to make autotune work- Autotuner._cache_lock = threading.RLock()- if not hasattr(Autotuner, "cache"):- Autotuner.cache = {}-except (ImportError, AttributeError):- pass-@triton.autotune(DEFAULT_DEQUANT_CONFIGS, key=["numels"])@triton.jitdiff --git a/auto_round_extension/triton/triton_utils_zp/dequant.py b/auto_round_extension/triton/triton_utils_zp/dequant.pyindex 288d27ea8..b4de5fb8f 100644--- a/auto_round_extension/triton/triton_utils_zp/dequant.py+++ b/auto_round_extension/triton/triton_utils_zp/dequant.py@@ -50,18 +50,6 @@ def make_dequant_configs(block_sizes, num_warps):DEFAULT_DEQUANT_CONFIGS = make_dequant_configs([128, 256, 512, 1024], [4, 8])-# Patch Autotuner if it's missing _cache_lock (compatibility fix for older triton versions)-try:- from triton.runtime.autotuner import Autotuner-- if not hasattr(Autotuner, "_cache_lock"):- # Add missing attributes to make autotune work- Autotuner._cache_lock = threading.RLock()- if not hasattr(Autotuner, "cache"):- Autotuner.cache = {}-except (ImportError, AttributeError):- pass-@triton.autotune(DEFAULT_DEQUANT_CONFIGS, key=["numels"])@triton.jitdiff --git a/test/test_cuda/advanced/test_evaluation.py b/test/test_cuda/advanced/test_evaluation.pyindex 8f67633ab..16d991cb9 100644--- a/test/test_cuda/advanced/test_evaluation.py+++ b/test/test_cuda/advanced/test_evaluation.py@@ -45,6 +45,7 @@ class TestVllmEvaluation:python_path = sys.executableos.environ["VLLM_SKIP_WARMUP"] = "true"+ os.environ["NCCL_ASYNC_ERROR_HANDLING"] = "1"os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"# Test with custom vllm_args@@ -59,6 +60,7 @@ class TestVllmEvaluation:python_path = sys.executableos.environ["VLLM_SKIP_WARMUP"] = "true"+ os.environ["NCCL_ASYNC_ERROR_HANDLING"] = "1"os.environ["VLLM_WORKER_MULTIPROC_METHOD"] = "spawn"cmd = f"{python_path} -m auto_round --model {opt_name_or_path} --iters 0 --disable_opt_rtn --tasks lambada_openai --eval_bs 8 --eval_backend vllm --limit 100"