Skip to content

scheduler: integrate #246, #221 and #180 as decode-floor v7 (#283) - #309

Merged
hecisaza merged 8 commits into
mainfrom
integrate-283-5f
Oct 1, 2026
Merged

hecisaza merged 8 commits into
mainfrom
integrate-283-5f

Conversation

@hecisaza

@hecisaza hecisaza commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Integrates the three scheduler directions tracked in #283 into one decode-floor patcher (v7), as qualified live in #283:

overlay/patch_mamba_align_chunking.py now accepts decode-floor v7. The proposed TP=2 CHUNK=0 default is not included, and launcher defaults are unchanged.

Qualification

These overlays install scheduler sha256 97c90a18fd0df6f9aeb1452c39801455d90756d315c6846ca0642e934fe4e269 on image ef9f5013. I checked this in-image: the same method gives the known baseline bfd7fffb… for the previous main overlays.

That identity ran a pre-registered baseline → candidate → baseline study on one TP2 pair (2026-09-30, 12:06–2:55 AM EDT). Every trial was valid: 0 replacements, 0 invalid trials, 0 stops.

Check Result
KV-blocked admission progress (#246) PASS. Candidate median R prefill with W present is 135 s, against a 159 s bar (control median ÷ 0.9). W was natively refused 25–56× per trial and completed after R.
#180 contention canary PASS (5/5 in every arm)
TheGrill routine prefill PASS (4/4 gates)
TheGrill decode / concurrency / mixed Inconclusive: baseline A1 vs A2 spread > 5 %. 0 of 30 gates regressed.
Temperature-0 output identity Inconclusive: the baseline agreed with itself on 6/10 prompts
CPU migration matrix PASS (13 producers migrate, 14 malformed inputs refused without writing)

Scope: qualified live on TP2 only. start-tp3.sh and start-tp4.sh load the same two overlays, but TP3/TP4 were not run live.

Known limitation, tracked in #308: under --scheduling-policy priority, a short high-priority prompt waited about 85 s behind a larger KV-blocked request.

Tests (CPU)

  • Scheduler, mamba and concurrency tests: 38 passed. The skipped checks run directly against the pinned image sources and pass.
  • The decode-floor installation test is ported to the v7 contract, with byte-exact fixtures for every public accepted identity (9 of 11; the two pre-release v7 candidates were never published), and it re-verifies an already-installed v7.
  • New multi-step regression for native KV refusal: the peer progresses, the refused waiter stays queued and recovers (fix(scheduler): prevent KV-blocked admissions from starving fair prefill #246).
  • The mamba A4 fixture now downgrades a v7 marker as well as v5.
  • docs/REFERENCE.md: decode-floor v5 references updated to v7 (five lines). README.md is unchanged.
  • Full tests/: no new failures versus main. Both have the same pre-existing test_gen_defaults failure, plus 7 files that need torch.

Closes #246, closes #180, closes #283.

Replace the fair-prefill decode-floor overlay with the integrated v7 patcher
qualified in #283:

- a selected WAITING request refused KV allocation no longer stalls a
  runnable prefill; it keeps being retried and recovers once memory frees (#246)
- explicit priorities keep ranking fair-prefill candidates under
  --scheduling-policy priority; FCFS is unchanged (#221)
- installer migration follows #180's fail-closed contract: pristine, v1, v2,
  v5 and v5+priority installs migrate to the fresh-install v7 bytes; v3/v4,
  drifted, duplicated, marker-only and unmarked helpers are refused unwritten

patch_mamba_align_chunking.py accepts decode-floor v7. #180's concurrency
canary, its docs and its CPU progress regressions land with it. The
decode-floor installation test is ported to the v7 contract with deployed
producer fixtures, and the mamba A4 fixture downgrades v7 as well as v5.

On image ef9f5013 these overlays install scheduler sha256
97c90a18fd0df6f9aeb1452c39801455d90756d315c6846ca0642e934fe4e269, the
identity qualified live in #283 (baseline -> candidate -> baseline, TP2).

Co-authored-by: RandomLlama <108938230+beastllama@users.noreply.github.com>
Co-authored-by: Surlebeat <64695525+surlebeat@users.noreply.github.com>
Co-authored-by: Mauvis Ledford <20738+krunkosaurus@users.noreply.github.com>
…283)

REFERENCE.md: name decode-floor v7 where it said v5, and describe the v7
installer contract (v3/v4 and drifted installs are refused, not migrated).
Drop docs/concurrent-agents.md from this integration: its launcher-default
statements predate main's fair default on all launchers.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Current-v7/deployed migration testing is broken or incomplete, and the new operational documentation contains incorrect defaults.

Review effort: Balanced
Findings: 1 High severity · 3 Medium severity

Open (4)
What changed in this PR

Integrates scheduler fixes from #246, #221, and #180 into decode-floor v7 with authenticated migration and concurrency qualification.

Changes:

  • Adds allocation-aware prefill retry and priority-aware scheduling.
  • Introduces fail-closed v7 migration and Mamba compatibility.
  • Adds migration fixtures, CPU regressions, a live canary, and documentation.
File Description
overlay/​patch_scheduler_decode_floor.py Implements v7 scheduling and migration.
overlay/​patch_mamba_align_chunking.py Accepts decode-floor v7.
tests/​test_scheduler_decode_floor.py Updates installer tests for v7.
tests/​test_prefill_concurrency.py Adds prefill progress regressions.
tests/​test_mamba_align_chunking.py Tests v7 compatibility.
tests/​check_concurrent_agents.py Adds the live concurrency canary.
tests/​fixtures/​legacy_scheduler_helpers.py Provides legacy migration fixtures.
tests/​fixtures/​decode_floor_producers/​v5_main_d5713ec6.py Captures the main v5 producer.
tests/​fixtures/​decode_floor_producers/​v5_priority_763bd30e.py Captures priority-enabled v5.
docs/​concurrent-agents.md Documents concurrency configuration and validation.
CHANGELOG.md Records the v7 integration and qualification.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test_scheduler_decode_floor.py Resolved
Comment thread overlay/patch_scheduler_decode_floor.py Resolved
Comment on lines +634 to +644
def note_alloc_failed(self, request):
# Native KV allocation refusal (new_blocks is None), distinct from a
# policy/alignment zero. Only a selected or granted request counts.
rid = request.request_id
rec = self._open_rec
if rec is not None and (rid in self.selected or rid in rec["grants"]):
self._refused.add(rid)
self._carry.discard(rid) # a refused request cannot hold carry
self.refusals += 1
self._ev("refusal", rid=rid, tier=self._tier(request))
self._release(rid, "allocation")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 300187d: test_native_kv_refusal_keeps_waiter_retryable_and_peer_progressing. A selected waiter is natively refused. The runnable peer then gets a positive grant in the same step. On the next step the waiter is in _refused_prev and is not preselected, but it stays a candidate. With no further refusals it recovers, and the peer keeps progressing. The test fails if the refusal is ignored (the pre-#246 behaviour) and if a refused waiter keeps its slot.

Comment thread tests/test_scheduler_decode_floor.py Resolved
…ic producers

Address review on #309:
- installation_tests() verifies an already-current v7 scheduler exactly (as
  the patcher's main() does) before unpatching, then checks it equals a fresh
  install and that re-applying is a verified no-op.
- New multi-step regression: a selected waiter natively refused KV lets the
  runnable peer progress in the same step, is not preselected for one step,
  stays a candidate and recovers once memory frees, while the peer keeps
  progressing (#246). Fails if the refusal is ignored or the refused waiter
  keeps its slot.
- Byte-exact producer fixtures for every accepted public identity:
  v1-image-d9758a6 (helper rebuilds image ef9f5013 byte-for-byte),
  v5-historical (e329e55), v6-warm-deadline (#180, f89e240) and v6-carry
  (#246, dc702b4), each migrated and re-applied.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The installer can verify mixed-marker scheduler state despite its fail-closed contract, and the canary incompletely rejects credential-bearing URLs.

Review effort: Balanced
Findings: 1 High severity · 3 Medium severity

Open (4)
Resolved since last review (2)

Comment thread overlay/patch_scheduler_decode_floor.py Resolved
Comment thread tests/check_concurrent_agents.py Resolved
… rejects any URL userinfo

Address review on #309:
- _unpatch() now refuses when any decode-floor marker (any version) or
  either helper definition remains after removing the identified install.
  A canonical v7 with a stray v5 or v1 marker no longer verifies as
  "already present". Installer-only change: on image ef9f5013 the
  installed scheduler is still sha256
  97c90a18fd0df6f9aeb1452c39801455d90756d315c6846ca0642e934fe4e269.
- check_concurrent_agents.py rejects password-only and empty-user userinfo
  (e.g. http://:secret@host), not only a non-empty username.
- Regressions: v7-plus-v5/v1-marker refusals in installation_tests() and
  tests/test_check_concurrent_agents.py; both fail on the previous code.
…ed v7 at its own position

Address independent verification of #309 at 7340644:
- _identify() treats a source as pristine only when no decode-floor marker
  of any version and no helper name (_Glm53MixedPrefill, _GLM53_MIXED,
  _glm53_mixed_prefill_policy) is present; an unknown marker such as
  "# [glm53-decode-floor:v99]" is refused without writing instead of being
  installed beside.
- _unpatch() applies the same rule to whatever remains after removing the
  identified install, so a later duplicate policy wrapper (which would
  rebind the global the hooks call) no longer verifies as current.
- installation_tests() compares a deployed v7 against apply_v7() at the
  helper's own position, so a scheduler that also carries adaptive-K (the
  deployed layout, helper before _Glm53AdaptiveK) passes; both compositions
  are checked explicitly. New refusal cases: duplicate wrapper on v7 and on
  pristine, unknown marker, unknown text after the helper.

Installer-only change: on image ef9f5013 the installed scheduler is still
sha256 97c90a18fd0df6f9aeb1452c39801455d90756d315c6846ca0642e934fe4e269
and re-applying on the deployed layout verifies without writing. The two
unpublished v7 pre-release identities still migrate to the fresh-install
bytes.
…er_helpers.py

Replace the six vendored copies of older patcher scripts under
tests/fixtures/decode_floor_producers/ with the byte-exact helper texts of
the same identities (v1-image-d9758a6, v5-main, v5-priority,
v6-warm-deadline, v6-carry), appended to tests/fixtures/legacy_scheduler_helpers.py
in the format #180 established for v1/v2/v5-historical, with provenance in
its docstring.

installation_tests() rebuilds every accepted public identity the same way:
helper text at the installer's anchor plus that version's hook pairs. Each
rebuild was checked byte-identical to the output of the removed patcher
copy, and the installer still authenticates each by sha256 and length.
v5-historical is now exercised directly as well. Same coverage (9 of 11),
about 3,600 fewer lines, no new file layout.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Legacy migration can rewrite an install with a drifted import os, violating the fail-closed contract.

Review effort: Balanced
Findings: 3 Medium severity

Open (3)
Resolved since last review (2)

Comment thread overlay/patch_scheduler_decode_floor.py Resolved
… fixture in the image; record legacy digests

Address review on #309 (b852f57):
- _identify() refuses a legacy install whose `import os` is missing
  ("import drifted") instead of repairing it during migration, matching
  the check the current-v7 path already had. Three refusal cases added; the
  refusal test now also requires a deliberate refusal message, not a crash.
- Dockerfile: the fixtures COPY now ships tests/fixtures/legacy_scheduler_helpers.py
  to /opt/glm53/fixtures/, and the runner resolves its fixture beside itself
  before the checkout tree, so the mandatory build-time self-test
  (python3 /opt/glm53/test_scheduler_decode_floor.py) finds it. New
  tests/test_image_test_layout.py stages the Dockerfile's /opt/glm53 layout
  from its COPY lines and checks that resolution (and, with
  GLM53_SCHEDULER_PY_SRC set, runs the full runner there).
- legacy_scheduler_helpers.py records PINNED_CLEAN_SHA256 and a SOURCE_DIGESTS
  entry per reconstructed legacy install on the pinned source. On that source
  the installation test compares each rebuild against its recorded digest and
  checks the comparison's sensitivity, so the installer's hook tables are
  checked against recorded history rather than against themselves. A wrong
  begin_step hook in the V5 or V6 table is now caught.

Installer-only change: the installed scheduler on image ef9f5013 is still
sha256 97c90a18fd0df6f9aeb1452c39801455d90756d315c6846ca0642e934fe4e269.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Priority credit handling violates its documented affordable-rung contract, and the installation runner rejects accepted legacy v7 identities.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (2)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Borrowing precedes affordable rung selection

overlay/​patch_scheduler_decode_floor.py:809

The borrow branch runs before the affordable-rung branch, so a never-served high-priority request always borrows the largest step-fitting rung even when a smaller rung fits current credit and a lower tier is queued. For example, with 0.21 s credit and learned 256@0.2 s pricing, this grants 2048 tokens and drives credit to -1.39 instead of granting the affordable 256. This contradicts the stated DROP-5f contract and can unnecessarily prolong lower-tier waits; prefer alt before falling back to borrowing.

Medium severity V7 markers incorrectly block legacy identity fallback

tests/​test_scheduler_decode_floor.py:509

Any source containing a v7 marker is treated as current here, so an accepted v7-drop2 or v7-drop4 migration source fails the exact-current _unpatch() and exits before _identify() can recognize it. The production patcher deliberately falls back to legacy identification in this case. Mirror that fallback so the installation runner can execute against every identity the installer accepts.

…legacy hook-table digests

Address review on #309 (f5830dd):
- installation_tests() now falls back to legacy identification for any
  v7-marked source that is not the current helper (as the installer does), so
  the runner can execute against the accepted pre-release v7 identities. A
  supplied legacy install of any identity is migrated and compared against
  apply_v7(clean, at=<its helper position>) and re-applied as a no-op, instead
  of being compared with the fresh-install bytes; with adaptive-K between the
  two positions that comparison was wrong. The same position rule is covered
  with the public v5-main fixture, helper before and after adaptive-K.
- legacy_scheduler_helpers.py records HOOK_TABLE_DIGESTS for the V1/V2/V5/V6
  hook tables. They are checked unconditionally (no scheduler source needed,
  also as a plain pytest test), so a changed table is caught on build-shaped
  and deployed sources too, where the whole-source digests cannot apply. A
  wrong begin_step hook in the V5 or V6 table now fails on every source layout.

Tests only; the installed scheduler on image ef9f5013 is still sha256
97c90a18fd0df6f9aeb1452c39801455d90756d315c6846ca0642e934fe4e269.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Coordinate original #246/#221/#180 scheduler integration and recipe qualification

2 participants