Skip to content

fix(mesh): sample power_of_two load per instance and drop failures - #3566

Open
MengqingCao wants to merge 3 commits into
mainfrom
mengqing/mesh-load-monitor
Open

MengqingCao wants to merge 3 commits into
mainfrom
mengqing/mesh-load-monitor

Conversation

@MengqingCao

@MengqingCao MengqingCao commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The load monitor that feeds power_of_two had three problems:

  • It requested every worker URL, but a DP rank's url@rank is not a request target, so those samples failed.
  • A failed sample was cached as -1, and comparing against -1 made power_of_two always pick the first of its two random workers.
  • It sampled at the worker startup check interval, not at the policy's load_check_interval_secs.

Summary

  • Query one base URL per instance. A url@rank address is not a request target. ATOM reads atom:dp_inflight_requests{rank} from /metrics; other backends still use /get_load, and only for workers that are not DP ranks.
  • Failed samples stay out of the power_of_two cache, so a cached -1 can no longer make the policy pick the first of two random workers. GET /get_loads still reports -1.
  • The sample interval follows the smallest power_of_two.load_check_interval_secs instead of the worker startup interval.

Split out of #3509. This does not add least_load.

Test plan

  • cargo check --offline --locked --lib on this branch
  • cargo test --offline --locked --lib -- worker_manager::tests (2 passed)

Made with Cursor

@valar-cop valar-cop 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.

some changes needed..

any real ATOM /metrics body showing atom:dp_inflight_requests non-zero, single-engine or DP?

ci green.

Comment thread atom/mesh/src/core/worker_manager.rs Resolved
Comment thread atom/mesh/src/core/worker_manager.rs Resolved
Comment thread atom/mesh/src/core/worker_manager.rs Resolved
Comment thread atom/mesh/src/core/worker_manager.rs Resolved
@MengqingCao
MengqingCao force-pushed the mengqing/mesh-load-monitor branch from a60a68a to b71b05c Compare November 23, 2026 07:36
@MengqingCao
MengqingCao force-pushed the mengqing/agentic-cost-weights branch from 662f705 to 1b09176 Compare November 23, 2026 07:36
@MengqingCao

Copy link
Copy Markdown
Contributor Author

No captured body yet. From the code, atom:dp_inflight_requests{rank} is the engine's _rank_reqs, charged in _dispatch_to_dp_ranks when it routes among DP ranks, which is what DP-aware workers read; a single engine never charges it, hence the queue gauges above.

@MengqingCao
MengqingCao force-pushed the mengqing/mesh-load-monitor branch from b71b05c to 16f000a Compare November 23, 2026 09:16
@MengqingCao
MengqingCao force-pushed the mengqing/agentic-cost-weights branch from 1b09176 to 31e6d11 Compare November 23, 2026 09:16

@valar-cop valar-cop 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.

LGTM

ci run_atomesh_test_harness (Atomesh Mocker Benchmark) failed — not sure yet (low): The captured log is 0 bytes, so the failing step cannot be identified. The same job passes on main 8/8 recent runs and 5/6 on other runs, so it is either flaky, a runner/infra fault, or a step inside this job (cargo test --lib --features atom-engine, token-parity download, ext-proc proto check, mocker harness) failing for a reason the PR diff alone does not reveal.

log .valar/ci/job_137594251164.log is 0 bytes (0 lines)
same job on main: 8x success through 2026-11-23T06:27; on other recent runs: {'failure': 1, 'skipped': 3, 'success': 2}
next: Re-run the job and, if it fails again, attach the failing step's log; the new worker_manager::tests (parse_dp_inflight, parse_queued_requests, cacheable_loads, the two-listener async test) are the only PR content in that lib build, so confirm which step is red. https://github.com/ROCm/ATOM/actions/runs/45145603432/job/137594251164

ci ATOMesh non-GPU unit tests (Atomesh Mocker Benchmark) failed — not sure yet (high): This is a derived gate, not an independent failure: on origin/main the unit-test-gate job is named 'ATOMesh non-GPU unit tests' and declares needs: [unit-test-scope, run_atomesh_test_harness], evaluating that job's result. It fails because run_atomesh_test_harness failed. The job name is absent from the PR head's workflow file, which confirms CI merged a newer base/main than the PR's merge base.

origin/main workflow: unit-test-gate: name: ATOMesh non-GPU unit tests ... needs: [unit-test-scope, run_atomesh_test_harness]
head .github/workflows/atomesh-mocker-benchmark.yaml exposes only run_atomesh_test_harness and run_atomesh_mocker_benchmark
next: Follow the run_atomesh_test_harness entry; no separate action for this gate. https://github.com/ROCm/ATOM/actions/runs/45145603432/job/137601470512

@MengqingCao
MengqingCao force-pushed the mengqing/mesh-load-monitor branch from 16f000a to 9e25615 Compare November 23, 2026 13:37
@MengqingCao
MengqingCao force-pushed the mengqing/agentic-cost-weights branch from 31e6d11 to 22b54ea Compare November 23, 2026 13:37

@valar-cop valar-cop 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.

some changes needed..

ci run_atomesh_test_harness (Atomesh Mocker Benchmark) failed — looks like the pr itself (medium): Log is 0 bytes, but this job builds the atomesh-mocker crate, whose app_helpers.rs still calls the 4-arg LoadMonitor::new after the PR added a backend parameter; the crate cannot compile. Same job passes on main 8/8 and the one recent other-PR run succeeded.

