-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeep_scan.py
More file actions
39 lines (31 loc) · 1.43 KB
/
deep_scan.py
File metadata and controls
39 lines (31 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import torch
from transformers import AutoConfig, AutoModelForCausalLM
from colorama import Fore, Style, init
init()
print(Fore.CYAN + "--- TFC DEEP PARAMETER SCAN ---" + Style.RESET_ALL)
MODEL_ID = "Qwen/Qwen1.5-MoE-A2.7B"
# 1. Load Skeleton
print("Loading Skeleton...")
config = AutoConfig.from_pretrained(MODEL_ID, trust_remote_code=True)
model = AutoModelForCausalLM.from_config(config, trust_remote_code=True)
# 2. Target the Experts Container
print(Fore.YELLOW + "\nSCANNING EXPERT PARAMETERS (Layer 0)..." + Style.RESET_ALL)
experts_container = model.model.layers[0].mlp.experts
# 3. List all parameters directly
params = list(experts_container.named_parameters())
if len(params) == 0:
print(Fore.RED + "CRITICAL: No parameters found in 'experts' container!" + Style.RESET_ALL)
print("Checking parent MLP...")
for name, _ in model.model.layers[0].mlp.named_parameters():
print(f" (MLP Level) Found: {name}")
else:
for name, param in params:
print(f" Name: '{Fore.GREEN}{name}{Style.RESET_ALL}'")
print(f" -> Shape: {param.shape}")
print(f" -> Type: {type(param)}")
print(Fore.CYAN + "\n--- CONCLUSION ---" + Style.RESET_ALL)
if any("gate_up" in n for n, _ in params):
print("We found 'gate_up'. The previous script failed because it looked for .weight")
elif any("weight" in n for n, _ in params):
print("We found standard weights. The paths might be different.")
print("Done.")