Expose predicted per-Instance queue pressure and use it in least_load scoring#125
Open
zhy1658858023 wants to merge 1 commit into
Open
Expose predicted per-Instance queue pressure and use it in least_load scoring#125zhy1658858023 wants to merge 1 commit into
zhy1658858023 wants to merge 1 commit into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
Description
QueueManager.queue_pressure_snapshot()and keptqueue_depth_snapshot()as a compatibility wrapper; the new snapshot returns instantaneous queue fields plus predicted reservation-only aggregates (pending_prefill_count,active_decode_count,next_slot_ready_in_ms,prefill_free_in_ms,predicted_total_backlog_ms) derived from internal reservation state while never exposing task payloads.LeastLoadStrategyto include conservative predicted-pressure components (pending_prefill_count,active_decode_count,predicted_total_backlog_ms) with safe default weights (1.0,0.5,0.001) and integrated them into the existing weighted scoring while preserving inflight and instantaneous queue components and all fallback behaviors (missing predicted fields → instantaneous behavior; missing queue hints → inflight-only; all unknown → round-robin).queue_pressure_snapshot()in selection, the control-plane queue snapshot provider, and pool-level snapshot aggregation so the select-time hint and/debug/instance_loadsshare identical data.proxy/README.mdto explain the three-layer least_load model and the debug curl example.Changed files (why each was necessary):
proxy/queue/manager.py(new snapshot + timeline-derived aggregates),proxy/strategy/least_load.py(add predicted fields and weights to scoring),proxy/proxy.py(use pressure snapshot for selection/provider/pool aggregation),proxy/resource/instance_pool.py(expose predicted fields in/debug/instance_loads),proxy/README.md(docs). No other modules or runtime behaviors (Scheduler routing, KDN/KVCache logic, IWS, queue release/forwarding, Resource Agent sampling, orpool_resourceschema) were modified.Testing
PYTHONDONTWRITEBYTECODE=1 python3 -m py_compile proxy/queue/manager.py proxy/strategy/least_load.py proxy/strategy/factory.py proxy/proxy.py proxy/resource/instance_pool.py proxy/resource/p_control_plane.py proxy/queue/*.py test/demo_proxy.pywhich succeeded.LeastLoadStrategy(lowerinflightwins; higherpending_prefill_countloses wheninflightequal; higherpredicted_total_backlog_msloses when instantaneous queue depths are zero; missing predicted fields fall back to previous queue-aware scoring; missing queue hints fall back to inflight-only; all-unknown → round-robin; ties use round-robin) and they passed via an isolated import test harness.proxyfailed here due to the environment missinguvicorn(ModuleNotFoundError), which is an environment limitation rather than a code error; unit smoke tests still validated behavior.Branch/base info: base branch
work(base SHA17a7f124e4883710fe36016e711d6eb4a24d52d4), head branchcodex/issue-123-predicted-instance-pressure(head SHAc54c2101fd63af562b1e4a5ad35bef68a9f74da0).Codex Task