MCPcopy Create free account
hub / github.com/MeshInfra/WaferLLM / main

Function main

Decode/compile.py:34–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32
33
34def main():
35 ap = argparse.ArgumentParser(description="Compile Decode (WSE-3, SDK 2.10)")
36 ap.add_argument("--mode", choices=["sim", "device"], required=True)
37 ap.add_argument("--config", required=True)
38 args = ap.parse_args()
39
40 cfg_name = os.path.splitext(os.path.basename(args.config))[0]
41 with open(args.config, encoding="utf-8") as f:
42 cj = json.load(f)
43 d = derive_params(cj)
44 P = d["P"]
45 params = ",".join(f"{k}:{v}" for k, v in d.items())
46
47 print("Start compiling: " + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())), flush=True)
48
49 if args.mode == "sim":
50 out_dir = f"out_{cfg_name}"
51 subprocess.run(["rm", "-rf", out_dir], check=True)
52 cmd = [
53 "cslc", "--arch=wse3", "./src/layout.csl",
54 f"--fabric-dims={P + 7},{P + 2}", "--fabric-offsets=4,1",
55 f"--params={params}", "-o", out_dir, "--memcpy", "--channels", "1",
56 ]
57 subprocess.run(cmd, check=True)
58 else:
59 from cerebras.sdk.client import SdkCompiler
60 os.makedirs("compile_out", exist_ok=True)
61 options = (
62 f"--arch=wse3 --fabric-dims=762,1172 --fabric-offsets=4,1 "
63 f"-o out --memcpy --channels=4 --params={params}"
64 )
65 with SdkCompiler(resource_cpu=48000, resource_mem=64 << 30, disable_version_check=True) as compiler:
66 artifact_id = compiler.compile(
67 app_path="src", csl_main="layout.csl", options=options, out_path="compile_out",
68 )
69 with open(f"compile_out/artifact_{cfg_name}.json", "w", encoding="utf-8") as f:
70 json.dump({"artifact_id": artifact_id}, f)
71
72 print("End compiling: " + time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())), flush=True)
73
74
75if __name__ == "__main__":

Callers 1

compile.pyFile · 0.70

Calls 1

derive_paramsFunction · 0.70

Tested by

no test coverage detected