Skip to content

Clean up residency source - #267

Open
julia-rai wants to merge 10 commits into
mainfrom
logos/remove-measured-state
Open

julia-rai wants to merge 10 commits into
mainfrom
logos/remove-measured-state

Conversation

@julia-rai

@julia-rai julia-rai commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What changes

A profile's residency_source is calibrated, hf or empty.

  • The labels override and cached are gone. Operator values from the node
    configuration still pin single fields (overridden_fields) but no longer
    change the source.
  • One rule everywhere: only calibrated passes the calibration gate and counts
    as complete, on CUDA and Metal. The Metal exemption is removed.
  • A Metal calibration (one probe, no KV sweep, no sleep) is complete without KV
    pairs and sleep values. The worker and the orchestrator check this per
    backend.
  • The measured base survives an operator base override. calibrated_footprint_mb
    is always set, shared calibration snapshots take their base from it, and
    effective_profile restores it when the override is removed.
  • The orchestrator stores only calibrated or hf as source (column and JSONB),
    whatever a worker reports.
  • Migration 107_model_profile_source_cleanup clears measured, override and
    cached and bumps sync_revision. Stored values stay.
  • config.example.yml, config.example.mlx.yml and MACOS.md: a pinned
    base_residency_mb is the full footprint including the KV cache. The
    statements that Metal cannot be calibrated are removed.

Already on main

The first two commits (6f2de525, e1855293) remove the measured source.
They are already on main and part of this branch's history. Please review
them together with this PR.

Behaviour to know about

  • The planner does not load a model without a calibration, on Metal either.
    Metal nodes that relied on a pinned base need a calibration first
    (maintenance window or "Calibrate uncalibrated").
  • A model whose probe fails has no workaround: a pinned base no longer makes a
    model loadable.
  • A base override replaces the calibrated total. The help text of the
    "Base residency" field in the UI still says "for the weights"; it is not
    changed here.
  • After the migration, models with a stored label become calibration
    candidates.

Rollout

Update the workers before or together with the core.

  • A worker that is online during the core update and runs the old code labels a
    profile without source as cached again. On Dev with the first build of
    this PR, six cached rows came back this way. The orchestrator now stores
    only known sources, so this label no longer reaches the database. This is
    not yet verified on Dev.
  • Workers that report profiles in the pre-central format are ignored by the
    orchestrator (unchanged). Julia's Laptop on Dev is in this state.

Testing

  • Worker 1923 passed (4 test_model_cache.py rsync failures exist on main),
    orchestrator 4520 passed, Liquibase tests 26 passed.
  • Dev (hochbruegge, an earlier build of this PR): the migration cleared 9 of 14
    profiles, the 5 calibrated ones stayed unchanged. A live lane load changed
    loaded_vram_mb, kv_budget_mb and the counter, not the base and not the
    source. A newly connected model was calibrated, got src = calibrated, and its
    snapshot carries the base.
  • Not tested: a pinned-base calibration on a current Metal worker (the Dev
    laptop worker is outdated) and e2e tier 1 locally.
  • Stack, Benchmark and Browser (Playwright) failed while building the
    stack image (Maven Central HTTP 429), not in a test.

New dependencies

None.

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ PASS — Per-request forwarding overhead

Overhead p50 = 8,298.6 µs; p95 = 17,531.6 µs — goals: p50 < 10,000 µs, p95 < 30,000 µs; CI fail thresholds p50 15,000 µs / p95 150,000 µs.

Path p50 p95 samples
Logos (orchestrator → worker → back) 8,856.1 µs 18,242.7 µs 400
Direct baseline (same payload, keep-alive) 557.5 µs 711.1 µs 200

Top phases (per-request p50, share of the median request):

Phase p50 Share
pipeline.context 3,002.9 µs 27.7% ⚠️
context.resolve_db 2,946.7 µs 27.2% ⚠️
auth.parse_log 1,022.9 µs 9.4% ⚠️
auth.log_usage_insert 874.2 µs 8.1% ⚠️
pipeline.schedule 748.1 µs 6.9% ⚠️
schedule.score 498.6 µs 4.6%
schedule.infra 434.8 µs 4.0%
schedule.profiles 408.1 µs 3.8%
schedule.profiles.fetch 405.6 µs 3.7%
schedule.reserve 197.0 µs 1.8%