atom/mesh/mocker/app_helpers.rs:83: let load_monitor = Some(Arc::new(LoadMonitor::new(
atom/mesh/mocker/app_helpers.rs:87: config.worker_startup_check_interval_secs,
atom/mesh/src/core/worker_manager.rs:358-364: pub fn new(..., client: reqwest::Client, backend: BackendType, interval_secs: u64) -> Self
next: Update the mocker call site to pass the backend (e.g. config.backend), then re-run; if it still fails, attach the failing step's log. https://github.com/ROCm/ATOM/actions/runs/45185830360/job/137731320910

ci ATOMesh non-GPU unit tests (Atomesh Mocker Benchmark) failed — looks like the pr itself (high): Derived gate: unit-test-gate needs [unit-test-scope, run_atomesh_test_harness] and fails because run_atomesh_test_harness failed. It is not an independent failure.

.github/workflows/atomesh-mocker-benchmark.yaml:239-260: unit-test-gate ... required-results: run_atomesh_test_harness=${{ needs.run_atomesh_test_harness.result }}
next: Follow the run_atomesh_test_harness entry; no separate action for this gate. https://github.com/ROCm/ATOM/actions/runs/45185830360/job/137741316262

Comment thread atom/mesh/src/core/worker_manager.rs Resolved
@valar-cop

Copy link
Copy Markdown

mengqing.cao@amd.com and others added 3 commits November 27, 2026 01:50
A DP worker URL cannot be queried as its own endpoint, and a cached -1
makes power_of_two always pick the first of two workers. One fetch per
instance, ATOM metrics by rank, and failed samples stay out of the cache.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ty loads

- A worker without a DP rank reads atom:requests_running + requests_waiting:
  the engine charges dp_inflight only when it routes among its own DP ranks,
  so on a single-engine replica it stays 0.
- A tick where every fetch fails publishes the empty map, so power_of_two
  drops the stale loads and falls back to its local request count.
- LoadMonitor::new takes the backend instead of an opt-in with_backend.
- Test: one instance's two DP ranks, a single engine and an unreachable
  worker through get_all_worker_loads.

Co-authored-by: Cursor <cursoragent@cursor.com>
LoadMonitor::new takes the backend since the previous commit; the mocker,
its own cargo root, still called the four-argument form and failed to build.

Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit 446622170f0da99f357a3486424f58a744d54af7)
@MengqingCao
MengqingCao removed this pull request from stack #3569 November 27, 2026 01:51
@MengqingCao
MengqingCao force-pushed the mengqing/mesh-load-monitor branch from db79296 to 796f8f5 Compare November 27, 2026 01:51
@MengqingCao
MengqingCao changed the base branch from mengqing/agentic-cost-weights to main November 27, 2026 01:51

@valarLip valarLip left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

⚠️ Action required before merge (5)

The structure is right: one fetch per instance, failed samples stay out of the cache, the empty map is published, and the interval comes from the policy. All valar-cop asks are addressed. The load signal itself is still wrong for one engine mode:

  1. Read ATOM's per-rank scheduler gauge, not dp_inflight. atom:dp_inflight_requests is CoreManager's own load-balancing bookkeeping, and it is charged only when track_load is set (engine_core_mgr.py:1342-1355). With --dp-load-balance round_robin, every rank exports 0. Mesh caches the 0s, so power_of_two compares 0 vs 0 forever and never falls back to its local counts. This also leaves valar-cop's "real /metrics body with dp_inflight non-zero?" unanswered. ATOM already exports atom:scheduler_requests{dp_rank,engine_role,state} per rank (exporter.py:491-517). Read running + waiting per dp_rank, and the sum over ranks for a worker without a rank. That one gauge replaces both parse_dp_inflight and parse_queued_requests. Also fix the comment at worker_manager.rs:228-236: explicit rank hints are charged too. Add a test where dp_inflight is 0 and the scheduler gauge is not.
  2. Reuse the crate's Prometheus parser. openmetrics-parser is already a dependency (Cargo.toml:87, used in observability/metrics/engine_metrics.rs:128-140). The hand-rolled samples / label_value (worker_manager.rs:288-334) duplicates it. label_value also matches rank=" inside dp_rank=", which turns into a real bug once item 1 reads dp_rank.
  3. Fix the load_sample_interval_secs docstring and test it. config/types.rs:574-577 says the monitor does not fetch without the policy. A model-scoped power_of_two from a worker's policy hint (registry.rs:280-287) still makes it fetch, at the startup interval. Nothing tests the function; returning the startup interval unconditionally passes. Cover regular power_of_two(5) -> 5, PD 30/10 -> 10, and none -> startup. The mocker (app_helpers.rs:88) and the test contexts should pass config.load_sample_interval_secs() too, as production does.
  4. Nit: policies/power_of_two.rs:71-87 says "high-fidelity token loads" / "Compare Tokens". An ATOM sample is now a request count, so say "sampled loads".
  5. Nit: fix the squash text. The body says ATOM reads only dp_inflight and the test plan says "2 passed" (there are 4 tests). Mention the empty-map publish, and drop the "(cherry picked from ...)" line.

CI: no workflow ran on 796f8f5. The same three patches were green on the Atomesh lanes at 0c36669 and db79296. Re-run CI on the head.

Root cause vs patch: right direction, with a patch-like signal choice. Mesh needs one per-rank load signal that does not depend on how the engine balances internally. The PR mixes the engine's LB bookkeeping with the instance totals. The per-rank scheduler gauge is the cheap, mesh-only root fix.


Reviewed at 796f8f5 (round 1, Standard, 2 independent passes).

This branch has not been deployed

No deployments
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.

3 participants