GPT-6 Astra · Serving

S04 · SLO

Valid

Online SLO goodput 1dev · Implementation Optimization

1.09×PERFORMANCE RATIO
261TOOL EVENTS
1TEXT PATCHES
0BINARY NAMES

01 / PROCESS MAP

Tool activity

Each row shows one agent’s tool events in its own recorded order. Colors show broad activities; bar widths do not represent duration.

Main agentGPT-6 Astra · 261 visible calls

InspectEditValidateExecuteBuildProfileRollbackOther
170Inspect
11Edit
37Validate
12Execute
2Profile
29Other

02 / EVENT SEQUENCE

Event timeline

Requests are grouped by agent, activity and topic. Delegations open into child branches. Summaries describe visible requests; tool errors and missing responses are flagged. A recorded response does not establish command success or a performance improvement.

Show event timelineHide event timeline195 groups · 261 calls

Scroll within this panel to view all events. Command sketches retain familiar programs and options. Values become <val> or <n>; paths, addresses and script bodies are hidden as <path>, <url> and <script>.

Main agent

  1. Inspect · Task requirements

    Requested file and log inspection, workspace inspection and source searches related to task requirements.

    2 calls · #0001–#0002

    printf <val> <val>cat <path>pwdrg --files -g <val> -g <path> -g <path> -g <path> -g <path> <args>
  2. Inspect · Source & workspace

    Requested repository inspection related to source & workspace.

    1 call · #0003–#0003

    git status --short
  3. Inspect · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    1 call · #0004–#0004

    cat <path> <path> <path> <path> <path>
  4. Inspect · Task requirements

    Requested file and log inspection related to task requirements.

    1 call · #0005–#0005

    cat <path> <path> <path> <path>
  5. Inspect · Batching & scheduling

    Requested source searches related to batching & scheduling.

    1 call · #0006–#0006

    <command> <args>rg --files <path>rg <val>
  6. Inspect · Task requirements

    Requested file and log inspection and source searches related to task requirements.

    1 call · #0007–#0007

    cat <path>rg --files <path>cat <path> <path> <path>
  7. Inspect · Benchmark & validation setup

    Requested source searches related to benchmark & validation setup.

    1 call · #0008–#0008

    rg -n <val> <path>
  8. Validate · Attention kernels

    Requested script or workload execution and source searches related to attention kernels.

    1 call · #0009–#0009

    python3 - <script>rg -n <val> <path> <path> <path>
  9. Other · Source & workspace

    1 tool error

    Requested script or workload execution related to source & workspace.

    1 call · #0010–#0010

    bash <script>
  10. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0011–#0011

    sed -n <val> <path>
  11. Validate · Task requirements

    Requested script or workload execution related to task requirements.

    1 call · #0012–#0012

    python3 - <script>
  12. Inspect · Source & workspace

    Requested environment setup or inspection and file and log inspection related to source & workspace.

    2 calls · #0013–#0014

    env <vars> bash <script> > <path>cat <path>sed -n <val> <path>
  13. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0015–#0015

    sed -n <val> <path>
  14. Inspect · Source & workspace

    Requested source searches and file and log inspection related to source & workspace.

    1 call · #0016–#0016

    rg -n <val> <path>sed -n <val> <path>cat <val>
  15. Inspect · Attention kernels

    Requested file and log inspection and source searches related to attention kernels.

    2 calls · #0017–#0018

    sed -n <val> <path>rg -n <val> <path> <path> <path> <path>tail -n <n> <path>rg --files <val>rg <val>head -n <n>
  16. Inspect · Benchmark & validation setup

    Requested file and log inspection, runtime inspection and source searches related to benchmark & validation setup.

    1 call · #0019–#0019

    tail -n <n> <path>cat <path>ps <flag> <args>rg <val>head -n <n>
  17. Inspect · Source & workspace

    1 tool error

    Requested file and log inspection and source searches related to source & workspace.

    2 calls · #0020–#0021

    sed -n <val> <path>cat <path>rg -n <val> <path> <path>
  18. Inspect · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    1 call · #0022–#0022

    tail -n <n> <path>cat <path>sed -n <val> <path>
  19. Inspect · Device memory

    Requested source searches and file and log inspection related to device memory.

    1 call · #0023–#0023

    rg -n <val> <path> <path> <path>head -n <n>rg -n <val> <path>
  20. Inspect · Attention kernels

    Requested file and log inspection and source searches related to attention kernels.

    2 calls · #0024–#0025

    cat <path>sed -n <val> <path>rg -n <val> <path> <path>
  21. Inspect · Benchmark & validation setup

    Requested file and log inspection and source searches related to benchmark & validation setup.

    1 call · #0026–#0026

    tail -n <n> <path>cut -c <val>rg --files <path>rg <val>head -n <n>sed -n <val> <path>
  22. Inspect · Attention kernels

    1 tool error

    Requested file and log inspection and source searches related to attention kernels.

    1 call · #0027–#0027

    sed -n <val> <path>rg --files <path>rg -n <val> <path> <path>
  23. Inspect · Batching & scheduling

    Requested file and log inspection and source searches related to batching & scheduling.

    1 call · #0028–#0028

    tail -n <n> <path>cut -c <val>rg -n <val> <path> <path>head -n <n>sed -n <val> <path>
  24. Validate · Benchmark & validation setup

    Requested file and log inspection, workspace inspection and runtime inspection related to benchmark & validation setup.

    1 call · #0029–#0029

    tail -n <n> <path>cut -c <val>ls -l <path> <n> > <path>ps <flag> <args>rg <val>head -n <n>
  25. Inspect · Batching & scheduling

    Requested file and log inspection and source searches related to batching & scheduling.

    1 call · #0030–#0030

    sed -n <val> <path>rg -n <val> <path>
  26. Inspect · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    1 call · #0031–#0031

    tail -n <n> <path>cut -c <val>cat <path>tail -c <n>
  27. Inspect · Source & workspace

    1 tool error

    Requested source searches and file and log inspection related to source & workspace.

    1 call · #0032–#0032

    rg -n <val> <path> <path> <path> <path> <path>head -n <n>cat <path>rg -n <val> <path>
  28. Validate · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0033–#0033

    env <vars> bash <script> > <path> <n> >& <path>
  29. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0034–#0034

    sed -n <val> <path>
  30. Inspect · Benchmark & validation setup

    Requested file and log inspection and source searches related to benchmark & validation setup.

    1 call · #0035–#0035

    tail -n <n> <path>tr <val> <val>tail -n <n>rg --files <val>head -n <n>
  31. Validate · Benchmark & validation setup

    Requested file and log inspection and script or workload execution related to benchmark & validation setup.

    1 call · #0036–#0036

    tail -n <n> <path>cut -c <val>python3 - <script>
  32. Profile · Task requirements

    Requested file and log inspection and environment setup or inspection related to task requirements.

    1 call · #0037–#0037

    cat > <path> <script>env <vars> python3 <script> <val> > <path> <n> >& <path>
  33. Inspect · Device memory

    Requested source searches and file and log inspection related to device memory.

    1 call · #0038–#0038

    rg -n <val> <path>tail -n <n>cat <path>head -n <n>rg -n <val> <path> <path> <path>
  34. Validate · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    1 call · #0039–#0039

    tail -n <n> <path>cut -c <val><command> <args>
  35. Inspect · Source & workspace

    Requested file and log inspection and source searches related to source & workspace.

    1 call · #0040–#0040

    sed -n <val> <path>rg -n <val> <path>
  36. Inspect · Attention kernels

    Requested file and log inspection and source searches related to attention kernels.

    1 call · #0041–#0041

    tail -n <n> <path>cut -c <val>rg -n <val> <path>
  37. Validate · Device memory

    Requested script or workload execution, source searches and file and log inspection related to device memory.

    1 call · #0042–#0042

    python3 - <script>rg -n <val> <val> <path> <path> -g <path>head -n <n>
  38. Inspect · Device memory

    Requested file and log inspection and source searches related to device memory.

    1 call · #0043–#0043

    sed -n <val> <path>rg -n <val> <path>tail -n <n>rg --files <path>head -n <n>
  39. Execute · Benchmark & validation setup

    Requested file and log inspection and script or workload execution related to benchmark & validation setup.

    1 call · #0044–#0044

    tail -n <n> <path>cut -c <val>cat <path>tail -c <n>python3 - <script>
  40. Inspect · Source & workspace

    Requested file and log inspection and source searches related to source & workspace.

    1 call · #0045–#0045

    tail -n <n> <path>cut -c <val>rg -n <val> <path>tail -n <n>
  41. Inspect · Device memory

    Requested source searches and file and log inspection related to device memory.

    1 call · #0046–#0046

    rg -n <val> <path>sed -n <val> <path>rg --files <path>head -n <n>
  42. Inspect · Source & workspace

    Requested file and log inspection, source searches and runtime inspection related to source & workspace.

    2 calls · #0047–#0048

    sed -n <val> <path>rg -n <val> <path> <path>head -n <n>tail -n <n> <path>cut -c <val>ps <flag> <args>
    2 more command sketches
    rg <val>tail -n <n>
  43. Edit · Attention kernels

    Requested code edits related to attention kernels.

    1 call · #0049–#0049

    Apply patch <patch>
  44. Inspect · Device memory

    Requested file and log inspection and source searches related to device memory.

    1 call · #0050–#0050

    cat <path>sed -n <val> <path>rg --files <path>head -n <n>
  45. Inspect · Source & workspace

    Requested file and log inspection and source searches related to source & workspace.

    1 call · #0051–#0051

    tail -n <n> <path>cut -c <val>rg --files <val>rg <val>head -n <n>
  46. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0052–#0052

    Apply patch <patch>
  47. Inspect · Source & workspace

    Requested file and log inspection and source searches related to source & workspace.

    1 call · #0053–#0053

    tail -n <n> <path>cut -c <val>rg --files <val>rg <val>
  48. Inspect · Device memory

    Requested repository inspection, source searches and file and log inspection related to device memory.

    1 call · #0054–#0054

    git diff --statgit diff --checkrg -n <val> <path>head -n <n>sed -n <val> <path>
  49. Inspect · Batching & scheduling

    Requested source searches and file and log inspection related to batching & scheduling.

    1 call · #0055–#0055

    rg -n <val> <path>tail -n <n>sed -n <val> <path>head -n <n>
  50. Inspect · Source & workspace

    1 tool error

    Requested file and log inspection, workspace inspection and source searches related to source & workspace.

    1 call · #0056–#0056

    command -v <val>cat <path>tail -n <n>ls -l <path>rg --files <path>rg <val>
  51. Validate · Source & workspace

    Requested environment setup or inspection related to source & workspace.

    1 call · #0057–#0057

    env <vars> python3 -m <module> <val> > <path> <n> >& <path>
  52. Other · Latency & request handling

    Requested script or workload execution related to latency & request handling.

    1 call · #0058–#0058

    python3 - <script>
  53. Other · Batching & scheduling

    Requested script or workload execution and file and log inspection related to batching & scheduling.

    3 calls · #0059–#0061

    <command> <args>python3 - <script>tail -n <n> <path>cut -c <val>
  54. Validate · Attention kernels

    Requested environment setup or inspection related to attention kernels.

    1 call · #0062–#0062

    env <vars> python3 -m <module> -q <script> <script> > <path> <n> >& <path>
  55. Inspect · Attention kernels

    Requested source searches and file and log inspection related to attention kernels.

    1 call · #0063–#0063

    rg -n <val> <path>sed -n <val> <path>
  56. Inspect · Latency & request handling

    Requested file and log inspection and script or workload execution related to latency & request handling.

    1 call · #0064–#0064

    tail -n <n> <path>python3 - <script>
  57. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0065–#0065

    tail -n <n> <path>cut -c <val>cat <path> <n> > <path>tail -c <n>cat <path>tail -n <n>
  58. Inspect · Attention kernels

    Requested source searches and file and log inspection related to attention kernels.

    1 call · #0066–#0066

    rg --files <path>rg -n <val> <path>head -n <n>
  59. Validate · Attention kernels

    Requested script or workload execution, file and log inspection and source searches related to attention kernels.

    1 call · #0067–#0067

    python3 - <script>sed -n <val> <path>rg -n <val> <path>
  60. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0068–#0068

    sed -n <val> <path>
  61. Other · Latency & request handling

    Requested script or workload execution and file and log inspection related to latency & request handling.

    1 call · #0069–#0069

    python3 - <script>tail -n <n> <path>cut -c <val>
  62. Inspect · Source & workspace

    Requested file and log inspection and source searches related to source & workspace.

    1 call · #0070–#0070

    cat <path>sed -n <val> <path>rg -n <val> <path>head
  63. Execute · Latency & request handling

    Requested file and log inspection and script or workload execution related to latency & request handling.

    1 call · #0071–#0071

    tail -n <n> <path>cut -c <val>python3 - <script>
  64. Other · Batching & scheduling

    Requested script or workload execution, repository inspection and file and log inspection related to batching & scheduling.

    1 call · #0072–#0072

    python3 - <script>git status --shortsed -n <val> <path>
  65. Inspect · Attention kernels

    Requested source searches and file and log inspection related to attention kernels.

    1 call · #0073–#0073

    rg -n <val> <path> <path>head -n <n>sed -n <val> <path>rg -n <val> <path>tail -n <n>
  66. Execute · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    1 call · #0074–#0074

    tail -n <n> <path>cut -c <val><command> <args>
  67. Validate · Task requirements

    Requested workspace file updates and environment setup or inspection related to task requirements.

    1 call · #0075–#0075

    cp <path> <path>env <vars> bash <script> > <path> <n> >& <path>
  68. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0076–#0076

    cat > <path> <script>
  69. Inspect · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    1 call · #0077–#0077

    tail -n <n> <path>cut -c <val>sed -n <val> <path>
  70. Validate · Benchmark & validation setup

    Requested file and log inspection and script or workload execution related to benchmark & validation setup.

    1 call · #0078–#0078

    tail -n <n> <path>cut -c <val>cat <path>tail -c <n>python3 - <script>
  71. Validate · Latency & request handling

    Requested file and log inspection and script or workload execution related to latency & request handling.

    1 call · #0079–#0079

    tail -n <n> <path>cut -c <val>python3 - <script>
  72. Validate · Task requirements

    Requested workspace file updates, script or workload execution and environment setup or inspection related to task requirements.

    1 call · #0080–#0080

    mkdir -p <path>python3 - <script>env <vars> python3 <script> <val> > <path> <n> >& <path>
  73. Validate · Benchmark & validation setup

    Requested file and log inspection and script or workload execution related to benchmark & validation setup.

    1 call · #0081–#0081

    tail -n <n> <path>cut -c <val>cat <path>tail -c <n>python3 - <script>
  74. Inspect · Source & workspace

    Requested file and log inspection and script or workload execution related to source & workspace.

    2 calls · #0082–#0083

    tail -n <n> <path>cut -c <val>python3 - <script>
  75. Validate · Benchmark & validation setup

    Requested workspace file updates and environment setup or inspection related to benchmark & validation setup.

    1 call · #0084–#0084

    cp <path> <path>env <vars> python3 <script> > <path> <n> >& <path>
  76. Inspect · Source & workspace

    Requested file and log inspection and workspace inspection related to source & workspace.

    2 calls · #0085–#0086

    tail -n <n> <path>cut -c <val>ls -l <path>
  77. Inspect · Batching & scheduling

    Requested file and log inspection and source searches related to batching & scheduling.

    2 calls · #0087–#0088

    sed -n <val> <path>rg -n <val> <path>headrg -n <val> <path> <path>head -n <n>
  78. Inspect · Source & workspace

    Requested file and log inspection and script or workload execution related to source & workspace.

    1 call · #0089–#0089

    tail -n <n> <path>cut -c <val>python3 - <script>
  79. Other · Attention kernels

    Requested script or workload execution and file and log inspection related to attention kernels.

    1 call · #0090–#0090

    python3 - <script>tail -n <n> <path>cut -c <val>
  80. Edit · Batching & scheduling

    Requested code edits related to batching & scheduling.

    1 call · #0091–#0091

    Apply patch <patch>
  81. Inspect · Batching & scheduling

    Requested source searches, file and log inspection and repository inspection related to batching & scheduling.

    1 call · #0092–#0092

    rg -n <val> <path>head -n <n>rg -n <val> <path> -g <path>git diff --check
  82. Inspect · Source & workspace

    Requested file and log inspection and script or workload execution related to source & workspace.

    1 call · #0093–#0093

    tail -n <n> <path>cut -c <val>python3 - <script>
  83. Inspect · Batching & scheduling

    Requested source searches and file and log inspection related to batching & scheduling.

    2 calls · #0094–#0095

    rg -n <val> <path> <path>head -n <n>sed -n <val> <path>rg -n <val> <path>cat <path>
  84. Edit · Batching & scheduling

    Requested code edits related to batching & scheduling.

    2 calls · #0096–#0097

    Apply patch <patch>
  85. Validate · Batching & scheduling

    Requested environment setup or inspection related to batching & scheduling.

    1 call · #0098–#0098

    env <vars> python3 -m <module> <val> > <path> <n> >& <path>
  86. Edit · Batching & scheduling

    Requested code edits related to batching & scheduling.

    1 call · #0099–#0099

    Apply patch <patch>
  87. Execute · Batching & scheduling

    Requested file and log inspection and script or workload execution related to batching & scheduling.

    1 call · #0100–#0100

    tail -n <n> <path>python3 - <script>cut -c <val>
  88. Inspect · Batching & scheduling

    Requested file and log inspection related to batching & scheduling.

    1 call · #0101–#0101

    tail -n <n> <path>cut -c <val>cat <path>tail -c <n>
  89. Other · Batching & scheduling

    Requested repository inspection and file and log inspection related to batching & scheduling.

    1 call · #0102–#0102

    command -v <val>git diff --statsed -n <val> <path>
  90. Validate · Batching & scheduling

    Requested script or workload execution and environment setup or inspection related to batching & scheduling.

    1 call · #0103–#0103

    python3 - <script>env <vars> python3 -m <module> -q <script> <script> > <path> <n> >& <path>
  91. Execute · Batching & scheduling

    Requested file and log inspection and script or workload execution related to batching & scheduling.

    1 call · #0104–#0104

    tail -n <n> <path>cut -c <val>python3 - <script>
  92. Execute · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0105–#0105

    env <vars> bash <script> > <path> <n> >& <path>
  93. Inspect · Batching & scheduling

    Requested source searches, file and log inspection and script or workload execution related to batching & scheduling.

    1 call · #0106–#0106

    rg -n <val> <path>head -n <n>python3 - <script>
  94. Inspect · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    1 call · #0107–#0107

    tail -n <n> <path>cut -c <val>
  95. Inspect · Batching & scheduling

    Requested repository inspection, source searches and workspace inspection related to batching & scheduling.

    1 call · #0108–#0108

    git status --shortrg --files <path>rg <val>find <path> -maxdepth <n> -name <val> -o -name <val>
  96. Edit · Batching & scheduling

    Requested code edits related to batching & scheduling.

    1 call · #0109–#0109

    Apply patch <patch>
  97. Validate · Benchmark & validation setup

    Requested file and log inspection and script or workload execution related to benchmark & validation setup.

    1 call · #0110–#0110

    tail -n <n> <path>cut -c <val>python3 - <script>
  98. Validate · Latency & request handling

    Requested workspace file updates, script or workload execution and environment setup or inspection related to latency & request handling.

    1 call · #0111–#0111

    mkdir -p <path>python3 - <script>env <vars> python3 <script> <val> > <path> <n> >& <path>
  99. Validate · Benchmark & validation setup

    Requested script or workload execution, file and log inspection and source searches related to benchmark & validation setup.

    2 calls · #0112–#0113

    python3 - <script>tail -n <n> <path>cut -c <val>cat <path>tail -c <n>rg -n <val> <path>
    1 more command sketches
    git diff --check
  100. Inspect · Batching & scheduling

    Requested file and log inspection and script or workload execution related to batching & scheduling.

    1 call · #0114–#0114

    tail -n <n> <path>cut -c <val>python3 - <script>
  101. Inspect · Attention kernels

    Requested repository inspection related to attention kernels.

    1 call · #0115–#0115

    git diff <flag> <args>
  102. Edit · Attention kernels

    Requested code edits related to attention kernels.

    1 call · #0116–#0116

    Apply patch <patch>
  103. Inspect · Batching & scheduling

    Requested file and log inspection and script or workload execution related to batching & scheduling.

    1 call · #0117–#0117

    tail -n <n> <path>cut -c <val>python3 - <script>
  104. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0118–#0118

    Apply patch <patch>
  105. Inspect · Latency & request handling

    Requested file and log inspection and script or workload execution related to latency & request handling.

    1 call · #0119–#0119

    tail -n <n> <path>cut -c <val>python3 - <script>
  106. Validate · Batching & scheduling

    Requested environment setup or inspection related to batching & scheduling.

    1 call · #0120–#0120

    env <vars> python3 -m <module> <val> <val> > <path> <n> >& <path>
  107. Inspect · Latency & request handling

    Requested file and log inspection and script or workload execution related to latency & request handling.

    1 call · #0121–#0121

    tail -n <n> <path>cut -c <val>python3 - <script>
  108. Validate · Task requirements

    Requested script or workload execution and environment setup or inspection related to task requirements.

    1 call · #0122–#0122

    python3 - <script>env <vars> bash <script> > <path> <n> >& <path>
  109. Execute · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    1 call · #0123–#0123

    tail -n <n> <path>cut -c <val><command> <args>
  110. Execute · Latency & request handling

    Requested file and log inspection and script or workload execution related to latency & request handling.

    1 call · #0124–#0124

    cat <path>python3 - <script>
  111. Validate · Attention kernels

    Requested environment setup or inspection related to attention kernels.

    1 call · #0125–#0125

    env <vars> python3 -m <module> -q <script> <script> > <path> <n> >& <path>
  112. Validate · Batching & scheduling

    Requested environment setup or inspection related to batching & scheduling.

    1 call · #0126–#0126

    env <vars> python3 -m <module> -q <script> <script> > <path> <n> >& <path>
  113. Inspect · Batching & scheduling

    Requested file and log inspection related to batching & scheduling.

    1 call · #0127–#0127

    cat <path>tail -n <n> <path>cut -c <val>
  114. Validate · Benchmark & validation setup

    Requested script or workload execution, runtime inspection and source searches related to benchmark & validation setup.

    1 call · #0128–#0128

    python3 - <script>ps <flag> <args>rg <val>tail -n <n>git diff --check
  115. Inspect · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    2 calls · #0129–#0130

    cat <path>tail -n <n> <path>cut -c <val>
  116. Validate · Benchmark & validation setup

    Requested script or workload execution and file and log inspection related to benchmark & validation setup.

    2 calls · #0131–#0132

    python3 - <script>cat <path>tail -n <n> <path>cut -c <val>
  117. Other · Source & workspace

    Requested script or workload execution and file and log inspection related to source & workspace.

    1 call · #0133–#0133

    python3 - <script>cat <path>tail -n <n> <path>cut -c <val>
  118. Inspect · Source & workspace

    Requested source searches and file and log inspection related to source & workspace.

    1 call · #0134–#0134

    rg -n <val> <path>head -n <n>sed -n <val> <path>
  119. Other · Source & workspace

    Requested script or workload execution and file and log inspection related to source & workspace.

    1 call · #0135–#0135

    python3 - <script>tail -n <n> <path>cut -c <val>
  120. Inspect · Source & workspace

    Requested file and log inspection, source searches and repository inspection related to source & workspace.

    4 calls · #0136–#0139

    cat <path>tail -n <n> <path>rg -n <val> <path>git status --short
  121. Inspect · Task requirements

    Requested file and log inspection related to task requirements.

    1 call · #0140–#0140

    cat <path>
  122. Inspect · Source & workspace

    Requested source searches and file and log inspection related to source & workspace.

    2 calls · #0141–#0142

    rg -n <val> <path>sed -n <val> <path>
  123. Inspect · Attention kernels

    Requested repository inspection related to attention kernels.

    1 call · #0143–#0143

    git diff <flag> <args>
  124. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    3 calls · #0144–#0146

    tail -n <n> <path>sed -n <val> <path>
  125. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0147–#0147

    sed -n <val> <path>
  126. Inspect · Benchmark & validation setup

    Requested file and log inspection related to benchmark & validation setup.

    1 call · #0148–#0148

    cat <path>
  127. Inspect · Source & workspace

    Requested source searches related to source & workspace.

    1 call · #0149–#0149

    rg -n <val> <path>
  128. Validate · Task requirements

    Requested file and log inspection and script or workload execution related to task requirements.

    1 call · #0150–#0150

    cat > <path> <script>python3 <script> > <path> <n> >& <path>
  129. Inspect · Batching & scheduling

    Requested file and log inspection related to batching & scheduling.

    1 call · #0151–#0151

    cat <path>
  130. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    2 calls · #0152–#0153

    sed -n <val> <path>
  131. Inspect · Task requirements

    Requested source searches related to task requirements.

    1 call · #0154–#0154

    rg -n <val> <path> <path>
  132. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    2 calls · #0155–#0156

    sed -n <val> <path>cat <path>
  133. Inspect · Attention kernels

    Requested source searches related to attention kernels.

    1 call · #0157–#0157

    rg -n <val> <path> <path>
  134. Inspect · Task requirements

    Requested file and log inspection related to task requirements.

    1 call · #0158–#0158

    cat <path>
  135. Inspect · Source & workspace

    Requested file and log inspection and repository inspection related to source & workspace.

    4 calls · #0159–#0162

    sed -n <val> <path>git diff <flag> <args>
  136. Execute · Task requirements

    Requested script or workload execution related to task requirements.

    1 call · #0163–#0163

    python3 - <script>
  137. Validate · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0164–#0164

    python3 - <script>
  138. Inspect · Source & workspace

    1 tool error

    Requested file and log inspection and source searches related to source & workspace.

    2 calls · #0165–#0166

    sed -n <val> <path>rg -n <val> <path> <path> <path>
  139. Inspect · Batching & scheduling

    Requested file and log inspection related to batching & scheduling.

    1 call · #0167–#0167

    cat <path>
  140. Inspect · Source & workspace

    1 tool error

    Requested source searches, file and log inspection and repository inspection related to source & workspace.

    11 calls · #0168–#0178

    rg -n <val> <path> <path> <path>tail -n <n> <path>git diff --statrg -n <val> <path>sed -n <val> <path>
  141. Inspect · Device memory

    Requested file and log inspection related to device memory.

    1 call · #0179–#0179

    sed -n <val> <path>
  142. Inspect · Source & workspace

    Requested file and log inspection, source searches and runtime inspection related to source & workspace.

    3 calls · #0180–#0182

    tail -n <n> <path>rg -n <val> <path>ps <flag> <args>
  143. Inspect · Task requirements

    Requested file and log inspection related to task requirements.

    1 call · #0183–#0183

    cat <path>
  144. Inspect · Source & workspace

    Requested source searches and file and log inspection related to source & workspace.

    1 call · #0184–#0184

    rg -n <val> <path>tail -n <n>
  145. Other · Source & workspace

    Requested repository inspection related to source & workspace.

    1 call · #0185–#0185

    git <val> <val> <flag>
  146. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    3 calls · #0186–#0188

    sed -n <val> <path>tail -n <n> <path>
  147. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0189–#0189

    python3 - <script>
  148. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    2 calls · #0190–#0191

    tail -n <n> <path>
  149. Execute · Latency & request handling

    Requested script or workload execution related to latency & request handling.

    1 call · #0192–#0192

    python3 - <script>
  150. Inspect · Batching & scheduling

    Requested source searches related to batching & scheduling.

    1 call · #0193–#0193

    rg -n <val> <path> <path> <path>
  151. Inspect · Source & workspace

    1 tool error

    Requested file and log inspection, source searches and repository inspection related to source & workspace.

    10 calls · #0194–#0203

    tail -n <n> <path>rg -n <val> <path>tail -n <n>sed -n <val> <path>rg -n <val> <path> <path> <path>git diff --stat
  152. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0204–#0204

    python3 - <script>
  153. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0205–#0205

    tail -n <n> <path>
  154. Inspect · Batching & scheduling

    Requested source searches and file and log inspection related to batching & scheduling.

    1 call · #0206–#0206

    rg -n <val> <path>head -n <n>
  155. Other · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0207–#0207

    python3 - <script>
  156. Inspect · Source & workspace

    Requested source searches related to source & workspace.

    1 call · #0208–#0208

    rg -n <val> <path> <path>
  157. Inspect · Runtime processes

    1 tool error

    Requested source searches related to runtime processes.

    1 call · #0209–#0209

    rg -n <val> <path> <path>
  158. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0210–#0210

    tail -n <n> <path>
  159. Other · Batching & scheduling

    Requested script or workload execution related to batching & scheduling.

    1 call · #0211–#0211

    python3 - <script>
  160. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0212–#0212

    tail -n <n> <path>
  161. Inspect · Benchmark & validation setup

    Requested source searches related to benchmark & validation setup.

    1 call · #0213–#0213

    rg -n <val> <path>
  162. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    2 calls · #0214–#0215

    tail -n <n> <path>
  163. Inspect · Runtime processes

    Requested file and log inspection related to runtime processes.

    1 call · #0216–#0216

    sed -n <val> <path>
  164. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0217–#0217

    python3 - <script>
  165. Profile · Rollout generation

    Requested file and log inspection and environment setup or inspection related to rollout generation.

    1 call · #0218–#0218

    cat > <path> <script>env <vars> python3 <script> > <path> <n> >& <path>
  166. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0219–#0219

    tail -n <n> <path>
  167. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0220–#0220

    python3 - <script>
  168. Inspect · Source & workspace

    Requested repository inspection related to source & workspace.

    1 call · #0221–#0221

    git diff --stat
  169. Edit · Attention kernels

    Requested code edits related to attention kernels.

    2 calls · #0222–#0223

    Apply patch <patch>
  170. Inspect · Source & workspace

    Requested repository inspection and file and log inspection related to source & workspace.

    4 calls · #0224–#0227

    git diff --checkcat <path>tail -n <n> <path>
  171. Validate · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0228–#0228

    python3 - <script>
  172. Validate · Batching & scheduling

    Requested environment setup or inspection related to batching & scheduling.

    1 call · #0229–#0229

    env <vars> python3 -m <module> <val> <val> > <path> <n> >& <path>
  173. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    2 calls · #0230–#0231

    tail -n <n> <path>
  174. Inspect · Batching & scheduling

    Requested source searches related to batching & scheduling.

    1 call · #0232–#0232

    rg -n <val> <path>
  175. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    2 calls · #0233–#0234

    python3 - <script>
  176. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    2 calls · #0235–#0236

    tail -n <n> <path>sed -n <val> <path>
  177. Inspect · Batching & scheduling

    Requested file and log inspection related to batching & scheduling.

    1 call · #0237–#0237

    tail -n <n> <path>
  178. Validate · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0238–#0238

    python3 - <script>
  179. Other · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0239–#0239

    env <vars> python3 <script> <val> > <path> <n> >& <path>
  180. Inspect · Benchmark & validation setup

    Requested file and log inspection and source searches related to benchmark & validation setup.

    2 calls · #0240–#0241

    tail -n <n> <path>rg -n <path> <path>tail -n <n>
  181. Validate · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0242–#0242

    python3 - <script>
  182. Inspect · Task requirements

    Requested script or workload execution related to task requirements.

    1 call · #0243–#0243

    python3 - <script>
  183. Inspect · Source & workspace

    Requested file and log inspection and repository inspection related to source & workspace.

    2 calls · #0244–#0245

    tail -n <n> <path>git diff --numstat
  184. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0246–#0246

    python3 - <script>
  185. Execute · Benchmark & validation setup

    Requested script or workload execution related to benchmark & validation setup.

    1 call · #0247–#0247

    python3 - <script>
  186. Other · Source & workspace

    1 tool error

    Requested script or workload execution related to source & workspace.

    3 calls · #0248–#0250

    python3 - <script>
  187. Inspect · Batching & scheduling

    Requested file and log inspection related to batching & scheduling.

    1 call · #0251–#0251

    cat > <path> <script>
  188. Other · Latency & request handling

    Requested script or workload execution related to latency & request handling.

    1 call · #0252–#0252

    python3 - <script>
  189. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0253–#0253

    python3 - <script>
  190. Execute · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0254–#0254

    env <vars> bash <script> > <path> <n> >& <path>
  191. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0255–#0255

    python3 - <script>
  192. Validate · Latency & request handling

    Requested script or workload execution related to latency & request handling.

    1 call · #0256–#0256

    python3 - <script>
  193. Other · Source & workspace

    Requested environment setup or inspection related to source & workspace.

    1 call · #0257–#0257

    env <vars> python3 <script> > <path> <n> >& <path>
  194. Inspect · Source & workspace

    Requested repository inspection and file and log inspection related to source & workspace.

    3 calls · #0258–#0260

    git diff --checkcat <path>git status --short
  195. Validate · Batching & scheduling

    Requested script or workload execution related to batching & scheduling.

    1 call · #0261–#0261

    python3 - <script>

