fix(coordinator): route target_reached through CLOSE so the close seq… - #1237
fix(coordinator): route target_reached through CLOSE so the close seq…#1237WhatGhost wants to merge 2 commits into
Conversation
1bd8c04 to
2a997ab
Compare
Code ReviewSummarySolid fix. The root-cause analysis is accurate: Publishing E2E evidence in the PR description is convincing ( Findings1. [Medium] Unit test uses the wrong state fieldIn c.shared_state.cumulative_gain_validated = 50.0But c.shared_state.cumulative_gain = 50.0With 2. [Low] Test assertion is weaker than the fix targetThe test only asserts assert c.shared_state.close_sequence_done is True3. [Low] Resume with pre-set
|
@xiaofei-zheng Thanks for you review~. I'll read and fix them. |
|
@xiaofei-zheng Thanks for the review. I've read and fixed them. Please review again. For 1 — This may be based on an earlier revision. On current For 2 — Agreed, real gap. Added For 3 — Reproducible, and a consequence of the For 5 — Fixed: |
Problem
When a run meets its
--target-gain, the coordinator breaks out of the tick loop immediately, so the CLOSE phase never runs and the 7-step close sequencer is skipped. The session ends with only the CLI safety-net report:{ "report_complete": false, "safety_net": true, "stop_reason": "target_reached" }A successful run therefore loses the real
reportoutput, the post-optimization roofline (CLOSE step 0),kernel_optimization_summary.json,robustness_postmortem.md, and the CLOSE segment insession_breakdown.json.Root cause
machine_state.py:228registerstarget_reachedas an "any phase -> CLOSE" terminal transition reason, but nothing ever produced that transition —compute_next_phase()never returns it. The only producer was the tick loop, which used it as a local variable and broke:_advance_phase_if_needed()lives in the tick body, sobreakremoves any further chance to reach CLOSE — andshared_state.stop_reasonis still empty at that point, since it is only written in thefinallyblock.This also made the two success terminals inconsistent:
time_exhausted(also in_SUCCESS_STOP_REASONS) routes through a closing path, so a timeout closed cleanly while a met target did not.Fix
Publish the stop reason and let the existing state machine drive the transition:
_global_terminal()(machine_state.py:1645) already picks this up — its comment reads "Coordinator-set stop_reason takes precedence over phase exits". That path had simply never been fed a value. No new mechanism is introduced.Bounded: after
continue, theif self.shared_state.stop_reason and not in_closingcheck necessarily fires on the next tick, so the loop runs at most one extra tick and cannot spin regardless of whether CLOSE succeeded. Theelsebranch preserves the previous behaviour when a stop reason is already published, leaving the timeout path untouched.Verification
Unit test.
test_target_reached_routes_through_close_phasebuilds a run that necessarily meets its objective and asserts the phase reaches CLOSE. Reverting only the implementation confirms it catches the bug:Full suite.
9 failed, 14360 passed, 32 skipped— the same 9 pre-existing failures asmain; passing count goes 14359 -> 14360 (the new test).End-to-end. A real run (MI355X, vLLM 0.24.0, Qwen3-8B, TP=1, conc=64, ISL=OSL=1024, bf16,
--target-gain 15) ending intarget_reached:reason=target_reachedon the EXPLORE segment is the vocab entry that previously had no producer.final.mdheading— emergency final reportInference Optimizer Report — <id>final.jsonreport_complete/safety_netfalse/truekernel_optimization_summary.jsonrobustness_postmortem.md