Fix GPTQ
diff --git a/fastchat/model/compression.py b/fastchat/model/compression.py
index 28ddada222..567f759f9b 100644
--- a/fastchat/model/compression.py
+++ b/fastchat/model/compression.py
@@ -3,12 +3,12 @@
 import glob
 import os
 
-import torch
-import torch.nn as nn
 from accelerate import init_empty_weights
 from accelerate.utils import set_module_tensor_to_device
+import torch
 from torch import Tensor
 from torch.nn import functional as F
+import torch.nn as nn
 from tqdm import tqdm
 from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer
 
diff --git a/fastchat/modules/gptq.py b/fastchat/modules/gptq.py
index 781ee65050..bc257aac0d 100644
--- a/fastchat/modules/gptq.py
+++ b/fastchat/modules/gptq.py
@@ -1,22 +1,11 @@
-import os
-import sys
 from dataclasses import dataclass, field
+import os
 from os.path import isdir, isfile
 from pathlib import Path
+import sys
 
 from transformers import AutoTokenizer
 
-script_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
-module_path = os.path.join(script_path, "../repositories/GPTQ-for-LLaMa")
-
-try:
-    sys.path.insert(0, module_path)
-    from llama import load_quant
-except ImportError:
-    print("Error: Failed to load GPTQ-for-LLaMa")
-    print("See https://github.com/lm-sys/FastChat/blob/main/docs/gptq.md")
-    sys.exit(-1)
-
 
 @dataclass
 class GptqConfig:
@@ -39,6 +28,18 @@ class GptqConfig:
 
 def load_gptq_quantized(model_name, gptq_config: GptqConfig, device):
     print("Loading GPTQ quantized model...")
+
+    try:
+        script_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+        module_path = os.path.join(script_path, "../repositories/GPTQ-for-LLaMa")
+
+        sys.path.insert(0, module_path)
+        from llama import load_quant
+    except ImportError:
+        print("Error: Failed to load GPTQ-for-LLaMa")
+        print("See https://github.com/lm-sys/FastChat/blob/main/docs/gptq.md")
+        sys.exit(-1)
+
     tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False)
     # only `fastest-inference-4bit` branch cares about `act_order`
     if gptq_config.act_order:

Fix some bugs in #1209 