- Move dead dsv4/ modules to dsv4/_archive/ (52 files)
- model/{dsv4,mtp,layer,layer_schedule}
- layers/{embedding,attention,ffn,norm} (kept linear,mhc,router,moe,shared_expert,grouped_linear - live)
- cache/*, kernels/cache/*, kernels/indexer/{csa_indexer,score_topk,compute_valid_lens}
- kernels/router/{nvfp4_fused_router,dense_router_decode_kernel,dense_router_prefill}
- ops/{topk,topk_select,rope,router}, loader/{hf_checkpoint,layout_convert}
- reference/{attention,compressor,csa_attention,moe_pipeline}
- kernels/compressor/{compress_tail,csa_hca}
- Restore dsv4/ops/{router,custom_ops}.py (needed by live layers)
- Fix dsv4/kernels/{indexer,compressor,attention}/__init__.py (removed broken imports)
- Remove preload_all() from loader.py (dead, referenced nonexistent .cu file)
- Fix loader.py docstring (fused_amax_quantize_nvfp4 → quantize_nvfp4_from_buffer)
- Move broken tests to tests/e2e_archive/
- test_fused_router, production_values_test, e2e/{one_layer,model_construction,csa_hca}
- vLLM has 0 imports of dsv4 (Step 0 confirmed)
39 lines
1.5 KiB
Python
39 lines
1.5 KiB
Python
# helpers/import_closure.py — list dsv4 modules NOT reachable from the entry points.
|
|
# Usage: python3 helpers/import_closure.py (run from repo root)
|
|
# NOTE: handles lazy imports inside functions (single_shot uses these heavily)
|
|
import ast, pathlib, sys
|
|
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
|
ENTRYPOINTS = ["single_shot_inference.py"] # vLLM has 0 imports of dsv4 (Step 0 confirmed)
|
|
|
|
def module_to_path(mod):
|
|
p = ROOT / (mod.replace(".", "/") + ".py")
|
|
if p.exists(): return p
|
|
p = ROOT / mod.replace(".", "/") / "__init__.py"
|
|
return p if p.exists() else None
|
|
|
|
def imports_of(path):
|
|
"""Parse ALL imports including lazy ones inside functions."""
|
|
tree = ast.parse(path.read_text())
|
|
out = set()
|
|
for n in ast.walk(tree):
|
|
if isinstance(n, ast.Import):
|
|
out |= {a.name for a in n.names}
|
|
elif isinstance(n, ast.ImportFrom) and n.module:
|
|
out.add(n.module)
|
|
return {m for m in out if m.startswith("dsv4")}
|
|
|
|
seen, stack = set(), list(ENTRYPOINTS)
|
|
stack = [ (ROOT / e) for e in stack ]
|
|
while stack:
|
|
f = stack.pop()
|
|
if f in seen or f is None or not f.exists(): continue
|
|
seen.add(f)
|
|
for m in imports_of(f):
|
|
mp = module_to_path(m)
|
|
if mp and mp not in seen: stack.append(mp)
|
|
|
|
all_py = set((ROOT / "dsv4").rglob("*.py"))
|
|
dead = sorted(p.relative_to(ROOT) for p in all_py - seen if "__pycache__" not in str(p))
|
|
print("REACHABLE:", len(seen), " | DEAD CANDIDATES:", len(dead))
|
|
for d in dead: print(" ", d)
|