Repository navigation
PSPLIB generator, eval tick cap, pool holds every job #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,3 +27,4 @@ python/out/ | |
| *.zip | ||
| bench/compare.png | ||
| paper/out/ | ||
| data/psplib/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ | |
|
|
||
| Metrics per episode (from the trace): average slowdown (wait + dur) / dur, | ||
| average wait, makespan, total reward, jobs rejected (full pool, impossible) | ||
| and admitted jobs left unplaced. | ||
| admitted jobs left unplaced, and episodes cut off at --max-ticks. | ||
| Writes paper/out/eval.json and prints a mean ± std table. | ||
| """ | ||
|
|
||
|
|
@@ -65,7 +65,8 @@ def read_trace(path: Path) -> tuple[dict, dict]: | |
| "wait": float(np.mean(wait)) if wait else float("nan"), | ||
| "makespan": done["makespan"] if done else None, | ||
| "unplaced": sum(1 for v in work.values() if v[1] is not None) - len(places), # admitted, never placed | ||
| "rejected": sum(1 for v in work.values() if v[1] is None)} | ||
| "rejected": sum(1 for v in work.values() if v[1] is None), | ||
| "truncated": int(bool(done and done.get("truncated")))} | ||
| return m, work | ||
|
|
||
|
|
||
|
|
@@ -119,6 +120,8 @@ def main(): | |
| ap.add_argument("--seed-start", type=int, default=EVAL_SEED_START) | ||
| ap.add_argument("--sims", type=int, default=32, help="MCTS simulations per move (0 = skip ptr+mcts)") | ||
| ap.add_argument("--policies", default=",".join(BUILTIN)) | ||
| ap.add_argument("--max-ticks", type=int, default=2000, | ||
| help="end (truncate) an episode after this many ticks; counted in the 'truncated' column") | ||
| ap.add_argument("--device", default="cpu") | ||
| ap.add_argument("--out", default="paper/out/eval.json") | ||
| args = ap.parse_args() | ||
|
|
@@ -140,7 +143,10 @@ def main(): | |
| overlap = [s for s in seeds if s in used] | ||
| if overlap: | ||
| raise SystemExit(f"evaluation seeds {overlap[0]}.. were used in training ({used.start}..{used.stop - 1})") | ||
| env_kw = ck["env"] if ck else ENV_KW | ||
| env_kw = dict(ck["env"] if ck else ENV_KW) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Checkpoint paths trigger local reads When a user evaluates an untrusted checkpoint whose environment selects a FIFO or a directory with a large number of Validate checkpoint environment specs before constructing the environment, and restrict PSPLIB inputs to explicitly trusted regular files or bounded directories. Also at Prompt for AI agentsIn `paper/evaluate.py` at line 146:
**Checkpoint paths trigger local reads**
When a user evaluates an untrusted checkpoint whose environment selects a FIFO or a directory with a large number of `.sm`/`.mm` files, evaluation passes checkpoint-controlled `env["machines"]` to `SchedEnv`, and the PSPLIB generator reads the resulting path as the current user. A checkpoint pointing to a FIFO or a directory with many matching files can hang or exhaust the evaluation process, so users see a stuck or terminated run.
Validate checkpoint environment specs before constructing the environment, and restrict PSPLIB inputs to explicitly trusted regular files or bounded directories.
Also at `src/app/registry.zig:97`. |
||
| # a policy that keeps choosing "wait" would otherwise never end the episode; | ||
| # every job has arrived long before this, so the cap does not change the workload | ||
| env_kw["max_ticks"] = env_kw.get("max_ticks") or args.max_ticks | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Paper changes lack regression tests When the paper tick-cap and pool-size changes are merged without dedicated tests, the new evaluation tick-cap and reporting path, and the 80-slot paper pool configuration, can regress without any test failing; existing truncation coverage exercises engine behavior, not these paper changes. Add paper-level tests for capped evaluation and truncated reporting, and for admitting all jobs with the configured pool. Also at Prompt for AI agentsIn `paper/evaluate.py` at line 149:
**Paper changes lack regression tests**
When the paper tick-cap and pool-size changes are merged without dedicated tests, the new evaluation tick-cap and reporting path, and the 80-slot paper pool configuration, can regress without any test failing; existing truncation coverage exercises engine behavior, not these paper changes.
Add paper-level tests for capped evaluation and truncated reporting, and for admitting all jobs with the configured pool.
Also at `paper/ptrmcts.py:61`.From - Every behavior change needs a test; integration tests in tests/. Engine
semantics: add a hand-worked case to tests/scenario_test.zig; the
`property:` test there checks against a naive reference simulator. |
||
| env = SchedEnv(**env_kw) | ||
|
|
||
| policies = {name: (lambda e, o, s, p, n=name: e.policy_action(n)) for name in args.policies.split(",") if name} | ||
|
|
@@ -176,7 +182,7 @@ def main(): | |
| print(f"\n{len(seeds)} seeds from {args.seed_start}; same workload for every policy: " | ||
| f"{'yes' if not checks['workload_mismatch'] else 'NO ' + str(checks['workload_mismatch'])}; " | ||
| f"engine deterministic: {'yes' if not checks['nondeterministic'] else 'NO ' + str(checks['nondeterministic'])}\n") | ||
| cols = ["slowdown", "wait", "makespan", "reward", "rejected", "unplaced", "sec"] | ||
| cols = ["slowdown", "wait", "makespan", "reward", "rejected", "unplaced", "truncated", "sec"] | ||
| print(f"{'policy':<14}" + "".join(f"{c:>18}" for c in cols)) | ||
| summary = {} | ||
| for name, rows in results.items(): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,12 +49,16 @@ | |
| from sched_env import _lib # noqa: E402 | ||
|
|
||
| # Environment used in the paper experiments. Small enough for MCTS on a CPU. | ||
| # The waiting pool has one slot per job in the episode, so it can never be | ||
| # full: no job is rejected and the model always sees every waiting job (the | ||
| # pointer network handles any number of jobs; empty slots are masked). | ||
| N_JOBS = 80 | ||
| ENV_KW = dict( | ||
| machines="deeprm:n=1", | ||
| jobs="poisson:n=80,rate=0.8", | ||
| jobs=f"poisson:n={N_JOBS},rate=0.8", | ||
| n_res=2, | ||
| n_ticks=20, | ||
| max_jobs=10, | ||
| max_jobs=N_JOBS, | ||
| reward="slowdown", | ||
| ) | ||
|
|
||
|
|
@@ -87,6 +91,19 @@ def atomic_write(path, write) -> None: | |
| raise | ||
|
|
||
|
|
||
| def env_config(psplib: str | None = None) -> dict: | ||
| """ENV_KW, or with job profiles from PSPLIB instances (a .sm file or a | ||
| directory of them): 4 renewable resources, demand / availability x 100.""" | ||
| if not psplib: | ||
| return dict(ENV_KW) | ||
| path = os.path.abspath(psplib) | ||
| if not os.path.exists(path): | ||
| raise FileNotFoundError(path) | ||
| if "," in path or "=" in path: | ||
| raise ValueError(f"PSPLIB path must not contain ',' or '=': {path}") | ||
| return {**ENV_KW, "machines": f"psplib:path={path},n=1", "n_res": 4} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · PSPLIB training rejects valid instances When the selected instance, or an instance in the selected directory, has fewer than four renewable resources, Set Prompt for AI agentsIn `paper/ptrmcts.py` at line 104:
**PSPLIB training rejects valid instances**
When the selected instance, or an instance in the selected directory, has fewer than four renewable resources, `--psplib` sets `n_res` to 4, so `Psplib.machine` rejects the request when the instance provides fewer renewable resources and `SchedEnv` construction fails before training starts.
Set `n_res` to a value supported by the selected PSPLIB instance instead of always fixing it at 4. |
||
|
|
||
|
|
||
| def make_env(**overrides) -> SchedEnv: | ||
| return SchedEnv(**{**ENV_KW, **overrides}) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · Invalid caps break evaluation
When the effective
max_ticksvalue is zero or negative,SchedEnvresets an already-finished engine for a zero cap, sorunfails on its firststep; for a negative cap,sim_createtreats the value as no cap and a wait-only policy never ends, so evaluation fails or hangs.Validate the effective cap from the CLI and checkpoint as positive before constructing
SchedEnv.Also at
paper/evaluate.py:149.Prompt for AI agents