Skip to content

Keep the SGLang radix cache for agentic runs on MI300X/MI355X - #123

Closed
zoroyihan7 wants to merge 1 commit into
AMD-AGI:mainfrom
zoroyihan7:agentic-keep-radix-cache
Closed

zoroyihan7 wants to merge 1 commit into
AMD-AGI:mainfrom
zoroyihan7:agentic-keep-radix-cache

Conversation

@zoroyihan7

Copy link
Copy Markdown

Motivation

sglang_mi300x.sh and sglang_mi355x.sh add --disable-radix-cache by default unless EXTRA_SGLANG_ARGS mentions it. That default suits fixed-length random-prompt runs, but agentic trace replay resends long shared prefixes. The AgentX traces have a theoretical prefix-cache hit rate of about 97% and inputs averaging about 143K tokens.

With the radix cache off, the server recomputes every prefix. We saw this on an AgentX trace replay on MI355X, where the launcher was booted as the server phase. The server log reported 0 cached tokens and TTFT p50 was about 68 s. A later run whose only real change was turning the radix cache back on reported about +210% output throughput and about +2300% on e2e_norm_intvty_p50. The baseline measured an unrepresentative server. The upstream InferenceX agentic recipes keep the prefix cache on.

Change

  • When IS_AGENTIC is 1 or true (case-insensitive), both launchers skip the --disable-radix-cache default. Magpie's AgentX mode and the InferenceX agentic scripts already use this variable.
  • Behaviour is unchanged when IS_AGENTIC is unset, empty or 0. --mem-fraction-static=0.8 is still added. An explicit EXTRA_SGLANG_ARGS still takes precedence.
  • New test test_sglang_agentic_runs_keep_radix_cache checks the server argv of both scripts for unset, 0, empty, 1, true and TRUE.

Verification

  • python -m pytest -q tests/test_client_tokenizer_mode.py: 97 passed, 76 skipped (the packaged-InferenceX cases skip below Python 3.12).
  • The new test fails on main's scripts in all 6 agentic cases and passes with this change.
  • ruff check / ruff format --check are clean on the touched test file. shellcheck reports no new warnings on the two scripts.
  • No GPU run is needed for this change: it only affects which arguments the launcher passes, and the tests check those arguments.

🤖 Generated with Claude Code

sglang_mi300x.sh and sglang_mi355x.sh append --disable-radix-cache unless
EXTRA_SGLANG_ARGS mentions it. Agentic trace replay resends long shared
prefixes (about 97% theoretical prefix hit on the AgentX traces), so a
radix-off baseline measures an unrepresentative server: TTFT is dominated
by recomputing ~100K-token prefixes, and any later run that simply turns
the cache back on looks like a large optimization.

When IS_AGENTIC is 1 or true (the variable Magpie's AgentX mode and the
InferenceX agentic recipes already use), skip the --disable-radix-cache
default. Fixed-length runs and explicit EXTRA_SGLANG_ARGS are unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: zoroyihan7 <Yihan.Wang@amd.com>
@zoroyihan7

Copy link
Copy Markdown
Author

Closing: per maintainer feedback, AgentX benchmarking and profiling will go through Magpie's native AgentX path (Hyperloom PR in flight), so this switch is not needed.

@zoroyihan7 zoroyihan7 closed this Oct 14, 2026
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.

1 participant