Spaces:
Running
on
A100
Running
on
A100
Gong Junmin
commited on
Commit
·
13bcd3e
1
Parent(s):
259f26f
fix Qwen3ForCausalLM has no attribute
Browse files
Dockerfile
CHANGED
|
@@ -42,7 +42,7 @@ USER user
|
|
| 42 |
RUN pip install --no-cache-dir --user -r requirements.txt
|
| 43 |
|
| 44 |
# Install nano-vllm with --no-deps since all dependencies are already installed
|
| 45 |
-
RUN pip install
|
| 46 |
|
| 47 |
# Copy the rest of the application
|
| 48 |
COPY --chown=user:user . .
|
|
|
|
| 42 |
RUN pip install --no-cache-dir --user -r requirements.txt
|
| 43 |
|
| 44 |
# Install nano-vllm with --no-deps since all dependencies are already installed
|
| 45 |
+
RUN pip install ./acestep/third_parts/nano-vllm
|
| 46 |
|
| 47 |
# Copy the rest of the application
|
| 48 |
COPY --chown=user:user . .
|
acestep/third_parts/nano-vllm/nanovllm/utils/loader.py
CHANGED
|
@@ -11,18 +11,54 @@ def default_weight_loader(param: nn.Parameter, loaded_weight: torch.Tensor):
|
|
| 11 |
|
| 12 |
def load_model(model: nn.Module, path: str):
|
| 13 |
packed_modules_mapping = getattr(model, "packed_modules_mapping", {})
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
with safe_open(file, "pt", "cpu") as f:
|
| 16 |
for weight_name in f.keys():
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
def load_model(model: nn.Module, path: str):
|
| 13 |
packed_modules_mapping = getattr(model, "packed_modules_mapping", {})
|
| 14 |
+
|
| 15 |
+
# Collect all weight names for error reporting
|
| 16 |
+
all_weight_names = []
|
| 17 |
+
safetensor_files = glob(os.path.join(path, "*.safetensors"))
|
| 18 |
+
|
| 19 |
+
if not safetensor_files:
|
| 20 |
+
raise FileNotFoundError(f"No .safetensors files found in {path}")
|
| 21 |
+
|
| 22 |
+
for file in safetensor_files:
|
| 23 |
+
with safe_open(file, "pt", "cpu") as f:
|
| 24 |
+
all_weight_names.extend(f.keys())
|
| 25 |
+
|
| 26 |
+
# Get model's available parameters for error reporting
|
| 27 |
+
model_params = dict(model.named_parameters())
|
| 28 |
+
|
| 29 |
+
for file in safetensor_files:
|
| 30 |
with safe_open(file, "pt", "cpu") as f:
|
| 31 |
for weight_name in f.keys():
|
| 32 |
+
try:
|
| 33 |
+
for k in packed_modules_mapping:
|
| 34 |
+
if k in weight_name:
|
| 35 |
+
v, shard_id = packed_modules_mapping[k]
|
| 36 |
+
param_name = weight_name.replace(k, v)
|
| 37 |
+
param = model.get_parameter(param_name)
|
| 38 |
+
weight_loader = getattr(param, "weight_loader")
|
| 39 |
+
weight_loader(param, f.get_tensor(weight_name), shard_id)
|
| 40 |
+
break
|
| 41 |
+
else:
|
| 42 |
+
param = model.get_parameter(weight_name)
|
| 43 |
+
weight_loader = getattr(param, "weight_loader", default_weight_loader)
|
| 44 |
+
weight_loader(param, f.get_tensor(weight_name))
|
| 45 |
+
except AttributeError as e:
|
| 46 |
+
# Detailed error message for debugging
|
| 47 |
+
print(f"\n{'='*60}")
|
| 48 |
+
print(f"[nano-vllm] Weight loading error!")
|
| 49 |
+
print(f"{'='*60}")
|
| 50 |
+
print(f"Failed to load weight: {weight_name}")
|
| 51 |
+
print(f"Error: {e}")
|
| 52 |
+
print(f"\nWeight file: {file}")
|
| 53 |
+
print(f"\n--- Weights in safetensors file (first 20) ---")
|
| 54 |
+
for i, name in enumerate(sorted(all_weight_names)[:20]):
|
| 55 |
+
print(f" {name}")
|
| 56 |
+
if len(all_weight_names) > 20:
|
| 57 |
+
print(f" ... and {len(all_weight_names) - 20} more")
|
| 58 |
+
print(f"\n--- Model parameters (first 20) ---")
|
| 59 |
+
for i, name in enumerate(sorted(model_params.keys())[:20]):
|
| 60 |
+
print(f" {name}")
|
| 61 |
+
if len(model_params) > 20:
|
| 62 |
+
print(f" ... and {len(model_params) - 20} more")
|
| 63 |
+
print(f"{'='*60}\n")
|
| 64 |
+
raise
|