Spaces:
Sleeping
Sleeping
File size: 2,370 Bytes
80292cf | 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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | """Debug harness: run static_graph against a list of models and report depth/leaves."""
import sys, os, time, traceback
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
# Avoid torch import cascade — static_graph doesn't need torch.
os.environ.setdefault("TRANSFORMERS_NO_ADVISORY_WARNINGS", "1")
from backend.model_loader import _load_config_robust
from backend.static_graph import build_static_graph, find_arch_class
MODELS = [
"bert-base-uncased",
"prajjwal1/bert-tiny",
"openai/whisper-tiny",
"openai/whisper-base",
"Qwen/Qwen2.5-0.5B",
"google/vit-base-patch16-224",
"google-t5/t5-small",
"openai-community/gpt2",
"distilbert/distilbert-base-uncased",
"FacebookAI/roberta-base",
"microsoft/deberta-v3-base",
"google/flan-t5-base",
"facebook/bart-base",
"mistralai/Mistral-7B-v0.1",
"meta-llama/Llama-3.2-1B",
"Qwen/Qwen3.6-35B-A3B",
"stabilityai/stablelm-2-1_6b",
"microsoft/phi-2",
"google/gemma-2-2b",
"openai/clip-vit-base-patch32",
]
def report(model_id):
print(f"\n=== {model_id} ===")
try:
cfg = _load_config_robust(model_id)
except Exception as e:
print(f" CONFIG FAIL: {e}")
return None
cls, mod = find_arch_class(cfg)
print(f" arch={cfg.architectures} model_type={getattr(cfg,'model_type',None)} → cls={cls.__name__ if cls else None}")
if cls is None:
return None
t0 = time.time()
try:
g = build_static_graph(cfg)
except Exception as e:
print(f" GRAPH FAIL: {e}")
traceback.print_exc()
return None
elapsed = time.time() - t0
depths = [n["depth"] for n in g["nodes"]]
leaf = sum(1 for n in g["nodes"] if n["is_leaf"])
kinds = {}
for n in g["nodes"]:
kinds[n["kind"]] = kinds.get(n["kind"], 0) + 1
print(f" nodes={len(g['nodes'])} edges={len(g['edges'])} max_depth={max(depths)} leaves={leaf} t={elapsed*1000:.0f}ms")
print(f" kinds={kinds}")
# Top-level + 1 sample of each depth
by_depth = {}
for n in g["nodes"]:
by_depth.setdefault(n["depth"], []).append(n)
for d in sorted(by_depth)[:6]:
sample = by_depth[d][0]
print(f" d={d} count={len(by_depth[d])} ex: {sample['module_class']} args={sample['config']}")
return g
for m in MODELS:
report(m)
|