Download kernels/p4_plan_sweep.py from Cion-lab/ounce100m-code: direct link, hf CLI and curl.
- Browser
- Download file 3.13 kB
-
https://huggingface.co/Cion-lab/ounce100m-code/resolve/main/kernels/p4_plan_sweep.py
- Command line
-
hf download hf://Cion-lab/ounce100m-code/kernels/p4_plan_sweep.py
-
curl -L -o p4_plan_sweep.py https://huggingface.co/Cion-lab/ounce100m-code/resolve/main/kernels/p4_plan_sweep.py
3.13 kB
| """Session-shape sweep on free CPU: what the shipped planner actually does at each candidate rate. | |
| The D-018 decision is not only "12,977 tok/s or 9,696 tok/s" -- it is how many billed sessions the run | |
| becomes and whether the remaining weekly quota covers them. Both are computed by the launcher's own `plan()`, | |
| so this runs that function rather than re-deriving the arithmetic in prose: import the pinned launcher, walk | |
| the schedule leg by leg at each rate, and print the legs, the session count, the stepping hours and the | |
| hours the week still owes. | |
| It mutates the module globals between walks, which is exactly what the environment variables do at launch, | |
| so nothing here is a model of the planner -- it is the planner. | |
| """ | |
| import hashlib | |
| import importlib.util | |
| import json | |
| import os | |
| import subprocess | |
| import sys | |
| REV = "c237b478076f68da43dabd3403daa5639286899e" | |
| SHA = "5fb14bc3597d999a21772a66b6f409f01f722019dc78da313feddb2f9c769c48" | |
| os.chdir("/kaggle/working") | |
| url = f"https://huggingface.co/Cion-lab/ounce100m-code/resolve/{REV}/kernels/phase4_session.py" | |
| assert subprocess.run(["curl", "-sfL", url, "-o", "phase4_session.py"]).returncode == 0, "fetch launcher" | |
| got = hashlib.sha256(open("phase4_session.py", "rb").read()).hexdigest() | |
| assert got == SHA, ("LAUNCHER SHA MISMATCH", got[:16], SHA[:16]) | |
| print("pinned launcher", got[:12], flush=True) | |
| spec = importlib.util.spec_from_file_location("phase4_session", "phase4_session.py") | |
| S = importlib.util.module_from_spec(spec) | |
| spec.loader.exec_module(S) | |
| RATES = [(9358.0, "checkpointed, the Gate 3 P3 measurement"), | |
| (12300.0, "D-018's planning rate: sustained across probe 2's two legs"), | |
| (12977.0, "no checkpointing, the optimistic 20-step progress-bar rate")] | |
| QUOTAS = [26.3, 24.5, 22.0] | |
| for rate, why in RATES: | |
| S.PLANNING_TOK_PER_S = rate | |
| sec_per_step = S.TOKENS_PER_STEP / rate | |
| for quota in QUOTAS: | |
| S.QUOTA_LEFT_HOURS = quota | |
| legs, start, guard = [], 0, 0 | |
| while start < S.HORIZON_STEPS and guard < 30: | |
| guard += 1 | |
| pl = S.plan(start, 19.5) | |
| n = pl["planned_steps"] | |
| if not n: | |
| legs.append((start, "REFUSED", pl["usable_hours"])) | |
| break | |
| end = S.HORIZON_STEPS if pl["stop_after_steps"] == 0 else pl["stop_after_steps"] | |
| legs.append((start, end, end - start)) | |
| start = end | |
| trained = sum(l[1] - l[0] for l in legs if isinstance(l[1], int)) | |
| hours = trained * sec_per_step / 3600.0 | |
| sessions = len(legs) | |
| print("RATE %6.0f (%s) QUOTA %5.1f h -> %d sessions, %d/%d steps, %.2f h stepping; %s" % ( | |
| rate, why, quota, sessions, trained, S.HORIZON_STEPS, hours, | |
| "FITS" if trained == S.HORIZON_STEPS and hours <= quota else "DOES NOT FIT"), flush=True) | |
| print(" legs", json.dumps(legs), flush=True) | |
| if trained != S.HORIZON_STEPS: | |
| print(" shortfall %d steps = %.2f h at this rate" % ( | |
| S.HORIZON_STEPS - trained, (S.HORIZON_STEPS - trained) * sec_per_step / 3600.0), flush=True) | |
| print("PLAN_SWEEP_DONE", flush=True) | |