03 / CANDIDATE ARTIFACT

Text patches & binary names

Read code changes as Git diffs. Identifying strings are masked; binary files are listed by their full relative names.

sglang · 9 changed files

Base commit: 340db9201005fc64635bb25db1d2538f955761c3

diff --git a/python/sglang/srt/environ.py b/python/sglang/srt/environ.pyindex 81cbfc18ddf28f9cf3d458c4f141f9ec1c9ac66a..049f59c90fff0997c235178e8855e91043deb59a 100644--- a/python/sglang/srt/environ.py+++ b/python/sglang/srt/environ.py@@ -631,6 +631,8 @@ class Envs:     SGLANG_MLX_CLEAR_CACHE_STEPS = EnvInt(256)      # NPU+    # Seconds to coalesce singleton eager prefills while decode is busy; 0 disables.+    SGLANG_NPU_PREFILL_COALESCE_MAX_DELAY = EnvFloat(0.08)     SGLANG_NPU_DISABLE_ACL_FORMAT_WEIGHT = EnvBool(False)     SGLANG_NPU_USE_MULTI_STREAM = EnvBool(False)     SGLANG_NPU_USE_MLAPO = EnvBool(False)diff --git a/python/sglang/srt/hardware_backend/npu/allocator_npu.py b/python/sglang/srt/hardware_backend/npu/allocator_npu.pyindex 1a6ce9e6e4f73d1f004ed8ba6f109f9b19bb5dbf..c570cc819656a7676fb1804a4ad59691eed9b4da 100644--- a/python/sglang/srt/hardware_backend/npu/allocator_npu.py+++ b/python/sglang/srt/hardware_backend/npu/allocator_npu.py@@ -120,12 +120,12 @@ class NPUPagedTokenToKVPoolAllocator(PagedTokenToKVPoolAllocator):         if num_new_pages > len(self.free_pages):             return None -        need_new_pages = (seq_lens % self.page_size == 1).int()-        end_new_pages = torch.cumsum(need_new_pages, 0)-        start_new_pages = end_new_pages - need_new_pages         if num_new_pages == 0:             out_indices = last_loc + 1         else:+            need_new_pages = (seq_lens % self.page_size == 1).int()+            end_new_pages = torch.cumsum(need_new_pages, 0)+            start_new_pages = end_new_pages - need_new_pages             out_indices = (last_loc + 1) * (1 - need_new_pages) + self.free_pages[                 start_new_pages             ] * self.page_size * need_new_pagesdiff --git a/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py b/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.pyindex 89e9de06db1cb0350cb55b83dbaffc15c100fff9..39ff13c4e6a5e782fd0106bba1a222578e109071 100644--- a/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py+++ b/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py@@ -430,7 +430,11 @@ class AscendAttnBackend(AttentionBackend):     def init_forward_metadata(self, forward_batch: ForwardBatch):         """Init the metadata for a forward pass."""         self.forward_metadata = ForwardMetadata()-        seq_lens_max = forward_batch.seq_lens.max()+        seq_lens_max = (+            forward_batch.seq_lens_cpu.max().item()+            if forward_batch.seq_lens_cpu is not None and forward_batch.spec_info is None+            else forward_batch.seq_lens.max().item()+        )         if forward_batch.forward_mode.is_target_verify():             seq_lens_max += self.speculative_num_draft_tokens         elif (@@ -459,8 +463,19 @@ class AscendAttnBackend(AttentionBackend):             )         if forward_batch.extend_seq_lens is not None:             self.forward_metadata.extend_seq_lens = forward_batch.extend_seq_lens+            # DP padding and speculative workers can change the device lengths+            # independently of the scheduler's original CPU list.             self.forward_metadata.extend_seq_lens_cpu_int = (-                forward_batch.extend_seq_lens.cpu().int()+                torch.tensor(+                    forward_batch.extend_seq_lens_cpu,+                    dtype=torch.int32,+                    device="cpu",+                )+                if forward_batch.extend_seq_lens_cpu is not None+                and forward_batch.spec_info is None+                and len(forward_batch.extend_seq_lens_cpu)+                == forward_batch.extend_seq_lens.numel()+                else forward_batch.extend_seq_lens.cpu().int()             )         if forward_batch.seq_lens is not None:             self.forward_metadata.seq_lens = forward_batch.seq_lens.int()diff --git a/python/sglang/srt/hardware_backend/npu/graph_runner/npu_cudagraph_backend.py b/python/sglang/srt/hardware_backend/npu/graph_runner/npu_cudagraph_backend.pyindex 105034c03c0fb36d35254f822b63908f5bd0a2a0..ea05cbd11ae6295e455b6c84461dc1eb23e16444 100644--- a/python/sglang/srt/hardware_backend/npu/graph_runner/npu_cudagraph_backend.py+++ b/python/sglang/srt/hardware_backend/npu/graph_runner/npu_cudagraph_backend.py@@ -12,7 +12,7 @@ non-NPU hosts.  from __future__ import annotations -import threading+from concurrent.futures import ThreadPoolExecutor from contextlib import AbstractContextManager, contextmanager from functools import partial from typing import TYPE_CHECKING, Any, Callable, Dict, Optional@@ -63,6 +63,7 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend):         self._enable_torch_compile = getattr(             cuda_graph_runner, "enable_torch_compile", False         )+        self._update_executor: Optional[ThreadPoolExecutor] = None      @contextmanager     def capture_session(self, stream):@@ -150,8 +151,8 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend):         attr_type: Any = None,         cpu_update_input: list = None,     ) -> Any:-        """Rebind seq_lens on the recorded NPU graph in a background-        thread, then replay. Used when the model is not deepseek-nsa.+        """Rebind seq_lens on the recorded NPU graph in a persistent+        worker while replaying. Used when the model is not deepseek-nsa.          Two calling conventions:         1. (legacy) seq_lens + attr_name + attr_type:@@ -166,17 +167,31 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend):          graph = self._graphs[shape_key] -        def _update():-            self._device_module.set_device(self._device_id)-            graph.update(cpu_update_input=cpu_update_input)--        thread = threading.Thread(target=_update)-        thread.start()-        graph.replay()-        thread.join()+        # update and replay must overlap: captured attention waits on external+        # events recorded by update. Reuse one worker (and its device context)+        # instead of creating a thread on every generated token.+        if self._update_executor is None:+            self._update_executor = ThreadPoolExecutor(+                max_workers=1,+                thread_name_prefix="npu-graph-update",+                initializer=self._device_module.set_device,+                initargs=(self._device_id,),+            )+        update = self._update_executor.submit(+            graph.update, cpu_update_input=cpu_update_input+        )+        try:+            graph.replay()+        finally:+            # Finish the update before any captured buffers can be reused, and+            # propagate worker failures to the scheduler.+            update.result()         return self._outputs[shape_key]      def cleanup(self) -> None:+        if self._update_executor is not None:+            self._update_executor.shutdown(wait=True)+            self._update_executor = None         self._graphs.clear()         self._outputs.clear()         self._pool = Nonediff --git a/python/sglang/srt/hardware_backend/npu/graph_runner/npu_graph_runner.py b/python/sglang/srt/hardware_backend/npu/graph_runner/npu_graph_runner.pyindex b82c973bc340c072ea79877ef4a0d183bd6af32d..1c12a1f09cea8debe286dfd979c49be53ea16d34 100644--- a/python/sglang/srt/hardware_backend/npu/graph_runner/npu_graph_runner.py+++ b/python/sglang/srt/hardware_backend/npu/graph_runner/npu_graph_runner.py@@ -243,9 +243,19 @@ class NPUGraphRunner(DecodeCudaGraphRunner):                 seq_lens_cpu = forward_batch.seq_lens.cpu() + self.captured_req_width                 seq_lens = seq_lens_cpu.tolist() + [0] * (self.bs - self.raw_bs)             else:-                seq_lens = forward_batch.seq_lens.cpu().tolist() + [0] * (-                    self.bs - self.raw_bs-                )+                # Ordinary decode maintains an immutable CPU mirror for each+                # scheduled batch. Reading it avoids synchronizing the forward+                # stream just to recover lengths already known by the scheduler.+                # Speculative workers may advance device lengths independently.+                if (+                    forward_batch.forward_mode.is_decode_or_idle()+                    and forward_batch.spec_info is None+                    and forward_batch.seq_lens_cpu is not None+                ):+                    seq_lens_cpu = forward_batch.seq_lens_cpu+                else:+                    seq_lens_cpu = forward_batch.seq_lens.cpu()+                seq_lens = seq_lens_cpu.tolist() + [0] * (self.bs - self.raw_bs)             output = self.backend.replay_with_input_update(                 graph_key,                 seq_lens=seq_lens,diff --git a/python/sglang/srt/hardware_backend/npu/prefill_coalescer.py b/python/sglang/srt/hardware_backend/npu/prefill_coalescer.pynew file mode 100644index 0000000000000000000000000000000000000000..e7768e04c7fcd14e5814c618e5abfa8eace7a12b--- /dev/null+++ b/python/sglang/srt/hardware_backend/npu/prefill_coalescer.py@@ -0,0 +1,93 @@+"""Bounded coalescing of eager prefills while an NPU decode graph is busy."""++import math+import time+from typing import TYPE_CHECKING, Optional++if TYPE_CHECKING:+    from sglang.srt.managers.scheduler import Scheduler+++class NPUPrefillCoalescer:+    """Amortize eager launch overhead without waiting on an idle device.++    A singleton prefill can interrupt every active decoder for many operator+    launches. Allow another arrival to join it while useful decode work runs.+    The wait is at most twice the observed prefill launch time, subject to a+    fixed wall-clock ceiling. A ready batch of two is dispatched immediately.+    """++    def __init__(self, max_delay_s: float):+        if not math.isfinite(max_delay_s) or max_delay_s < 0:+            raise ValueError(+                "NPU prefill coalescing delay must be finite and nonnegative"+            )+        self.max_delay_s = max_delay_s+        self._prefill_cost: Optional[float] = None+        self._waiting_req = None+        self._deadline = 0.0++    @classmethod+    def from_scheduler(cls, scheduler: "Scheduler") -> Optional["NPUPrefillCoalescer"]:+        from sglang.srt.environ import envs+        from sglang.srt.model_executor.cuda_graph_config import Backend++        args = scheduler.server_args+        max_delay_s = envs.SGLANG_NPU_PREFILL_COALESCE_MAX_DELAY.get()+        # Distributed ranks need a negotiated decision. Explicit delayers,+        # mixed chunks and speculative workers already own their scheduling.+        if (+            max_delay_s == 0+            or not scheduler.enable_overlap+            or not scheduler.is_generation+            or scheduler.dllm_config is not None+            or scheduler.ps.tp_size != 1+            or scheduler.ps.dp_size != 1+            or scheduler.ps.pp_size != 1+            or not scheduler.spec_algorithm.is_none()+            or scheduler.is_mixed_chunk+            or scheduler.prefill_delayer is not None+            or scheduler.min_free_slots_delayer is not None+            or args.enable_priority_scheduling+            or args.schedule_policy != "fcfs"+            or args.disaggregation_mode != "null"+            or args.cuda_graph_config.decode.backend != Backend.FULL+            or args.cuda_graph_config.prefill.backend != Backend.DISABLED+        ):+            return None+        return cls(max_delay_s)++    def observe_prefill(self, duration_s: float) -> None:+        if not math.isfinite(duration_s) or duration_s < 0:+            return+        # Clip cold-start compilation outliers before updating the estimate.+        duration_s = min(duration_s, self.max_delay_s)+        if self._prefill_cost is None:+            self._prefill_cost = duration_s+        else:+            self._prefill_cost += 0.125 * (duration_s - self._prefill_cost)++    def should_delay(+        self,+        *,+        running_bs: int,+        waiting_queue: list,+        has_chunked_req: bool,+    ) -> bool:+        if (+            running_bs < 2+            or len(waiting_queue) != 1+            or has_chunked_req+            or self._prefill_cost is None+        ):+            self._waiting_req = None+            return False++        now = time.perf_counter()+        req = waiting_queue[0]+        if req is not self._waiting_req:+            self._waiting_req = req+            self._deadline = now + min(self.max_delay_s, 2 * self._prefill_cost)+        # Keep an expired deadline until this request is admitted or leaves the+        # queue. Memory pressure must not restart its wait on every attempt.+        return now < self._deadlinediff --git a/python/sglang/srt/managers/scheduler.py b/python/sglang/srt/managers/scheduler.pyindex a9615a14c512345b2d63323ff3ebd2fe3d9a0dca..dd776252b28740edbf44a857b48daa2cbf0566c5 100644--- a/python/sglang/srt/managers/scheduler.py+++ b/python/sglang/srt/managers/scheduler.py@@ -1228,6 +1228,19 @@ class Scheduler(             self.server_args         ) +        self.npu_prefill_coalescer = None+        if _is_npu:+            from sglang.srt.hardware_backend.npu.prefill_coalescer import (+                NPUPrefillCoalescer,+            )++            self.npu_prefill_coalescer = NPUPrefillCoalescer.from_scheduler(self)+            if self.npu_prefill_coalescer is not None:+                logger.info(+                    "NPU eager prefill coalescing enabled (maximum delay %.0f ms).",+                    self.npu_prefill_coalescer.max_delay_s * 1000,+                )+     def init_soft_watchdog(self, server_args: ServerArgs):         if (x := server_args.soft_watchdog_timeout) is not None:             self.soft_watchdog = create_scheduler_watchdog(@@ -1760,7 +1773,15 @@ class Scheduler(              # Launch the current batch             if batch:+                coalescer = self.npu_prefill_coalescer+                prefill_start = (+                    time.perf_counter()+                    if coalescer is not None and batch.forward_mode.is_extend()+                    else None+                )                 batch_result = self.run_batch(batch)+                if prefill_start is not None:+                    coalescer.observe_prefill(time.perf_counter() - prefill_start)                 # Fence result processing behind this forward's shared reads.                 self._apply_war_barrier()                 self.result_queue.append((batch.copy(), batch_result))@@ -3065,6 +3086,18 @@ class Scheduler(         return res      def get_new_batch_prefill(self, running_batch: ScheduleBatch) -> NextBatchPlan:+        if (+            self.npu_prefill_coalescer is not None+            and self.npu_prefill_coalescer.should_delay(+                running_bs=(+                    0 if running_batch.is_prefill_only else len(running_batch.reqs)+                ),+                waiting_queue=self.waiting_queue,+                has_chunked_req=self.chunked_req is not None,+            )+        ):+            return NextBatchPlan(batch_to_run=None, running_batch=running_batch)+         prefill_delayer_single_pass = None         if self.prefill_delayer:             # Decay the max-prefill-bs high-watermark once per pass so onediff --git a/python/sglang/test/ascend/test_npu_decode_metadata.py b/python/sglang/test/ascend/test_npu_decode_metadata.pynew file mode 100644index 0000000000000000000000000000000000000000..94e6e4d7feb9a518cddc4f743d36963f1ced2e0e--- /dev/null+++ b/python/sglang/test/ascend/test_npu_decode_metadata.py@@ -0,0 +1,220 @@+"""CPU tests for NPU decode metadata and graph-update coordination."""++import threading+import unittest+from types import SimpleNamespace+from unittest.mock import Mock, patch++import torch++from sglang.srt.hardware_backend.npu.allocator_npu import (+    NPUPagedTokenToKVPoolAllocator,+)+from sglang.srt.hardware_backend.npu.attention.ascend_backend import AscendAttnBackend+from sglang.srt.hardware_backend.npu.graph_runner.npu_cudagraph_backend import (+    NPUCudaGraphBackend,+)+from sglang.srt.hardware_backend.npu.graph_runner.npu_graph_runner import NPUGraphRunner+from sglang.srt.layers.logits_processor import LogitsProcessorOutput+from sglang.srt.model_executor.forward_batch_info import ForwardMode+++class TestNPUDecodeLengths(unittest.TestCase):+    def setUp(self):+        self.runner = object.__new__(NPUGraphRunner)+        self.runner.model_runner = SimpleNamespace(+            model_config=SimpleNamespace(+                hf_config=SimpleNamespace(architectures=["Qwen3ForCausalLM"])+            )+        )+        self.runner.bs = 4+        self.runner.raw_bs = self.runner.raw_num_token = 3+        self.runner.captured_req_width = 1+        self.runner.is_dllm = False+        self.runner.load_batch = Mock()+        self.runner._make_graph_key = Mock(return_value=4)+        self.runner._get_update_attr_name = Mock(return_value="actual_seq_lengths_kv")+        self.runner._get_update_attr_type = Mock(return_value=[])+        self.runner.backend = Mock()+        self.runner.backend.replay_with_input_update.return_value = (+            LogitsProcessorOutput(next_token_logits=torch.zeros(4, 8))+        )+        self.batch = SimpleNamespace(+            needs_forward_metadata_init=lambda: True,+            forward_mode=ForwardMode.DECODE,+            seq_lens_cpu=torch.tensor([17, 129, 257]),+            seq_lens=Mock(),+            spec_info=None,+        )+        self.batch.seq_lens.cpu.side_effect = AssertionError("unexpected device copy")++    def test_decode_uses_cpu_mirror_and_pads_inactive_requests(self):+        out = self.runner.execute(self.batch)+        self.assertEqual(out.next_token_logits.shape, (3, 8))+        self.assertEqual(+            self.runner.backend.replay_with_input_update.call_args.kwargs["seq_lens"],+            [17, 129, 257, 0],+        )+        self.batch.seq_lens.cpu.assert_not_called()++    def test_missing_mirror_uses_device_lengths(self):+        self.batch.seq_lens_cpu = None+        self.batch.seq_lens.cpu.side_effect = None+        self.batch.seq_lens.cpu.return_value = torch.tensor([18, 130, 258])+        self.runner.execute(self.batch)+        self.assertEqual(+            self.runner.backend.replay_with_input_update.call_args.kwargs["seq_lens"],+            [18, 130, 258, 0],+        )++    def test_speculative_decode_keeps_device_length_authority(self):+        self.batch.spec_info = object()+        self.batch.seq_lens.cpu.side_effect = None+        self.batch.seq_lens.cpu.return_value = torch.tensor([20, 132, 260])+        self.runner.execute(self.batch)+        self.assertEqual(+            self.runner.backend.replay_with_input_update.call_args.kwargs["seq_lens"],+            [20, 132, 260, 0],+        )+++class TestNPUPageAllocation(unittest.TestCase):+    def setUp(self):+        self.allocator = object.__new__(NPUPagedTokenToKVPoolAllocator)+        self.allocator.debug_mode = False+        self.allocator.page_size = 128+        self.allocator.free_pages = torch.tensor([8, 11, 13, 17])++    def test_decode_within_pages_does_not_build_a_page_scan(self):+        seq_lens = torch.tensor([2, 128, 130, 256])+        last_loc = torch.tensor([128, 382, 512, 766])+        with patch.object(torch, "cumsum", side_effect=AssertionError("unused scan")):+            out = self.allocator.alloc_decode(seq_lens, seq_lens, last_loc)+        self.assertEqual(out.tolist(), [129, 383, 513, 767])+        self.assertEqual(out.dtype, torch.int32)+        self.assertEqual(self.allocator.free_pages.tolist(), [8, 11, 13, 17])++    def test_decode_across_pages_consumes_pages_in_request_order(self):+        seq_lens = torch.tensor([129, 130, 257, 258])+        last_loc = torch.tensor([255, 512, 767, 896])+        out = self.allocator.alloc_decode(seq_lens, seq_lens, last_loc)+        self.assertEqual(out.tolist(), [8 * 128, 513, 11 * 128, 897])+        self.assertEqual(self.allocator.free_pages.tolist(), [13, 17])+++class TestNPUEagerMetadata(unittest.TestCase):+    def setUp(self):+        self.backend = object.__new__(AscendAttnBackend)+        self.backend.req_to_token_pool = SimpleNamespace(+            req_to_token=torch.arange(4096, dtype=torch.int32).reshape(4, 1024)+        )+        self.backend.page_size = 128+        self.backend.is_hybrid_swa = False+        self.backend.use_mla = False+        self.backend.use_sliding_window_kv_pool = False+        self.batch = SimpleNamespace(+            forward_mode=ForwardMode.EXTEND,+            seq_lens=torch.tensor([130, 180]),+            seq_lens_cpu=torch.tensor([130, 180]),+            req_pool_indices=torch.tensor([1, 2]),+            extend_seq_lens=torch.tensor([2, 3]),+            extend_seq_lens_cpu=[2, 3],+            spec_info=None,+        )++    def test_prefill_metadata_needs_no_device_readback(self):+        with patch.object(torch.Tensor, "cpu", side_effect=AssertionError("readback")):+            self.backend.init_forward_metadata(self.batch)+        metadata = self.backend.forward_metadata+        self.assertEqual(metadata.block_tables.tolist(), [[8, 9], [16, 17]])+        self.assertEqual(metadata.extend_seq_lens_cpu_int.tolist(), [2, 3])+        self.assertEqual(metadata.extend_seq_lens_cpu_int.dtype, torch.int32)++    def test_speculative_lengths_can_advance_independently(self):+        self.batch.spec_info = object()+        self.batch.seq_lens = torch.tensor([130, 300])+        self.batch.extend_seq_lens = torch.tensor([4, 5])+        self.backend.init_forward_metadata(self.batch)+        metadata = self.backend.forward_metadata+        self.assertEqual(metadata.block_tables.shape, (2, 3))+        self.assertEqual(metadata.extend_seq_lens_cpu_int.tolist(), [4, 5])++    def test_padded_device_lengths_keep_the_device_shape(self):+        self.batch.extend_seq_lens = torch.tensor([2, 3, 0])+        self.backend.init_forward_metadata(self.batch)+        metadata = self.backend.forward_metadata+        self.assertEqual(metadata.extend_seq_lens_cpu_int.tolist(), [2, 3, 0])+++class TestNPUGraphUpdateWorker(unittest.TestCase):+    def setUp(self):+        self.device = Mock()+        self.device.current_device.return_value = 0+        self.backend = NPUCudaGraphBackend(+            SimpleNamespace(+                device_module=self.device,+                model_runner=SimpleNamespace(tp_group=None),+            )+        )+        self.addCleanup(self.backend.cleanup)++    def test_updates_overlap_replay_and_reuse_the_worker(self):+        worker_ids = []+        for index in range(3):+            update_started = threading.Event()+            replay_started = threading.Event()+            update_finished = threading.Event()+            metadata = [{"actual_seq_lengths_kv": [index + 1, 0]}]++            def update(*, cpu_update_input):+                self.assertEqual(cpu_update_input, metadata)+                worker_ids.append(threading.get_ident())+                update_started.set()+                self.assertTrue(replay_started.wait(5))+                update_finished.set()++            def replay():+                self.assertTrue(update_started.wait(5))+                replay_started.set()+                self.assertTrue(update_finished.wait(5))++            self.backend._graphs[index] = SimpleNamespace(update=update, replay=replay)+            output = object()+            self.backend._outputs[index] = output+            self.assertIs(+                self.backend.replay_with_input_update(+                    index, seq_lens=None, cpu_update_input=metadata+                ),+                output,+            )+        self.assertEqual(len(set(worker_ids)), 1)+        self.assertNotEqual(worker_ids[0], threading.get_ident())+        self.device.set_device.assert_called_once_with(0)+        self.backend.cleanup()+        self.assertIsNone(self.backend._update_executor)+        self.assertFalse(self.backend._graphs)++    def test_update_errors_reach_the_caller(self):+        self.backend._graphs[1] = Mock()+        self.backend._graphs[1].update.side_effect = RuntimeError("update failed")+        self.backend._outputs[1] = object()+        with self.assertRaisesRegex(RuntimeError, "update failed"):+            self.backend.replay_with_input_update(+                1, seq_lens=[1], attr_name="actual_seq_lengths_kv"+            )++    def test_tensor_metadata_conversion(self):+        graph = Mock()+        self.backend._graphs[1] = graph+        self.backend._outputs[1] = object()+        self.backend.replay_with_input_update(+            1, seq_lens=[7, 0], attr_name="context_lens", attr_type=torch.empty(0)+        )+        lengths = graph.update.call_args.kwargs["cpu_update_input"][0]["context_lens"]+        self.assertEqual(lengths.tolist(), [7, 0])+        self.assertEqual(lengths.dtype, torch.int32)+        self.assertEqual(lengths.device.type, "cpu")+++if __name__ == "__main__":+    unittest.main()diff --git a/python/sglang/test/ascend/test_npu_prefill_coalescer.py b/python/sglang/test/ascend/test_npu_prefill_coalescer.pynew file mode 100644index 0000000000000000000000000000000000000000..b556b624824af0679c8d54c360963a3ccd64d348--- /dev/null+++ b/python/sglang/test/ascend/test_npu_prefill_coalescer.py@@ -0,0 +1,133 @@+import unittest+from types import SimpleNamespace+from unittest.mock import Mock, patch++from sglang.srt.environ import envs+from sglang.srt.hardware_backend.npu.prefill_coalescer import NPUPrefillCoalescer+from sglang.srt.model_executor.cuda_graph_config import Backend, CudaGraphConfig+++class TestNPUPrefillCoalescer(unittest.TestCase):+    def setUp(self):+        self.coalescer = NPUPrefillCoalescer(max_delay_s=0.08)+        self.coalescer.observe_prefill(0.02)+        self.clock = patch(+            "sglang.srt.hardware_backend.npu.prefill_coalescer.time.perf_counter",+            return_value=100.0,+        ).start()+        self.addCleanup(patch.stopall)+        self.request = object()++    def delay(self, **overrides):+        kwargs = dict(+            running_bs=8, waiting_queue=[self.request], has_chunked_req=False+        )+        kwargs.update(overrides)+        return self.coalescer.should_delay(**kwargs)++    def test_wait_expires_and_does_not_restart_under_memory_pressure(self):+        self.assertTrue(self.delay())+        self.clock.return_value += 0.039+        self.assertTrue(self.delay())+        self.clock.return_value += 0.002+        self.assertFalse(self.delay())+        self.clock.return_value += 1+        self.assertFalse(self.delay())++    def test_second_arrival_is_dispatched_immediately(self):+        self.assertTrue(self.delay())+        self.assertFalse(self.delay(waiting_queue=[self.request, object()]))++    def test_idle_small_decode_and_chunked_prefills_are_not_delayed(self):+        for overrides in (+            dict(running_bs=0),+            dict(running_bs=1),+            dict(has_chunked_req=True),+            dict(waiting_queue=[]),+        ):+            with self.subTest(overrides=overrides):+                self.assertFalse(self.delay(**overrides))++    def test_new_request_gets_its_own_deadline(self):+        self.assertTrue(self.delay())+        self.clock.return_value += 0.05+        self.assertFalse(self.delay())+        self.request = object()+        self.assertTrue(self.delay())+        self.clock.return_value += 0.05+        self.assertFalse(self.delay())++    def test_cold_start_outlier_cannot_exceed_the_ceiling(self):+        self.coalescer.observe_prefill(1000)+        self.assertTrue(self.delay())+        self.clock.return_value += 0.081+        self.assertFalse(self.delay())++    def test_no_observation_and_zero_budget_do_not_wait(self):+        self.coalescer = NPUPrefillCoalescer(0.08)+        self.assertFalse(self.delay())+        self.coalescer = NPUPrefillCoalescer(0)+        self.coalescer.observe_prefill(0.1)+        self.assertFalse(self.delay())++    def test_invalid_timings_cannot_create_an_unbounded_wait(self):+        for duration in (float("nan"), float("inf"), -1):+            self.coalescer.observe_prefill(duration)+        self.assertTrue(self.delay())+        self.clock.return_value += 0.041+        self.assertFalse(self.delay())+        for delay in (float("nan"), float("inf"), -1):+            with self.assertRaises(ValueError):+                NPUPrefillCoalescer(delay)+++class TestNPUPrefillCoalescerEligibility(unittest.TestCase):+    def setUp(self):+        config = CudaGraphConfig.from_dict(+            {"decode": {"backend": "full"}, "prefill": {"backend": "disabled"}}+        )+        self.scheduler = SimpleNamespace(+            enable_overlap=True,+            is_generation=True,+            dllm_config=None,+            ps=SimpleNamespace(tp_size=1, dp_size=1, pp_size=1),+            spec_algorithm=Mock(is_none=lambda: True),+            is_mixed_chunk=False,+            prefill_delayer=None,+            min_free_slots_delayer=None,+            server_args=SimpleNamespace(+                enable_priority_scheduling=False,+                schedule_policy="fcfs",+                disaggregation_mode="null",+                cuda_graph_config=config,+            ),+        )++    def test_single_device_eager_prefill_can_coalesce(self):+        self.assertIsNotNone(NPUPrefillCoalescer.from_scheduler(self.scheduler))++    def test_explicit_scheduling_controls_take_precedence(self):+        for field, value in (+            ("prefill_delayer", object()),+            ("min_free_slots_delayer", object()),+            ("is_mixed_chunk", True),+            ("enable_overlap", False),+            ("dllm_config", object()),+        ):+            with self.subTest(field=field), patch.object(self.scheduler, field, value):+                self.assertIsNone(NPUPrefillCoalescer.from_scheduler(self.scheduler))++    def test_distributed_engines_do_not_make_local_wait_decisions(self):+        for field in ("tp_size", "dp_size", "pp_size"):+            with self.subTest(field=field), patch.object(self.scheduler.ps, field, 2):+                self.assertIsNone(NPUPrefillCoalescer.from_scheduler(self.scheduler))++    def test_graph_prefill_and_env_opt_out(self):+        with envs.SGLANG_NPU_PREFILL_COALESCE_MAX_DELAY.override(0):+            self.assertIsNone(NPUPrefillCoalescer.from_scheduler(self.scheduler))+        self.scheduler.server_args.cuda_graph_config.prefill.backend = Backend.FULL+        self.assertIsNone(NPUPrefillCoalescer.from_scheduler(self.scheduler))+++if __name__ == "__main__":+    unittest.main()