Scenario: logosnode provider, warm lane, no concurrent requests, non-streaming POST /v1/chat/completions. Overhead p50/p95 = matching percentile(Logos) − percentile(direct).

@Claudia-Anthropica Claudia-Anthropica 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.

@julia-rai I found three calibration issues: Metal memory can be underestimated, successful Metal probes remain calibration candidates, and base overrides can produce incomplete shared snapshots. Several CI checks are still running; no failures were captured. [nit] Please also remove the Logos scope prefix from the PR title.

Comment thread logos-workernode/config.example.mlx.yml Resolved
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ PASS: GPU-less residency simulation

GPU-simulated functional exercise of residency policies against the real orchestrator and worker with a fake vLLM below the worker. Times are not GPU performance. Synthetic only; no scientific claims.

SHA: c0ba26c9433e8304e8ba6280738258051813dffa · Run: workflow run

Per policy / pattern

Policy Pattern Submitted Completed Failures Missing models
demand burst 10 10 0 0
demand poisson 10 10 0 0
demand sequential 10 10 0 0
demand mixed 10 10 0 0
lru burst 10 10 0 0
lru poisson 10 10 0 0
lru sequential 10 10 0 0
lru mixed 10 10 0 0
simple burst 10 10 0 0
simple poisson 10 10 0 0
simple sequential 10 10 0 0
simple mixed 10 10 0 0

Lifecycle & VRAM

Policy Cold load Sleep Wake VRAM observations VRAM violations Verdict
demand 7 1 1 552 0 PASS
lru 6 1 1 372 0 PASS
simple 8 1 1 336 0 PASS

Synthetic performance (short CI run)

Latencies are simulated seconds: observed wall time multiplied by the reported factor. Prefill and concurrency contain explicit estimates. No GPU performance or energy claim.

Policy Pattern Seed Factor Completion TTFT p50/p95/p99 TTLT p50/p95/p99 Cold Sleep Wake 507 VRAM violations
demand burst 42 10 25/25 485.30/699.46/699.98 490.44/704.47/705.68 5 2 0 0 0
demand poisson 42 10 25/25 447.68/722.16/730.06 452.35/752.62/760.42 5 4 0 0 0
demand sequential 42 10 25/25 389.73/674.94/678.22 392.25/697.22/700.48 5 4 0 0 0
demand mixed 42 10 25/25 414.70/719.87/720.39 456.02/726.14/727.65 5 3 0 0 0
lru burst 42 10 25/25 373.76/703.17/703.26 378.84/757.53/765.22 5 4 1 0 0
lru poisson 42 10 25/25 449.91/740.65/748.52 454.65/771.10/778.95 5 6 0 0 0
lru sequential 42 10 25/25 390.98/694.63/697.81 393.50/716.81/720.04 5 5 0 0 0
lru mixed 42 10 25/25 346.50/679.00/679.26 351.34/683.71/683.83 5 1 0 0 0
simple burst 42 10 25/25 349.34/764.20/765.19 354.33/770.83/771.98 5 5 0 0 0
simple poisson 42 10 25/25 318.72/701.60/704.46 324.63/712.35/714.17 5 3 0 0 0
simple sequential 42 10 25/25 381.83/648.81/651.93 389.09/652.15/655.96 5 3 0 0 0
simple mixed 42 10 25/25 487.05/723.21/737.25 492.70/767.37/767.64 5 5 0 0 0

@Claudia-Anthropica Claudia-Anthropica 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.

@julia-rai Thanks for correcting the example sizing and retaining the measured footprint in shared snapshots. I found a local-restoration case I missed earlier that still needs a fix. Several CI checks are still running; no failures were captured.

@Claudia-Anthropica Claudia-Anthropica 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.

@julia-rai Thanks, the fresh-profile restoration case is fixed. I found an existing-profile case I missed earlier: removing an override can still restore an older footprint after recalibration. Stack (inter-node + client) failed, but the captured evidence only reports exit code 1, so I couldn't attribute it to this change. Browser, webservice and benchmark checks are still running.

@Claudia-Anthropica Claudia-Anthropica 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.

@julia-rai Thanks, restoring the latest measured footprint fixes the previous restart issue. [medium] I missed the CUDA configuration example earlier: logos-workernode/config.example.yml still tells operators to set base_residency_mb to weights excluding KV, but overrides now preserve calibrated, so both placement estimators treat that value as the total and under-reserve memory. Please update its inline capability instructions and manual-profile examples to require the full footprint including KV, as the Metal example now does. Several CI checks are still running; no failures were captured at this head.

@Claudia-Anthropica Claudia-Anthropica 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.

@julia-rai Thanks for updating the CUDA sizing instructions to include KV memory. The earlier calibration and restart issues are fixed, and I found no further blocking issues across the full diff. Several CI checks are still running; no failures were captured at this head.

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Gateway Concurrency Benchmark

Run at 2026-11-30T23:08:48+00:00 against http://localhost:18081.

Concurrency ramp

Peak gateway relay tasks simultaneously: 1024. Onset of failures (>5% of a step): not reached within the tested steps requests per step. Configured gateway I/O limits: unlimited, unlimited across 2 replica(s) = unlimited. Executor: virtual-per-task. Source: live gateway stats.

Step size Peak relayed OK Failed Truncated Fail rate TTFB p50 TTFB p95 Total p50
8 8 8 0 0 0.0% 61.0 ms 63.2 ms 1,863.4 ms
64 64 64 0 0 0.0% 268.2 ms 386.0 ms 2,146.9 ms
256 256 256 0 0 0.0% 1,134.9 ms 1,474.6 ms 3,945.4 ms
512 512 512 0 0 0.0% 4,025.7 ms 4,539.9 ms 8,816.5 ms
1024 1024 1024 0 0 0.0% 3,552.7 ms 6,219.0 ms 17,305.4 ms

Step size is how many requests were fired at once; peak relayed is how many StreamingResponseBody tasks the webservice replicas had open at the same moment, counted around the gateway relay task itself (sum of per-replica peaks). The fake upstream only pins each completion open until that peak is sampled — counting overlap there would over-count, because the gateway opens the upstream response before the executor task runs. ⚠️ marks a step that never became fully concurrent within the 30s hold budget — which is what reaching the ceiling looks like. Truncated counts 2xx streams that ended without the terminal SSE event; they are failures. Latencies here are measured under the barrier and include waiting for a held slot, so read them as behaviour under load, not as the gateway's latency — that is the added-latency section below.

Added latency (gateway vs. direct-to-upstream)

Overhead p50 = 12.0 ms, p95 = 17.7 ms (n=180 gateway / 180 direct).

Path p50 p95 p99
Via gateway 1,213.7 ms 1,220.3 ms 1,223.9 ms
Direct to fake upstream 1,201.7 ms 1,202.6 ms 1,202.9 ms

Failover under load

❌ killed 045ba4fec0b2 at t=10s into a 30s run with 32 concurrent streams. total=688, ok=664, connectivity failures=24 (connection error/timeout/5xx, incl. 0 truncated stream(s)), other failures=0, max latency=30,021.1 ms.

Sample errors: ['HTTP 504', "RemoteProtocolError('peer closed connection without sending complete message body (incomplete chunked read)')"]

Recovery: PASS. New requests must succeed after the fixed 5 s routing allowance. Interrupted streams still count above; this does not assert seamless stream failover.

Phase Requests OK Connectivity failures Other failures
after recovery 288 288 0 0
before kill 256 256 0 0
interrupted 32 16 16 0
routing update 112 104 8 0

Budget admission

Application key with a budget limit and a month of history (seed_budget.sql), 16 concurrent workers for 40 s (budget cache TTL 15 s, so the load spans at least one refresh). 530 requests, 0 failed, 0 HTTP 5xx. Time in Logos median = 3.1 ms ✅ median within the 5.0 ms threshold, p99 = 5.3 ms ✅ p99 within the 50.0 ms threshold.

Phase n p50 p95 p99 max
Idle baseline (sequential) 10 1,213.1 ms 1,267.2 ms 1,301.2 ms 1,309.7 ms
Under load 530 1,209.3 ms 1,211.9 ms 1,214.3 ms 1,224.5 ms
Time in Logos, per request of the load 530 3.1 ms 4.1 ms 5.3 ms 9.9 ms
… admission (auth, rate limit, budget, reservation) 530 0.9 ms 1.3 ms 2.2 ms 7.6 ms
… call (admission end to the provider call) 530 0.7 ms 1.0 ms 1.2 ms 2.3 ms
… tail (provider response to end of the response: delivery, settle) 530 1.5 ms 2.0 ms 2.6 ms 4.9 ms

Time in Logos is read back from each request's log_entry row: arrival at the controller to the end of the response, minus the provider window. It is the gateway's own cost without the fake upstream's fixed delay and without the hop through Traefik; the two phase rows above it include both.

Budget refresh query in the database (apiKeyBudgetUsage): before the load 107.2 ms, 0 unpriced rows; after 97.9 ms, 0 unpriced rows.

Latency by send time (5 s windows):

From Requests Failed p50 p95 max
0 s 67 0 1,209.9 ms 1,212.9 ms 1,224.5 ms
5 s 66 0 1,210.1 ms 1,212.3 ms 1,213.0 ms
10 s 66 0 1,209.9 ms 1,211.7 ms 1,214.4 ms
15 s 66 0 1,209.4 ms 1,212.9 ms 1,220.9 ms
20 s 66 0 1,208.8 ms 1,211.4 ms 1,216.3 ms
25 s 66 0 1,208.9 ms 1,211.3 ms 1,218.0 ms
30 s 66 0 1,209.0 ms 1,210.4 ms 1,211.6 ms
35 s 67 0 1,208.7 ms 1,210.4 ms 1,211.1 ms

A refresh that re-prices the key's month blocks every request of the key that misses the cache, so a slow refresh shows up as a window whose requests all finish late together, and as 5xx once the long queries hold the connections that authentication needs.

Status counts: {"200": 530}

Method

  • Upstream: fake_cloud_upstream.py, an OpenAI-shaped mock (streaming SSE + non-streaming), so the numbers above are the gateway's own overhead/limits, not a real cloud provider's throttling.
  • The concurrency and latency legs are informational. With LOGOS_BENCH_GW_FAILOVER_REQUIRE_RECOVERY=1, failover requires successful requests before the kill and after the fixed routing allowance, zero failures in those phases, and no other HTTP errors. Missing or skipped recovery measurements fail this gate. The budget-admission leg checks the median and p99 time in Logos against LOGOS_BENCH_GW_BUDGET_LOGOS_P50_MAX_MS and LOGOS_BENCH_GW_BUDGET_LOGOS_P99_MAX_MS; with LOGOS_BENCH_GW_BUDGET_FAIL_ON_THRESHOLD=1 a breach fails the run.
  • Env: {"database_storage": "tmpfs-ci-ephemeral", "gateway_url": "http://localhost:18081", "model": "bench-cloud-model", "upstream_url": "http://localhost:19100"}

@julia-rai julia-rai self-assigned this Nov 27, 2026

@Claudia-Anthropica Claudia-Anthropica 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.

@julia-rai The earlier calibration, sizing and restart fixes still hold after the merge, and I found no further blocking issues across the full diff. Several test, build and benchmark checks are still running; no failures were captured at this head.

@Claudia-Anthropica Claudia-Anthropica 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.

@julia-rai The earlier calibration, sizing and restart fixes still hold, and I found no blocking issues across the full diff. There's one non-blocking input-handling issue below. Several CI checks are still running; no failures were captured at this head.

@julia-rai julia-rai changed the title Logos: Clean up residency source Clean up residency source Nov 30, 2026
@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

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.

2 participants