Repository navigation
Keep checkpoint capture on the admitted continuation clock #8621
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
Open
huangruiteng
wants to merge
3
commits into
main
Choose a base branch
from
codex/edgebench-resumed-phase-clock-20261112
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+79
−25
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,12 @@ | |
| from benchmark.edgebench.source import active_source_receipt | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("clock", [b"nan\n", b"9007199254740992.0\n", b"2000.25000000000000001\n"]) | ||
| def test_phase_budget_rejects_invalid_or_rounded_clock(clock): | ||
| with pytest.raises(ValueError, match="Host phase deadline"): | ||
| transport._phase_budget(clock, {"captured_at_epoch": 1000}) | ||
|
|
||
|
|
||
| @contextmanager | ||
| def server(app): | ||
| import uvicorn | ||
|
|
@@ -267,20 +273,25 @@ def reject_non_json_constant(value): | |
|
|
||
|
|
||
| def host_phase_command(tmp_path, monkeypatch): | ||
| """Real command builder; only installation/inference are outside this oracle.""" | ||
| """Real phase admission shell, isolated from installation and model access.""" | ||
| pytest.importorskip("harbor") | ||
| from sforge.harness.config import SForgeConfig | ||
| from benchmark.runtime.sforge import BenchmarkCodex, SForgeWorker | ||
|
|
||
| async def installed(self, environment): | ||
| pass | ||
| monkeypatch.setattr(BenchmarkCodex, "install", installed) | ||
| monkeypatch.setenv("CODEX_AUTH_JSON_PATH", "/synthetic-not-read") | ||
| logs = tmp_path / "phase-worker" | ||
| logs.mkdir() | ||
| worker = SForgeWorker(SForgeConfig(agent_model="fixture", agent_effort="xhigh"), | ||
| # The model-free prefix must not try to inspect a desktop login. The | ||
| # custom endpoint uses the same phase shell and is never contacted. | ||
| config = SForgeConfig(agent_model="fixture", agent_effort="xhigh", | ||
|
Collaborator
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. [P2] 切分实际生成的阶段命令 三个参数都在 |
||
| agent_api_base_url="http://127.0.0.1:1/v1", agent_api_key="fixture-not-used") | ||
| backend = Mock() | ||
| backend.exec_run.return_value = SimpleNamespace(exit_code=0, output=config.agent_api_base_url) | ||
| worker = SForgeWorker(config, | ||
| profile="heartbeat-resume", cwd="/task", timeout_seconds=43200, task_entry="seeded-todo") | ||
| worker.install_stop_hook(None, None, logs, None) | ||
| worker.install_stop_hook(backend, None, logs, None) | ||
| worker.prepared = True | ||
| # Execute the provider's actual phase shell between subscription readiness | ||
| # and model dispatch. Both surrounding operations are outside this fixture. | ||
|
|
@@ -298,8 +309,8 @@ def test_host_phase_and_native_opportunities_continue_without_offline_refill( | |
| token = register(source, first, max_agent_submissions=3, submission_cooldown=2) | ||
| assert submit(first, token, 7).status_code == 200 | ||
| before = copy.deepcopy((source.state.judge.tokens, source.state.judge.submissions, source.state.judge.run_history)) | ||
| # An already admitted Host has 2h left from its original 12h configured | ||
| # trial. Fixture seeding represents that prior elapsed research, not a new run. | ||
| # An admitted continuation retains about 2h from its original 12h trial. | ||
| # The scheduler publishes a decimal deadline for this phase. | ||
| source_phase = tmp_path / "source-phase" | ||
| source_epoch = int(time.time()) + 7200 | ||
| if fraction is not None: | ||
|
|
@@ -341,7 +352,8 @@ def test_host_phase_and_native_opportunities_continue_without_offline_refill( | |
| result = subprocess.run(["/bin/bash", "-c", shell + | ||
| f"printf '8' > '{candidate}'; printf '%s' \"$remaining\""], | ||
| env={"PATH": str(bin) + ":/usr/bin:/bin"}, capture_output=True, text=True, check=True) | ||
| assert 7180 < int(result.stdout) <= 7200 and candidate.read_bytes() == b"8" | ||
| assert int(result.stdout) == int(phase.read_bytes()) - int(clock) | ||
| assert candidate.read_bytes() == b"8" | ||
| history = requests.get(second + "/api/v1/history", params={"token": fresh, "admin_secret": destination.state.judge.admin_secret}, timeout=5).json() | ||
| assert history["agent_submissions"] == 1 and history["best_score"] == 7 | ||
| assert submit(second, fresh, 8).status_code == 429 | ||
|
|
@@ -626,7 +638,7 @@ def lost(controller, route, body, timeout): | |
| assert calls == ["/api/v1/checkpoint/restore"] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("raw", [b"", b"nan\n", b"1.5.0\n", b"0.0\n", b"9007199254740992\n"]) | ||
| @pytest.mark.parametrize("raw", [b"", b"nan\n", b"1.50\n", b"1.5.0\n", b"0.0\n", b"9007199254740992\n"]) | ||
| def test_invalid_host_epoch_cannot_create_native_point(controllers, tmp_path, raw): | ||
| source, destination, first, second, files, grades = controllers | ||
| token = register(source, first) | ||
|
|
@@ -640,6 +652,24 @@ def test_invalid_host_epoch_cannot_create_native_point(controllers, tmp_path, ra | |
| assert destination.state.judge.tokens == {} and grades == [] | ||
|
|
||
|
|
||
| def test_expired_fractional_epoch_seals_without_work_allowance(controllers, tmp_path): | ||
| source, destination, first, _, files, grades = controllers | ||
| token = register(source, first) | ||
| phase = tmp_path / "source-phase" | ||
| phase.write_bytes(b"1.5\n") | ||
| unit = tmp_path / "unit" | ||
| point = transport.capture(files[0], token=token, capture_id="f" * 32, | ||
| destination=unit, phase_deadline_file=phase) | ||
| manifest = json.loads((unit / "checkpoint.json").read_bytes()) | ||
| budget = manifest["point_metadata"]["host_phase_budget"] | ||
| assert budget["source_deadline_epoch"] == 1.5 and budget["remaining_seconds"] == 0 | ||
| assert (unit / "components" / "host_phase_deadline").read_bytes() == phase.read_bytes() | ||
| with pytest.raises(ValueError, match="no work allowance"): | ||
| transport.restore(files[1], root=unit, expected_sha256=point["sha256"], run_id="expired", | ||
| phase_deadline_file=tmp_path / "destination-phase") | ||
| assert destination.state.judge.tokens == {} and grades == [] | ||
|
|
||
|
|
||
| def test_native_only_point_cannot_acquire_a_later_host_budget(controllers, tmp_path): | ||
| source, destination, first, second, files, grades = controllers | ||
| token = register(source, first) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[P2] 扩大小数语法时请同步现有真实 HTTP 负例。
现有 test_invalid_host_epoch_cannot_create_native_point 的 1.5 用例在 merge base 通过,当前提交报 DID NOT RAISE ValueError。实际 capture 已写入原生点,余额为零且 receiver restore 拒绝。请改用 1.50 或需舍入的小数验证无原生点;另验规范过期值可保存证据但不激活。