Skip to content

tune(moa): tighten first_answer_grace from 6s to 3s - #626

Closed
michaelneale wants to merge 2 commits into
mainfrom
micn/moa-grace-tighter-default
Closed

tune(moa): tighten first_answer_grace from 6s to 3s#626
michaelneale wants to merge 2 commits into
mainfrom
micn/moa-grace-tighter-default

Conversation

@michaelneale

Copy link
Copy Markdown
Collaborator

What it does

Lowers the chat-mode first_answer_grace default from 6 seconds to 3 seconds. This is a one-line tuning change. Built on top of #624 (which makes grace fire on diverse fast answers \u2014 needed for the chat case where workers don't textually agree).

Why now

On the public mesh today (5 workers including studio MiniMax, mini Qwen3.5, etc.):

  • MoA consensus rarely fires for short chat answers \u2014 workers respond with diverse short text like "Hello" / "Yes" / "Ready" / "Okay" that don't textually match.
  • PR fix(moa): grace fires on diverse fast answers, not just sole answer #624's diverse-answer grace catches this case: when grace expires with \u22651 qualifying answer, pick the highest-confidence one.
  • But the 6s grace becomes the chat latency floor \u2014 every turn pays the full 6s.

With #624 landed and the timer being the dominant chat path, 3s gives 2\u00d7 better p50 with no measurable quality regression on short chat prompts.

Lab data, public mesh, 10 varied turns

Prompt type Result
"Symbol for gold?" 2x: "Au, from Latin aurum\u2026" \u2705
"WW2 end?" 2x: "1945" \u2705
"Coffee shop name?" "Brewed" / "Perk" \u2705
"60mph \u00d7 2h?" 2x: "120" \u2705
"5-word rain sentence" "Rain drums gently on the roof" / "Rain pours down in relentless sheets" \u2014 reasonable but 6 words not 5 (same loose constraint behavior the model has at 6s grace too)

Latency distribution:

grace min p50 max n
6s (current) 700ms ~6000ms 6000ms 5
3s (proposed) 1299ms 2002ms 2007ms 10

Trade-off

A worker that takes 3\u20136s to land is now excluded from consensus. On the public mesh post-#624 we found textual consensus rarely fires for chat anyway, so this isn't losing a path that was actually firing.

For agentic / tool turns (has_tools=true), grace is bypassed entirely and consensus continues to work as before. The 3s number is chat-only.

Compat

  • No API change. The default value moves, callers that explicitly build a GatewayConfig keep their configured value.
  • No protocol / ABI / plugin change.
  • No mesh-version compatibility concerns.

Tests

cargo test -p mesh-llm-host-runtime --lib: 1463 pass.
cargo clippy --all-targets -- -D warnings: clean.
cargo fmt --all -- --check: clean.

The grace eligibility logic itself (which determines when the timer arms) is covered by PR #624's tests. This PR is strictly a config tuning, no behavior-shape change.

Open question

3s is empirical. A more conservative tuning would be 4-5s. A more aggressive one would be 2s (tested in lab, all 10 turns sub-2.5s but tight enough that any worker with 2s+ network latency is excluded). Happy to land at any number you prefer.

Empirical default tuning based on public-mesh lab data.

Setup: 3-node + public-mesh client, MoA fans out to 4-5 workers,
including studio MiniMax (~1s), mini Qwen3.5 (~700ms), and assorted
public-mesh peers.

Before (6s grace, PR #624 diverse-answer landed):
  median mesh_chat ~6.0s (5/5 runs hit grace ceiling)

After (3s grace):
  median mesh_chat ~2.0s (lab data: 10/10 turns sub-2.1s)

Quality: across factual / arithmetic / subjective / creative-short
prompts in the lab, all 10 turns returned correct or reasonable
answers. The 1 turn that was technically loose ("write a 5-word
sentence about rain" returned a 6-word sentence) is consistent with
MoA's general short-creative-constraint behavior, not a new failure
mode introduced by tighter grace.

Trade-off being made: a worker that takes 3-6s to land is now
excluded from consensus. On the public mesh post-PR #624 we found
consensus rarely fires anyway (textually-identical short answers are
rare); we fall through to grace's highest-confidence picker. So the
3s ceiling is effectively the floor for chat latency, not the
midpoint of a consensus distribution.

Other change: zero. Backwards compatible \u2014 callers that explicitly
build a  (tests, custom integrations) keep their
configured value.
Copilot AI review requested due to automatic review settings May 21, 2026 22:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the MoA gateway’s chat-mode timeout tuning by reducing the first_answer_grace default, aiming to improve perceived chat latency by allowing earlier exit when grace conditions are met.

Changes:

  • Reduced first_answer_grace default from 6s to 3s in the MoA gateway config.
  • Added a lab TODO note capturing post-#624 measurement takeaways / next steps.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
MIC_LAB_TODO.md Adds a short lab strategy/todo note related to grace behavior and streaming ideas.
crates/mesh-llm-host-runtime/src/network/openai/moa_gateway.rs Lowers the default first_answer_grace duration and expands the rationale comment.
Comments suppressed due to low confidence (1)

crates/mesh-llm-host-runtime/src/network/openai/moa_gateway.rs:307

  • PR description and this comment block assume the “diverse fast answers” grace behavior from PR #624, but that logic does not appear to be present in this branch (no matching grace tests, and gather_workers_incremental still requires answers.len() == 1). With the current sole-answer grace, tightening this timer may not address the stated chat latency floor. Either include the prerequisite #624 behavioral change in this PR/stack, or adjust the PR description + rationale comments accordingly.
        // 3 seconds: empirically good across the public mesh. Long
        // enough that slow-but-good workers (e.g. studio MiniMax
        // landing at ~1s, mini Qwen3.5 at ~700ms) finish before the
        // timer; short enough that the chat UI feels responsive
        // instead of sitting on the 6s ceiling. Lab data: median
        // mesh_chat dropped from ~6s to ~2s after this change with no
        // measurable quality regression on factual, arithmetic, and
        // short-creative prompts.
        first_answer_grace: std::time::Duration::from_secs(3),

hedge_delay: std::time::Duration::from_secs(5),
// Chat-only sole-answer grace. Tool turns ignore this.
first_answer_grace: std::time::Duration::from_secs(6),
// Chat-only grace: after this long since dispatch, if at least
Comment thread MIC_LAB_TODO.md
Comment on lines +4 to +6
* **Chat path is now grace-bounded.** `mesh_chat` p50 floor on the public
mesh is ~6s = the `first_answer_grace` config. To make chat feel
faster, lower the grace (1.5-2s), trade off: more likely to take a
@michaelneale

Copy link
Copy Markdown
Collaborator Author

Rolled into #624 \u2014 the eligibility relaxation and the tighter default are the same user-journey change and only meaningful together. Easier to review as one PR.

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