Repository navigation
Add DeepRM Packer scheduling policy - #5
Conversation
packer: among pairs that fit now, max sum_r free[r][now] * peak[r] (unnormalized, current tick only), as DeepRM's get_packer_action; uses PairCache. Hand-worked scenario (differs from tetris), added to the cache-vs-fresh-scan property test, registered, in paper eval, CI smoke run and docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reviewer's GuideUses of the APIInclude Packer in the paper evaluation's built-in policy set.
ImplementationImplement Packer scoring and register the policy so it can be selected and resolved by name.
Make machine cache stamps globally unique so a cached policy cannot reuse stale scores across engines or resets.
Limit PRTMCTS training episodes to 1000 ticks to prevent policies that wait indefinitely from hanging training.
ConfigurationAdd Packer to the CI smoke-test policy matrix.
DocumentationDocument Packer in the CLI policy list and explain its scoring rule alongside the other scheduling policies.
Add Packer to the documented Python built-in policy choices.
List Packer among the supported policies in the README.
TestsVerify Packer's scoring, tie-breaking, waiting behavior, cache isolation across engines, and cached-versus-fresh decision equivalence.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/adapters/policies/packer.zig" line_range="40" />
<code_context>
+ }
+
+ pub fn decide(self: *Packer, st: *const model.State) model.Action {
+ self.cache.update(st, score, {}) catch @panic("packer: out of memory");
+ return self.cache.pick(st, PairCache.noPen, {});
+ }
</code_context>
<issue_to_address>
**Stale scores survive Packer reuse**
When the same Packer is reused across engine resets or separate engines with matching cached dimensions, epochs, stamps, and job IDs but changed capacities or demands, `PairCache.update` treats the matching IDs and metadata as proof that cached rows are current and skips recomputing them, so `Packer.decide` uses stale fit results or scores and returns an inferior or illegal placement, or waits despite a fitting job.
Invalidate or rebuild the `PairCache` when the engine or job state changes instead of treating matching IDs and metadata as sufficient.
</issue_to_address>
### Comment 2
<location path="src/adapters/policies/packer.zig" line_range="25" />
<code_context>
+ const mach = st.machines.get(m);
+ var acc: f32 = 0;
+ for (0..st.machines.layout.n_res) |r| {
+ acc += @as(f32, @floatFromInt(mach.resource(r)[0])) * @as(f32, @floatFromInt(peak[r]));
+ }
+ return acc;
</code_context>
<issue_to_address>
**Packer chooses a lower-scoring pair**
When fitting candidates have distinct integer dot products that round to the same `f32` value, `score` converts and accumulates the dot products as `f32`, so `PairCache.pick` treats distinct scores as tied and resolves the tie by order, selecting a pair with a lower mathematical score.
Use a score representation and accumulation that preserve distinctions between candidate integer dot products.
Also at `src/adapters/policies/packer.zig:26-27`.
</issue_to_address>
### Comment 3
<location path="tests/scenario_test.zig" line_range="488" />
<code_context>
+ _ = try sim2.place(want, 0);
+ }
+ const s3 = sim2.eng.state();
+ try testing.expect(p2.decide(&s3) == .wait);
+}
+
</code_context>
<issue_to_address>
**Wait assertion has no waiting jobs**
When the preceding placement loop has placed all three jobs, the `scenario: packer scores free-now x demand, unnormalized (DeepRM)` test places all three jobs in the preceding loop, so this assertion passes on an empty job set even if Packer incorrectly selects jobs that do not fit. It does not verify the claimed wait behavior when jobs remain but none fit.
Leave a job unplaced that cannot fit in the remaining capacity before asserting that the policy waits.
</issue_to_address>… test - Machines epoch/stamp now come from one process-wide counter, so a PairCache policy reused with another engine can't match stale scores (regression test: same Packer on a second engine with swapped machines). - packer sums the dot product in u64 before converting to f32. - packer wait assertion now has a job left that does not fit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A policy that keeps choosing wait never ended the episode, and MCTS replay made each step slower, so training stalled after ~8 iterations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
New policy
packer, the packing baseline from DeepRM (Mao et al., HotNets'16;get_packer_actionin the reference code): among the (job, machine) pairs that fit now, pick the max ofHow it differs from
tetrisWith one machine it is exactly DeepRM's Packer. Ties: first machine, then oldest job. Uses
PairCachelike best_fit/tetris.Tests
tests/scenario_test.zigwhere packer and tetris pick different machines, plus the job order packer picks and wait when nothing fits.Also
Registered (
--policy packer,env.policy_action("packer")), added topaper/evaluate.py, the CI smoke loop and the docs.Paper workload, 50 seeds, avg slowdown: sjf 1.92, tetris_srpt 2.01, packer 3.30, fifo 3.34, best_fit 3.36, tetris 5.81. That matches DeepRM, where Packer trails SJF on slowdown.
🤖 Generated with Claude Code
Summary by Sourcery
Add the DeepRM Packer baseline and integrate it throughout policy execution, evaluation, testing, and documentation.
New Features:
Bug Fixes:
CI:
Documentation:
Tests:
Chores: