Benchmarking and Optimizing Inference on SWE-bench Pro with Qwen3.8-27B on AMD Instinct™ MI350X#
In agentic LLM workloads, the model is dropped into a task, given tools, and left to work: reading files, running commands, editing code, checking the result, and trying again. A task is not solved in one shot; it is solved over many turns of back-and-forth with the task environment. This is exactly the shape of a software-engineering benchmark like SWE-bench Pro, where “success” means an actual code change that makes a hidden test suite pass after churning over it for multiple turns.
In this post, we first walk through how to set up a multi-turn agentic inference loop using Harbor as the task orchestrator — this is the Architecture section. We then run an agentic RL workload with Qwen3.8 27B and Claude Code as the agentic harness on ScaleAI/SWE-bench_Pro and benchmark it; the Benchmark Results section reports the accuracy and efficiency metrics and details how we collect them from SGLang, which has no native agentic view of the workload. The rest of the post is a debugging story: the benchmark run surfaces a significant number of AgentTimeoutErrors caused by slow inference. A timeout can cut an agent off before it has a fair chance to finish the task, which distorts the benchmark. Tracking down their cause leads us, through metric collection instrumentation, to a critical prefix-cache bottleneck caused by our choice of agent; fixing it improves decode latency and, in turn, sharply cuts the timeouts.
Architecture: SGLang and Harbor on One Docker® Network#
Figure 1 is an illustrative diagram of our setup we will walk through in this blog. We keep the two concerns — serving the model and running the task — in separate containers, and let them talk over a private Docker network.
Figure 1. Inference architecture schematic with SGLang and Harbor.
SGLang (the serving engine) and Harbor (the task orchestrator) require their own dependencies and are launched in two separate containers. Each example from the dataset is called a task and Harbor’s job is to launch a separate container per task from the dataset to execute it. The task containers and SGLang communicate over the same Docker network. We describe each the role of each component here before giving the reproducible steps.
The model server. SGLang serves Qwen3.8-27B and exposes an Anthropic/OpenAI-compatible HTTP API. The container it is launched from is named sglang-server and joins a bridge network (in our deployment, sglang-harbor-network, 172.20.0.0/16), listening on port 30000.
Docker DNS. User-defined Docker networks come with their own DNS. Containers on the same network can reach each other by name without hard-coding IP addresses. Therefore, from your Harbor trial container on the same Docker network, http://sglang-server:30000 works: sglang-server resolves via Docker DNS, and HTTP rides on top of that resolved IP:port like any normal request.
The Harbor container is a Docker container with Python 3.12 and uv installed. Inside it, Harbor is cloned from harbor-framework/harbor.git and installed using uv sync. We launch the container as privileged and mount the host’s Docker socket so that Harbor can access the host’s dockerd and spawn task containers. SWE-Bench-Pro contains 731 tasks, each a curated bug fix or feature enhancement RL training example across multiple copyleft public repositories.
Reproduce the run#
1. Create the Docker network. docker network create <network-name>. We use sglang-harbor-network as the network name.
2. Launch the SGLang server. We pass the network name to the docker run command using --network sglang-harbor-network and launch the SGLang server at --port 30000. To enable it to listen on all incoming ports, we add --host 0.0.0.0. We mount the Hugging Face cache from a custom path where we downloaded Qwen/Qwen3.8-27B. On our AMD Instinct™ MI350X host it is launched roughly like this:
docker run -it --name sglang-server \
--network sglang-harbor-network \
--device /dev/kfd --device /dev/dri \
--group-add 44 --group-add 109 \
--security-opt seccomp=unconfined \
--ipc=host --shm-size=32g \
--ulimit stack=67108864 \
-v /data/hf_cache:/root/.cache/huggingface \
-e HF_HOME=/root/.cache/huggingface \
rocm/sgl-dev:miles-rocm720-mi35x-20260823 \
python3 -m sglang.launch_server \
--model-path Qwen/Qwen3.8-27B \
--served-model-name model \
--tp-size 8 \
--context-length 262144 \
--mem-fraction-static 0.7 \
--cuda-graph-max-bs 512 \
--tool-call-parser qwen3_coder \
--reasoning-parser qwen3 \
--host 0.0.0.0 --port 30000
3. Generate the tasks. From inside the Harbor container, we generate the SWE Bench Pro tasks from the HuggingFace format to Harbor compatible task format. Harbor has an built-in command to do this:
cd /harbor/adapters/swebenchpro
uv run --frozen --no-dev swebenchpro \
--all \
--task-dir /data/harbor_tasks \
--overwrite
4. Point the agent and run the job. Since we use the claude-code agent harness, it needs to know where to direct the LLM requests. The agent inside the Harbor task container is pointed at the model through ANTHROPIC_BASE_URL to the SGLang server on the docker network. The SWE-Bench-Pro benchmark is then run using the following command. Note we give the agent a total of 100 turns as the maximum:
uv run harbor job start \
-p /data/harbor_tasks -a claude-code -m model \
-n 64 \
--n-concurrent-agents 32 \
--override-memory-mb 32768 --override-cpus 4 \
--agent-timeout-multiplier 1.8 \
--ae ANTHROPIC_BASE_URL=http://sglang-server:30000 \
--ae ANTHROPIC_API_KEY=dummy \
--ae ENABLE_TOOL_SEARCH=false \
--agent-kwarg disallowed_tools=WebSearch,WebFetch \
--agent-kwarg reasoning_effort=medium \
--agent-kwarg max_turns=100 \
--jobs-dir <jobs_dir>
Benchmark Results#
For each of the 731 examples in the benchmark, Harbor grades the edits the LLM made via the agent and emits a binary reward. Task success on the benchmark is measured by the mean reward across all tasks. Notice here that we are disabling the agent from using its WebSearch and WebFetch tools to prevent the agent from looking up solutions online. We allow the agent to run for a maximum of 100 turns. Note also that we allow Harbor to spawn 64 task containers concurrently but cap the maximum number of agents to 32. Consequently, some tasks that are ready to run the agent enter a Harbor wait queue. This queue should not be confused with the SGLang request wait queue, which is negligible in our run thanks to continuous batching.
Table 1 reports the benchmark metrics for SWE-bench Pro with Qwen3.8-27B on 8 GPUs of AMD Instinct™ MI350X (TP=8), scored over 713 tasks (this is a dense model, so no EP):
Metric |
Value |
|---|---|
Mean reward (all tasks) |
68.9% |
End-to-end task latency |
mean: 57.8 minutes, p50: 55.9 minutes, p95: 91 minutes |
GPU residency per task (mean) |
53.9 minutes |
Generated Tokens per successful task (median) |
40,300 |
Turns / task (median) |
passed: 50, failed: 57 |
Tool calls / task (solved) |
For passing tasks: 61, Failing tasks: 68 |
Table 1. Benchmark metrics summary.
Note that the public SWE-bench Pro dataset has 731 tasks. In our run, 18 of them failed even before reaching the agent phase and were never scored. Every metric in the table above is reported over the 713 tasks that actually ran, except the mean reward: there we count the 18 un-run tasks as failures (reward = 0), so the mean reward is taken over all 731 tasks. We used reasoning_effort=medium with Claude Code.
The HuggingFace model card for Qwen3.8 27B reports a benchmark score of 61.7%. They mention correcting problematic tasks and report score on a refined benchmark but further details are not available. They also use Claude Code as the agentic harness and only mention a few sampling parameters and allowed context window.
Let us now take a closer look at a few metrics from Table 1.
GPU Residency#
Definition. GPU residency per task (also called GPU wall-clock time) is the total time a task’s requests spend on the GPU: SGLang scheduling queue (runs on CPU, negligible) + prefill + decode, summed over every request belonging to that task across all of its turns. We compute one such number per task and report the mean across all tasks in the table above.
A caveat on reading it: the prefill + decode part is batch-shared across ~29 concurrent requests at steady state, so residency is overlapped wall-clock, not exclusive GPU seconds. The included SGLang queue time is only 1.19% of request time (averaged across requests) — tiny, thanks to continuous batching.
Takeaway. Splitting GPU residency per task into prefill and decode (Table 2) shows that decode dominates inference on any given task, as expected.
SGLang Queue |
Prefill |
Decode |
|---|---|---|
1.19% |
4.10% |
94.71% |
Table 2. GPU residency split by phase.
End-to-End (E2E) Task Latency#
Definition. For any given task, the multi-turn loop (excluding environment setup and grading) combines the task’s GPU residency time and the bash-tool execution the agent runs. We define E2E task latency as the total wall-clock time for environment setup (sandbox spawn) + agent setup (claude code install) + agent execution (the multi-turn loop = LLM GPU execution + tool call execution) + verifier (testcase runtime for reward) + environment teardown (Harbor queue wait excluded). Table 1 reports the aggregate over all tasks. This is distinct from E2E SGLang request latency, which is per-request.
Takeaway. From the E2E split and the GPU-residency split, each task spends most of its time decoding tokens — making decode the prime mover for hardware-performance optimization. Figure 2 shows this breakdown as a mean across all tasks.

Figure 2. Mean End To End Latency split by Phase
Task Exceptions and Analysis#
We hit a few Task exceptions along the way and Table 3 summarizes each. Note that receiving an exception doesn’t mean reward=0 as the verifier can still run:
Exception |
Trials |
Unscored |
Scored |
Passed / Scored |
Error description |
|---|---|---|---|---|---|
(none) |
582 |
0 |
582 |
438 / 582 (75%) |
Ran cleanly to the verifier, no exception raised |
|
106 |
0 |
106 |
46 / 106 (43%) |
Agent hit the 90-min |
|
27 |
17 |
10 |
7 / 10 (70%) |
Agent process exited non-zero. 17 crashed at |
|
8 |
0 |
8 |
7 / 8 (88%) |
sglang/Anthropic endpoint returned a 429-style rate-limit mid-trajectory; run recovered, verifier scored |
|
3 |
0 |
3 |
3 / 3 (100%) |
Transient connection drop to the model endpoint; recovered, all passed |
|
3 |
0 |
3 |
2 / 3 (67%) |
Unclassified API error from the serving layer; non-fatal, scored |
|
1 |
0 |
1 |
1 / 1 (100%) |
Authentication failure to the API (dummy key / header issue); still reached a state the verifier could score |
|
1 |
1 |
0 |
0 / 0 (—) |
|
Table 3. Breakdown of all 731 trials by Harbor exception.
The biggest exception here is the AgentTimeoutError. This is fired when the multi-turn agentic loop runs for more than Harbor’s task timeout. The default timeout is 50 minutes. By passing --agent-timeout-multiplier 1.8 we gave each agent 90 minutes.
In this run, for 43% of the times the agent hit the timeout error, it still got a reward=1. This means it kept continuing even after solving the task.
Earlier, when we ran the benchmark with the default timeout, we observed 366 timeouts (out of which 41.5% scored a reward=1) ! So clearly allowing the agent to run for longer helped mitigate the error.
Analysis of Agent Timeouts#
We plotted a few distributions to identify where we can find anomalies that correspond to these timeouts. The idea was to report metrics for each task and see if the timed out tasks stand out.
First we plot the End-to-end latency distribution (Figure 3).

Figure 3. End-to-end task latency across scored tasks.
Had the distribution been, for example bi-modal we could have concluded that some trials are characterized by a bottleneck due to which they time out. But that is not the case here! The E2E latency curve is monotonic and almost linear, and timed-out tasks also have a higher average number of turns. The graph therefore supports the hypothesis that timeouts are a natural consequence of running longer, but offers no further insight.
We then ask the question: What if the timeouts aren’t supposed to take that long? We earlier saw that the End-To-End task latency was dominated by GPU residency. We next plot the Time To First Token (TTFT) and Time Per Output Token (TPOT) per-trial (Figure 4) to see if the long E2E task latency for the timeouts was a result of anomalous prefill or decode times.

Figure 4. TTFT and TPOT distribution across tasks.
Here TTFT per task (one vertical bar) is the mean of all the TTFT values across its turns in the trajectory. Each TPOT/task is the mean across all its generated tokens across all turns. The mean TTFT across all tasks is 3.13s and TPOT is 66.5ms. The AgentTimeoutErrors do not exhibit clustering here.
One thing is clear though. Reducing Decode time would help mitigate these errors since tasks would complete before the timeout ceiling. By the end of this blog, we shall achieve a low AgentTimeoutError count by speeding up decode. We shall show improvement in decode latency by fixing a low prefix cache hit rate resulting in a reduction of these timeout errors. We highlight an important metrics collection gap that we bridged for debugging in the next section.
Data Collection Methodology: The SGLang-Harbor Gap#
Our objective is to observe the inference engine under the full SWE-bench Pro load — latency, token economics, and cache behavior — at a granularity fine enough to reason about individual trials. Collection rests on three layers: a Prometheus endpoint giving aggregates, an on-disk per-request export carrying cached-token counts and timestamps, and thirdly, a custom trial identity stamped onto every request so the first two can be read per-task.
The first two layers are standard SGLang observability; the third exists to close a gap. By default, SGLang has no concept of a trial. The Prometheus histograms and gauges carry no request identity, and the per-request export keys each request only by rid, an opaque hash. So every signal is either a global aggregate or an anonymous per-request row — neither is meaningful for task-level analysis until we give the engine a trial identity to label by.
Instrumenting Per-Trial Collection#
The collection flags. The first two layers are turned on by four SGLang flags turn: --enable-metrics exposes the Prometheus aggregate endpoint; --export-metrics-to-file writes the on-disk per-request JSONL export; --enable-cache-report adds the per-request cached-token count to each response; and --enable-request-time-stats-logging adds per-request time stats (timestamps).
Tagging requests with a trial identity. The third layer bridges the serving engine and the task orchestrator by tagging every request at the source. On the Harbor side, a small patch to trial/trial.py stamps each trial’s unique identity onto every request the agent emits:
--- a/src/harbor/trial/trial.py
+++ b/src/harbor/trial/trial.py
@@ def _init_agent(self) -> None:
self.agent.session_id = f"{self.config.trial_name}__agent"
self.agent.context_id = self._id
+ self.agent._extra_env["ANTHROPIC_CUSTOM_HEADERS"] = (
+ 'X-Trial-Id: {"trial_id":"' + self.config.trial_name + '"}'
+ )
The trial/trial.py change above modifies Harbor, licensed under the Apache License 2.0.
The key is trial_name, which is unique per attempt (retries included). On the SGLang side the two tokenizer-metrics flags complete the path: --tokenizer-metrics-custom-labels-header X-Trial-Id makes the engine read that header, and --tokenizer-metrics-allowed-custom-labels trial_id admits the parsed trial_id key. The engine scrape thereby becomes per-trial.
Result: a per-trial view by joining with Harbor outputs. With trial_id now present on every per-request metric and the Prometheus aggregates, and the JSONL export supplying exact token counts and timestamps, we join the engine-side, trial-labelled metrics against Harbor’s own trial outputs (trial_name → task, final status, exception/timeout, turn boundaries) to get a per-trial view of the run.
Cache Hit Rate Analysis#
Issue: With a per-trial view, we notice that the median prefix_cache_hit_rate, a Prometheus per trial multi-turn aggregate is suspiciously low at median 0.251 and mean 0.286 across tasks. In the multi-turn conversation we expect that as the turns increase, cache hit rate is fairly high since at every new turn the model is given the entire trajectory until that turn as the prompt.
Understanding the cache: The model that we are serving is a Qwen3.8 27B which has 16 attention layers which have a KV cache and 48 Gated DeltaNet (Mamba) layers with a separate Mamba cache. Using the --mem-fraction-static flag, we allocate static VRAM for SGLang. The effective static memory fraction we used is 0.595. On the AMD Instinct™ MI350X node with TP=8 , we allocated 71.86 GB for the KV Cache and 64.68 GiB for Mamba Cache per rank. We use BF16 data type so the maximum number of tokens accommodated in the KV Cache is 4,709,608.
What is prefix_cache_hit_rate: Now a matching prefix length is measured as the intersection of the length cached by both kinds of layers:
cached_tokens = min( attention-KV matched tokens, floor(mamba matched tokens / mamba_cache_chunk_size) × mamba_cache_chunk_size ) and prefix_cache_hit_rate = cached_tokens/input_len.
What the prefix_cache_hit_rate means:
Since the Prometheus gauge prefix_cache_hit_rate is a mean across all turns of a trial, turn level analysis is made possible by
the SGLang request export JSONL. We can pose a few questions here: Did prefix matching break at a turn along the way through the trial for some reason that brought down the average? Or was it consistently lower? Or worse, did the prompt’s input length not grow i.e. the multi-turn loop was broken?
To answer these, we show a scatter-plot of prefix_cache_hit_rate vs input_len i.e. for a given input prompt length, how much of it is cached? We also color code each point by its turn number (Figure 5):

Figure 5. Prefix Cache hit rate versus input length, colored by turn number.
For most of the trials, we can see that as the input prompt length increases, the turn number increases, meaning that prompt length growth is as expected. But we see an interesting anomaly: the scatter points roughly follow a constant/x shape indicated by the orange line. This would happen if the cached token length was constant at ~15K but the input length is increasing (the x here). This establishes that the low cache hit rate is not mid-trajectory event driven but systemic across the entire trajectory.
One possible explanation, albeit as it turns out to be a far-fetched one, is that for this is that due to prefix cache contention, each turn’s cache is being evicted between turns. To see cache usage across time, we plot Figure 6, which shows the combined cache usage as well as the KV + Mamba split:

Figure 6. Combined cache occupancy and the KV plus Mamba split over the run.
We see that the active cache is nowhere close to the ceiling and additionally, there are no in-flight retractions. That rules out eviction due to cache contention as a cause.Claude-Code as the Source of Prefix Divergence#
Another strong hypothesis for the poor prefix cache hit rate is that the prefix cache is diverging after ~15K tokens. (To reproduce this, enable --log-requests, --log-requests-level 3, and --log-requests-format json so SGLang logs the raw tokens it sees in each request.) Since we have trial tagging available per SGLang request, we can sort the requests by timestamp to reconstruct the full per-trial trajectory.
Such a reconstruction reveals that the prefix-cache is diverging after Claude’s system prompt because it is injecting a live token budget reminder every turn! Figure 7 shows these injected reminder lines.

Figure 7. Token-budget reminder lines injected into the system prompt.
Claude Code builds and attaches its own system prompt. Before each request hits SGLang’s /v1/messages, Claude Code places one large system prompt — its agent
instructions plus the full <tools> definitions — as a single stable block at the very start. This base prompt (tools + prose, ~52K chars) is byte-identical on every turn of a trial. The conversation grows append-only after it (assistant replies + tool results).
The feature adding the growing counters: totalTokensReminder. This is a stock Claude Code feature. Each turn it injects a <total_tokens>N tokens left</total_tokens>
line — a token-budget counter, not a clock timestamp — emitted as a small role:“system” reminder message. Because this model uses the Qwen3.5 template which forbids non-leading system messages, SGLang’s Anthropic adapter merges every role:“system” message into the one front system block. So these reminders pile up at the tail of the system prompt, and
the stack grows +1 line (~50 chars ≈ 13 tokens) per turn (2 → 26 over 25 turns). In padded-countdown mode the value = 15,000,000 − (prev turn’s input+output tokens), so
it also changes each turn. That growing, changing block sits ahead of all conversation history, which is what pins cached_input_len at ~14.7K and forces re-prefill of the whole history every turn.
Fixing the Cache Hit Rate and Performance Comparison#
The fix for this issue is simple: Turn off this budgeting with --ae CLAUDE_CODE_TOTAL_TOKENS_REMINDER=off in the Harbor run.
With this fix hardware performance of the benchmark drastically improved as indicated by Figure 8:

Figure 8. Performance comparison before and after disabling the token-budget reminder.
With the feature disabled, the benchmark we ran scored only 568 of the tasks and others failed largely due to the infrastructure issues in container bring-up, unrelated to the agent. All other parameters between both runs remain the same.We see a dramatic improvement in prefix-cache hit rate now averaging to 94% over trials from 28.6%. Having a high prefix cache rate over turns improves the TTFT and we see the mean TTFT across all turns of all tasks improve from 3.132s down to 0.566s. Here is the bonus of our fix: The per-request End-To-End wall-clock time improved from 61.53s down to 27.64s, an improvement of 55.1%. We saw that E2E request latency is dominated by decode with prefill contributing to an average of 4.10% of the time. So If E2E latency improved, decode latency should have improved and we see from Figure 8 that it did with our fix: TPOT improved from an average of 0.0665 seconds/token to 0.0318 seconds/token resulting in a Request throughput improvement from 15.22 tokens/second to 31.81 tokens/second.
AgentTimeoutError impact: With an improved decode latency, trials complete faster. The fix for the prefix cache hit rate fix had a dramatic reduction of AgentTimeoutErrors down to 2 at the same timeout ceiling!
How Prefills Stall Decodes in This Workload#
The question remains: why did fixing prefix cache hit rate, a prefill metric affecting only 4.10% to the e2e wall clock time on average improve TPOT ? We hypothesize that the answer lies in the fact that the SGLang server is overloaded with concurrent prefill and decode requests. In this agentic workload we have ~29 concurrent agents talking to the server in a multi-turn loop where the start of each turn submits its new prefill request . Prefill requests are compute bound and decodes are memory bound. In this run, they don’t just delay decodes, they stall them completely. We ran the SGLang server runs with chunked prefill enabled by chunked_prefill_size 16384 but it doesn’t have --enable-mixed-chunk due to which when a prefill chunk is pending, it runs a prefill-only step (up to 16K tokens across TP8), during which every in-flight decode stream is stalled and emits no token. Therefore, it is very likely that a decoding request’s inter-token gaps absorb the wall-time of interleaved prefill chunk steps.
Summary#
In this blog post, we discussed in detail the setup for a multi-turn agentic inference run using Harbor as the task orchestrator, SGLang as the inference engine and Claude Code as the agentic harness. We benchmarked Qwen3.8 27B on the Swe-Bench-Pro dataset and obtained a mean reward of 68.9%. We observed AgentTimeoutErrors and to debug these, we first enabled a per-task view in SGLang to collect metrics. This view revealed a low prefix cache hit rate and we walked through a debug to identify that our harness, Claude Code, is the reason for a prefix cache divergence. We then fixed that by disabling the totalTokensReminder feature and report massive timing gains resulting in a dramatic reduction of the timeouts. That completes the deep dive from setting up and benchmarking an agentic RL inference run and improving caching and timing performance. Looking ahead, the team is committed to optimizing the full agentic RL loop, which includes training and inference.
Additional Resources#
Harbor — the task orchestrator used to spawn, run and grade each task container.
SGLang — the inference serving engine used to serve the model.
ScaleAI/SWE-bench_Pro — the benchmark dataset of 731 software-engineering tasks.
Qwen/Qwen3.8-27B — the model card for the model benchmarked in this blog.
Training SWE agents with Miles on MI355X — related work covering the training side of the agentic RL loop.
Disclaimers#
The information presented in this document is for informational purposes only and may contain technical inaccuracies, omissions, and typographical errors. The information contained herein is subject to change and may be rendered inaccurate for many reasons, including but not limited to product and roadmap changes, component and motherboard version changes, new model and/or product releases, product differences between differing manufacturers, software changes, BIOS flashes, firmware upgrades, or the like. Any computer system has risks of security vulnerabilities that cannot be completely prevented or mitigated. AMD assumes no obligation to update or otherwise correct or revise this information.
However, AMD reserves the right to revise this information and to make changes from time to time to the content hereof without obligation of AMD to notify any person of such revisions or changes.
THIS INFORMATION IS PROVIDED ‘AS IS.” AMD MAKES NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE CONTENTS HEREOF AND ASSUMES NO RESPONSIBILITY FOR ANY INACCURACIES, ERRORS, OR OMISSIONS THAT MAY APPEAR IN THIS INFORMATION. AMD SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR ANY PARTICULAR PURPOSE. IN NO EVENT WILL AMD BE LIABLE TO ANY PERSON FOR ANY RELIANCE, DIRECT, INDIRECT, SPECIAL, OR OTHER CONSEQUENTIAL DAMAGES ARISING FROM THE USE OF ANY INFORMATION CONTAINED HEREIN, EVEN IF AMD IS EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
AMD, the AMD Arrow logo, AMD Instinct, and combinations thereof are trademarks of Advanced Micro Devices, Inc. Other product names used in this publication are for identification purposes only and may be trademarks of their respective companies. Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc.
© 2026 Advanced Micro Devices, Inc. All rights reserved.