GPT-6 Astra · Serving

S05 · Mixed

Valid

Mixed interactivity 1dev · Implementation Optimization

1.27×PERFORMANCE RATIO
294TOOL 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 · 294 visible calls

InspectEditValidateExecuteBuildProfileRollbackOther
166Inspect
19Edit
3Build
55Validate
20Execute
4Profile
27Other

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 timeline252 groups · 294 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 · Source & workspace

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

    1 call · #0001–#0001

    pwdprintenv <vars>
  2. Build · Task requirements

    Requested source searches related to task requirements.

    1 call · #0002–#0002

    rg --files -g <val> -g <path> -g <path> <path> <n> > <path>
  3. Inspect · Source & workspace

    Requested repository inspection related to source & workspace.

    1 call · #0003–#0003

    git status --short
  4. Inspect · Task requirements

    Requested file and log inspection related to task requirements.

    2 calls · #0004–#0005

    cat <path> <path><command> <args>
  5. Inspect · Attention kernels

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

    1 call · #0006–#0006

    rg --files -g <path> -g <path> -g <val> -g <val> <path> <val>head -n <n>
  6. Inspect · Task requirements

    Requested file and log inspection related to task requirements.

    1 call · #0007–#0007

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

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

    1 call · #0008–#0008

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

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

    1 call · #0009–#0009

    rg --files <path> <path>head -n <n>
  9. Inspect · Benchmark & validation setup

    Requested source searches related to benchmark & validation setup.

    1 call · #0010–#0010

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

    Requested script or workload execution related to task requirements.

    1 call · #0011–#0011

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

    1 tool error

    Requested script or workload execution related to source & workspace.

    1 call · #0012–#0012

    bash <script>
  12. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0013–#0013

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

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

    1 call · #0014–#0014

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

    Requested environment setup or inspection related to source & workspace.

    1 call · #0015–#0015

    env <vars> bash <script>
  15. Inspect · Source & workspace

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

    1 call · #0016–#0016

    rg --files <path> <path> <path>head -n <n>
  16. Inspect · Batching & scheduling

    Requested source searches related to batching & scheduling.

    1 call · #0017–#0017

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

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

    2 calls · #0018–#0019

    rg -n <flag> <args>sed -n <val> <path>rg -n <val> <path>
  18. Inspect · Batching & scheduling

    Requested file and log inspection related to batching & scheduling.

    1 call · #0020–#0020

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

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

    2 calls · #0021–#0022

    sed -n <val> <path>rg --files <path>sortrg -n <val> <path>
  20. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0023–#0023

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

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

    1 call · #0024–#0024

    tail -n <n> <path>cat <path>
  22. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0025–#0025

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

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

    2 calls · #0026–#0027

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

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

    1 call · #0028–#0028

    ps <flag> <args>rg <val>head -n <n>ls -l <val>
  25. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0029–#0029

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

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

    2 calls · #0030–#0031

    rg --files <val> <path>rg <val>head -n <n>cat <path>tail -n <n>sed -n <val> <path>
  27. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0032–#0032

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

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

    1 call · #0033–#0033

    tail -n <n> <path>
  29. Inspect · Attention kernels

    1 tool error

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

    1 call · #0034–#0034

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

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

    1 call · #0035–#0035

    tail -n <n> <path>cut <flag>
  31. Inspect · Attention kernels

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

    1 call · #0036–#0036

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

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

    1 call · #0037–#0037

    tail -n <n> <path>cut <flag>cat <path>
  33. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0038–#0038

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

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

    1 call · #0039–#0039

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

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

    2 calls · #0040–#0041

    sed -n <val> <path>tail -n <n> <path>cut <flag>rg -n <val> <path>tail -n <n>
  36. Inspect · Device memory

    Requested file and log inspection related to device memory.

    1 call · #0042–#0042

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

    1 tool error

    Requested source searches related to batching & scheduling.

    1 call · #0043–#0043

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

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

    1 call · #0044–#0044

    tail -n <n> <path>cut <flag>cat <path>tail -c <n>
  39. Inspect · Attention kernels

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

    1 call · #0045–#0045

    rg -n <val> <path> <path> <path>head -n <n>sed -n <val> <path>
  40. Validate · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0046–#0046

    env <vars> bash <script> > <path> <n> >& <path>
  41. Validate · Benchmark & validation setup

    Requested workspace file updates and script or workload execution related to benchmark & validation setup.

    1 call · #0047–#0047

    <command> <args>cp <path> <path>python3 - <script>
  42. Validate · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0048–#0048

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

    Requested file and log inspection related to source & workspace.

    1 call · #0049–#0049

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

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

    1 call · #0050–#0050

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

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

    2 calls · #0051–#0052

    rg -n <val> <path>tail -n <n>rg -n <flag> <args>cat <path>
  46. Inspect · Speculative decoding

    Requested source searches and file and log inspection related to speculative decoding.

    1 call · #0053–#0053

    rg -n <val> <path>head -n <n>
  47. Validate · Benchmark & validation setup

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

    1 call · #0054–#0054

    tail -n <n> <path>cut <flag>python3 - <script>
  48. Inspect · Source & workspace

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

    3 calls · #0055–#0057

    sed -n <val> <path>rg -n <val> <path>rg -n <val> <path> <path>tail -n <n> <path>cut <flag>tail -n <n>
  49. Inspect · Attention kernels

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

    1 call · #0058–#0058

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

    Requested file and log inspection related to source & workspace.

    1 call · #0059–#0059

    tail -n <n> <path>cut <flag>
  51. Inspect · Attention kernels

    1 tool error

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

    1 call · #0060–#0060

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

    1 tool error

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

    2 calls · #0061–#0062

    tail -n <n> <path>cut <flag>ls -l <path> <n> > <path>sed -n <val> <path>rg -n <val> <path>head -n <n>
  53. Inspect · Speculative decoding

    Requested source searches and file and log inspection related to speculative decoding.

    1 call · #0063–#0063

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

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

    2 calls · #0064–#0065

    tail -n <n> <path>cut <flag>rg --files <val>sorttail -n <n>sed -n <val> <path>
  55. Inspect · Batching & scheduling

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

    1 call · #0066–#0066

    sed -n <val> <path>rg --files <path>rg <val>
  56. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0067–#0067

    python3 - <script>
  57. Other · Latency & request handling

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

    2 calls · #0068–#0069

    python3 - <script>tail -n <n> <path>cut <flag>
  58. Execute · Benchmark & validation setup

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

    1 call · #0070–#0070

    python3 - <script>
  59. Execute · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0071–#0071

    env <vars> bash <script> > <path> <n> >& <path>
  60. Inspect · Benchmark & validation setup

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

    1 call · #0072–#0072

    tail -n <n> <path>cut <flag>rg --files <val> -g <val>
  61. Validate · Benchmark & validation setup

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

    1 call · #0073–#0073

    python3 - <script>
  62. Edit · Attention kernels

    Requested code edits related to attention kernels.

    1 call · #0074–#0074

    Apply patch <patch>
  63. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0075–#0075

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

    Requested repository inspection related to source & workspace.

    1 call · #0076–#0076

    git diff --checkgit diff --stat
  65. Edit · Source & workspace

    Requested code edits related to source & workspace.

    2 calls · #0077–#0078

    Apply patch <patch>
  66. Inspect · Benchmark & validation setup

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

    1 call · #0079–#0079

    tail -n <n> <path>cut <flag>
  67. Inspect · Attention kernels

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

    1 call · #0080–#0080

    git diff --checksed -n <val> <path>python3 - <script>
  68. Validate · Attention kernels

    Requested environment setup or inspection related to attention kernels.

    1 call · #0081–#0081

    env <vars> python3 -m <module> <script> <script> -q > <path> <n> >& <path>
  69. Inspect · Benchmark & validation setup

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

    1 call · #0082–#0082

    tail -n <n> <path>cut <flag>
  70. Inspect · Speculative decoding

    Requested file and log inspection related to speculative decoding.

    1 call · #0083–#0083

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

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

    1 call · #0084–#0084

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

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

    1 call · #0085–#0085

    tail -n <n> <path>cut <flag>rg -n <val> <path>tail -n <n>
  73. Validate · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0086–#0086

    env <vars> bash <script> > <path> <n> >& <path>
  74. Inspect · Benchmark & validation setup

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

    1 call · #0087–#0087

    tail -n <n> <path>cut <flag>
  75. Inspect · Attention kernels

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

    2 calls · #0088–#0089

    sed -n <val> <path>rg -n <val> <path> <path>head -n <n>
  76. Validate · Benchmark & validation setup

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

    1 call · #0090–#0090

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

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

    1 call · #0091–#0091

    rg <val> <path>rg -n <val> <path>head -n <n>sed -n <val> <path>
  78. Validate · Benchmark & validation setup

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

    1 call · #0092–#0092

    python3 - <script>
  79. Edit · Attention kernels

    Requested code edits related to attention kernels.

    1 call · #0093–#0093

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

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

    1 call · #0094–#0094

    git diff --checktail -n <n> <path>cut <flag>
  81. Profile · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0095–#0095

    cat > <path> <script>
  82. Validate · Benchmark & validation setup

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

    1 call · #0096–#0096

    tail -n <n> <path>cut <flag>python3 - <script>
  83. Validate · Attention kernels

    Requested script or workload execution related to attention kernels.

    1 call · #0097–#0097

    python3 - <script>
  84. Execute · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0098–#0098

    env <vars> bash <script> > <path> <n> >& <path>
  85. Validate · Benchmark & validation setup

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

    1 call · #0099–#0099

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

    Requested file and log inspection related to source & workspace.

    1 call · #0100–#0100

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

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

    1 call · #0101–#0101

    git status --shortrg -n <val> <path>tail -n <n>
  88. Inspect · Source & workspace

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

    3 calls · #0102–#0104

    tail -n <n> <path>printenv <vars>rg --files <path>rg <val>head -n <n>
  89. Other · Source & workspace

    1 tool error

    Requested environment setup or inspection related to source & workspace.

    1 call · #0105–#0105

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

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

    1 call · #0106–#0106

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

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

    1 call · #0107–#0107

    rg -n <val> <path>tail -n <n>cut <flag>python3 - <script>
  92. Inspect · Batching & scheduling

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

    2 calls · #0108–#0109

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

    Requested code edits related to batching & scheduling.

    1 call · #0110–#0110

    Apply patch <patch>
  94. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0111–#0111

    Apply patch <patch>
  95. Inspect · Benchmark & validation setup

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

    1 call · #0112–#0112

    git diff --checktail -n <n> <path>cut <flag>
  96. Validate · Task requirements

    1 tool error

    Requested environment setup or inspection related to task requirements.

    1 call · #0113–#0113

    env <vars> bash <script> > <path> <n> >& <path>
  97. Inspect · Benchmark & validation setup

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

    1 call · #0114–#0114

    tail -n <n> <path>cut <flag>
  98. Inspect · Batching & scheduling

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

    1 call · #0115–#0115

    git diff --statsed -n <val> <path>
  99. Validate · Batching & scheduling

    Requested environment setup or inspection related to batching & scheduling.

    1 call · #0116–#0116

    env <vars> python3 -m <module> <script> <script> <script> -q > <path> <n> <args>
  100. Validate · Benchmark & validation setup

    1 tool error

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

    1 call · #0117–#0117

    python3 - <script>
  101. Inspect · Benchmark & validation setup

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

    2 calls · #0118–#0119

    cat <path>rg -n <flag> <args>tail -n <n>tail -n <n> <path>ps <flag> <args>rg <val>
    1 more command sketches
    head -n <n>
  102. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0120–#0120

    bash <script>
  103. Inspect · Batching & scheduling

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

    1 call · #0121–#0121

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

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

    1 call · #0122–#0122

    rg -n <val> <path>tail -n <n>
  105. Execute · Task requirements

    1 tool error

    Requested environment setup or inspection related to task requirements.

    1 call · #0123–#0123

    env <vars> bash <script> > <path> <n> >& <path>
  106. Validate · Benchmark & validation setup

    Requested process termination, runtime inspection and source searches related to benchmark & validation setup.

    2 calls · #0124–#0125

    kill <flag> <args>ps <flag> <args>rg <val>head -n <n>tail -n <n> <path>cut <flag>
    1 more command sketches
    python3 - <script>
  107. Profile · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0126–#0126

    env <vars> python3 - <script>
  108. Inspect · Source & workspace

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

    2 calls · #0127–#0128

    rg -n <flag> <args>sed -n <val> <path>tail -n <n> <path>rg --files <val> -g <val>
  109. Validate · Benchmark & validation setup

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

    1 call · #0129–#0129

    rg -n <val> <path>head -n <n>python3 - <script>
  110. Inspect · Batching & scheduling

    Requested file and log inspection related to batching & scheduling.

    1 call · #0130–#0130

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

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

    1 call · #0131–#0131

    rg -n <flag> <args>head -n <n>rg -n <val> <path> <path>
  112. Profile · Rollout generation

    1 tool error

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

    1 call · #0132–#0132

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

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

    2 calls · #0133–#0134

    tail -n <n> <path>cut <flag>python3 - <script>
  114. Validate · Attention kernels

    Requested script or workload execution and environment setup or inspection related to attention kernels.

    1 call · #0135–#0135

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

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

    3 calls · #0136–#0138

    tail -n <n> <path>python3 - <script>rg -n <val> <path> <path> <path>tail -n <n>rg -n <val> <path>head -n <n>
  116. Inspect · Speculative decoding

    Requested file and log inspection and source searches related to speculative decoding.

    1 call · #0139–#0139

    sed -n <val> <path>rg -n <val> <path>tail -n <n>
  117. Inspect · Device memory

    2 tool errors

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

    2 calls · #0140–#0141

    sed -n <val> <path>rg -n <flag> <args>rg -n <val> <path> <path>
  118. Inspect · Runtime processes

    Requested source searches and file and log inspection related to runtime processes.

    1 call · #0142–#0142

    rg -n <val> <path> <path>head -n <n>
  119. Inspect · Device memory

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

    1 call · #0143–#0143

    rg -n <flag> <args>head -n <n>sed -n <val> <path>rg -n <val> <path>
  120. Other · Attention kernels

    Requested script or workload execution related to attention kernels.

    1 call · #0144–#0144

    python3 - <script>
  121. Edit · Batching & scheduling

    Requested code edits related to batching & scheduling.

    1 call · #0145–#0145

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

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

    1 call · #0146–#0146

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

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

    2 calls · #0147–#0148

    tail -n <n> <path>cut <flag>git diff --check
  124. Inspect · Batching & scheduling

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

    1 call · #0149–#0149

    rg -n <val> <path> <path> <path> <path> <path>head -n <n>
  125. Other · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0150–#0150

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

    Requested file and log inspection related to source & workspace.

    1 call · #0151–#0151

    tail -n <n> <path>cut <flag>
  127. Edit · Batching & scheduling

    Requested code edits related to batching & scheduling.

    1 call · #0152–#0152

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

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

    1 call · #0153–#0153

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

    Requested environment setup or inspection related to batching & scheduling.

    1 call · #0154–#0154

    env <vars> python3 -m <module> <script> <script> <script> <script> -q > <path> <args>
  130. Inspect · Device memory

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

    1 call · #0155–#0155

    git diff --checkrg -n <val> <path>head -n <n>
  131. Validate · Benchmark & validation setup

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

    1 call · #0156–#0156

    tail -n <n> <path>cut <flag>python3 - <script>
  132. Execute · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0157–#0157

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

    Requested repository inspection related to source & workspace.

    1 call · #0158–#0158

    git status --short
  134. Validate · Benchmark & validation setup

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

    1 call · #0159–#0159

    python3 - <script>
  135. Validate · Task requirements

    Requested script or workload execution related to task requirements.

    1 call · #0160–#0160

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

    Requested repository inspection related to batching & scheduling.

    1 call · #0161–#0161

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

    Requested file and log inspection related to source & workspace.

    2 calls · #0162–#0163

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

    Requested file and log inspection related to task requirements.

    1 call · #0164–#0164

    cat <path>
  139. Inspect · Batching & scheduling

    Requested file and log inspection related to batching & scheduling.

    1 call · #0165–#0165

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

    Requested file and log inspection related to attention kernels.

    1 call · #0166–#0166

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

    Requested script or workload execution related to source & workspace.

    1 call · #0167–#0167

    python3 - <script>
  142. Inspect · Attention kernels

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

    1 call · #0168–#0168

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

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

    2 calls · #0169–#0170

    git diff <flag> <args>sed -n <val> <path>
  144. Inspect · Attention kernels

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

    1 call · #0171–#0171

    sed -n <val> <path>rg -n <val> <path>
  145. Inspect · Speculative decoding

    Requested repository inspection, file and log inspection and source searches related to speculative decoding.

    1 call · #0172–#0172

    git diff <flag> <args>sed -n <val> <path>rg -n <val> <path>head -n <n>
  146. Inspect · Device memory

    Requested source searches related to device memory.

    1 call · #0173–#0173

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

    Requested file and log inspection related to source & workspace.

    1 call · #0174–#0174

    tail -n <n> <path>
  148. Inspect · Device memory

    Requested file and log inspection related to device memory.

    1 call · #0175–#0175

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

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

    1 call · #0176–#0176

    sed -n <val> <path>rg -n <val> <path>head -n <n>
  150. Inspect · Device memory

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

    1 call · #0177–#0177

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

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

    1 call · #0178–#0178

    tail -n <n> <path>python3 - <script>
  152. Inspect · Batching & scheduling

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

    1 call · #0179–#0179

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

    Requested file and log inspection related to source & workspace.

    1 call · #0180–#0180

    tail -n <n> <path>
  154. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0181–#0181

    tail -n <n> <path>sed -n <val> <path>
  155. Profile · Rollout generation

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

    1 call · #0182–#0182

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

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

    1 call · #0183–#0183

    tail -n <n> <path>python3 - <script>
  157. Inspect · Device memory

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

    1 call · #0184–#0184

    rg -n <val> <path>head -n <n>rg --files <path>rg <val>
  158. Inspect · Batching & scheduling

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

    1 call · #0185–#0185

    sed -n <val> <path>rg --files <path>head -n <n>
  159. Edit · Batching & scheduling

    Requested code edits related to batching & scheduling.

    1 call · #0186–#0186

    Apply patch <patch>
  160. Inspect · Attention kernels

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

    1 call · #0187–#0187

    rg -n <val> <path> <path> <path>head -n <n>python3 - <script>tail -n <n> <path>
  161. Validate · Batching & scheduling

    Requested environment setup or inspection related to batching & scheduling.

    1 call · #0188–#0188

    env <vars> python3 -m <module> -q -p <val> <script> <script> <script> <script> <args>
  162. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0189–#0189

    tail -n <n> <path>
  163. Other · Rollout generation

    Requested script or workload execution and file and log inspection related to rollout generation.

    1 call · #0190–#0190

    python3 - <script>tail -n <n> <path>
  164. Other · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0191–#0191

    env <vars> python3 <script> > <path> <n> >& <path>
  165. Inspect · Batching & scheduling

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

    1 call · #0192–#0192

    rg -n <val> <path>sed -n <val> <path>tail -n <n> <path>
  166. Execute · Batching & scheduling

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

    1 call · #0193–#0193

    python3 - <script>sed -n <val> <path>
  167. Inspect · Source & workspace

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

    2 calls · #0194–#0195

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

    Requested script or workload execution related to source & workspace.

    1 call · #0196–#0196

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

    Requested file and log inspection related to source & workspace.

    1 call · #0197–#0197

    tail -n <n> <path>
  170. Other · Task requirements

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

    1 call · #0198–#0198

    python3 - <script>env <vars> python3 <script> > <path> <n> >& <path>
  171. Inspect · Runtime processes

    Requested source searches and file and log inspection related to runtime processes.

    1 call · #0199–#0199

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

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

    2 calls · #0200–#0201

    rg -n <val> <path>head -n <n>sed -n <val> <path>
  173. Edit · Attention kernels

    Requested code edits related to attention kernels.

    1 call · #0202–#0202

    Apply patch <patch>
  174. Inspect · Attention kernels

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

    2 calls · #0203–#0204

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

    Requested code edits related to source & workspace.

    1 call · #0205–#0205

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

    Requested file and log inspection related to source & workspace.

    1 call · #0206–#0206

    tail -n <n> <path>
  177. Validate · Attention kernels

    1 tool error

    Requested environment setup or inspection related to attention kernels.

    1 call · #0207–#0207

    env <vars> python3 -m <module> -q -p <val> <script> <script> > <path> <args>
  178. Other · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0208–#0208

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

    Requested file and log inspection related to source & workspace.

    2 calls · #0209–#0210

    tail -n <n> <path>sed -n <val> <path>
  180. Edit · Batching & scheduling

    Requested code edits related to batching & scheduling.

    1 call · #0211–#0211

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

    Requested repository inspection related to source & workspace.

    1 call · #0212–#0212

    git diff --check
  182. Validate · Attention kernels

    Requested environment setup or inspection related to attention kernels.

    1 call · #0213–#0213

    env <vars> python3 -m <module> -q -p <val> <script> <script> <script> <script> <args>
  183. Validate · Batching & scheduling

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

    1 call · #0214–#0214

    tail -n <n> <path>python3 - <script>
  184. Validate · Benchmark & validation setup

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

    1 call · #0215–#0215

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

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

    1 call · #0216–#0216

    python3 - <script>sed -n <val> <path>
  186. Validate · Benchmark & validation setup

    1 tool error

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

    3 calls · #0217–#0219

    python3 - <script>sed -n <val> <path>
  187. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0220–#0220

    cat <path>sed -n <val> <path>
  188. Validate · Benchmark & validation setup

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

    1 call · #0221–#0221

    python3 - <script>
  189. Execute · Batching & scheduling

    Requested environment setup or inspection related to batching & scheduling.

    1 call · #0222–#0222

    env <vars> bash <script> > <path> <n> >& <path>
  190. Execute · Benchmark & validation setup

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

    1 call · #0223–#0223

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

    Requested script or workload execution related to batching & scheduling.

    1 call · #0224–#0224

    python3 - <script>
  192. Edit · Batching & scheduling

    Requested code edits related to batching & scheduling.

    1 call · #0225–#0225

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

    Requested repository inspection related to source & workspace.

    1 call · #0226–#0226

    git diff --stat
  194. Validate · Benchmark & validation setup

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

    1 call · #0227–#0227

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

    Requested file and log inspection related to source & workspace.

    1 call · #0228–#0228

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

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

    2 calls · #0229–#0230

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

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

    1 call · #0231–#0231

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

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

    1 call · #0232–#0232

    tail -n <n> <path>python3 - <script>
  199. Inspect · Attention kernels

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

    1 call · #0233–#0233

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

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

    1 call · #0234–#0234

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

    Requested file and log inspection related to source & workspace.

    1 call · #0235–#0235

    tail -n <n> <path>
  202. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0236–#0236

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

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

    2 calls · #0237–#0238

    git diff --checksed -n <val> <path>tail -n <n> <path>python3 - <script>
  204. Validate · Attention kernels

    Requested environment setup or inspection related to attention kernels.

    1 call · #0239–#0239

    env <vars> python3 -m <module> -q -p <val> <script> <script> <script> <script> <args>
  205. Validate · Benchmark & validation setup

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

    1 call · #0240–#0240

    python3 - <script>tail -n <n> <path>
  206. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    2 calls · #0241–#0242

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

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

    1 call · #0243–#0243

    python3 - <script>
  208. Execute · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0244–#0244

    env <vars> bash <script> > <path> <n> >& <path>
  209. Validate · Benchmark & validation setup

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

    1 call · #0245–#0245

    python3 - <script>
  210. Edit · Attention kernels

    Requested code edits related to attention kernels.

    1 call · #0246–#0246

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

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

    1 call · #0247–#0247

    git diff --checksed -n <val> <path>
  212. Other · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0248–#0248

    env <vars> bash <script> > <path> <n> >& <path>
  213. Validate · Attention kernels

    Requested environment setup or inspection related to attention kernels.

    1 call · #0249–#0249

    env <vars> python3 -m <module> -q -p <val> <script> <script> <script> <script> <args>
  214. Build · Runtime processes

    Requested environment setup or inspection related to runtime processes.

    1 call · #0250–#0250

    env <vars> python3 - <script>
  215. Validate · Benchmark & validation setup

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

    1 call · #0251–#0251

    tail -n <n> <path>python3 - <script>
  216. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0252–#0252

    python3 - <script>
  217. Validate · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0253–#0253

    env <vars> bash <script> > <path> <n> >& <path>
  218. Other · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0254–#0254

    env <vars> python3 <script> > <path> <n> >& <path>
  219. Validate · Benchmark & validation setup

    Requested environment setup or inspection related to benchmark & validation setup.

    1 call · #0255–#0255

    env <vars> python3 - <script>
  220. Edit · Attention kernels

    Requested code edits related to attention kernels.

    1 call · #0256–#0256

    Apply patch <patch>
  221. Other · Source & workspace

    Requested environment setup or inspection related to source & workspace.

    1 call · #0257–#0257

    env <vars> bash <script> > <path> <n> >& <path>env <vars> python3 - <script>
  222. Inspect · Batching & scheduling

    Requested repository inspection related to batching & scheduling.

    1 call · #0258–#0258

    git diff <flag> <args>
  223. Inspect · Attention kernels

    Requested repository inspection related to attention kernels.

    1 call · #0259–#0259

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

    Requested repository inspection related to source & workspace.

    1 call · #0260–#0260

    git diff --checkgit status --shortgit <val> <val> <flag>
  225. Validate · Benchmark & validation setup

    Requested environment setup or inspection related to benchmark & validation setup.

    1 call · #0261–#0261

    env <vars> python3 - <script>
  226. Other · Source & workspace

    Requested environment setup or inspection related to source & workspace.

    1 call · #0262–#0262

    env <vars> python3 - <script>
  227. Validate · Benchmark & validation setup

    Requested environment setup or inspection related to benchmark & validation setup.

    1 call · #0263–#0263

    env <vars> python3 - <script>
  228. Execute · Benchmark & validation setup

    Requested environment setup or inspection related to benchmark & validation setup.

    2 calls · #0264–#0265

    env <vars> python3 - <script>
  229. Execute · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0266–#0266

    env <vars> bash <script> > <path> <n> >& <path>
  230. Validate · Benchmark & validation setup

    1 tool error

    Requested environment setup or inspection related to benchmark & validation setup.

    1 call · #0267–#0267

    env <vars> python3 - <script>
  231. Inspect · Attention kernels

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

    1 call · #0268–#0268

    rg -n <val> <path>head -n <n>
  232. Execute · Benchmark & validation setup

    Requested environment setup or inspection related to benchmark & validation setup.

    1 call · #0269–#0269

    env <vars> python3 - <script>
  233. Inspect · Source & workspace

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

    1 call · #0270–#0270

    rg -n <val> <path> <path> --glob <path>rg -n <val> <path> <path>head -n <n>
  234. Other · Source & workspace

    Requested environment setup or inspection related to source & workspace.

    1 call · #0271–#0271

    env <vars> python3 - <script>
  235. Inspect · Device memory

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

    2 calls · #0272–#0273

    cat <path>sed -n <val> <path>sed -n <val> <path> <n> > <path>rg --files <path>head -n <n>
  236. Edit · Device memory

    Requested code edits related to device memory.

    2 calls · #0274–#0275

    Apply patch <patch>
  237. Validate · Device memory

    Requested environment setup or inspection related to device memory.

    1 call · #0276–#0276

    env <vars> python3 -m <module> -q -p <val> <script> > <path> <n> <args>
  238. Inspect · Device memory

    Requested file and log inspection related to device memory.

    1 call · #0277–#0277

    tail -n <n> <path>
  239. Build · Device memory

    Requested environment setup or inspection and repository inspection related to device memory.

    1 call · #0278–#0278

    env <vars> python3 - <script>git diff --check
  240. Validate · Device memory

    Requested environment setup or inspection related to device memory.

    3 calls · #0279–#0281

    env <vars> python3 - <script>
  241. Execute · Device memory

    Requested environment setup or inspection related to device memory.

    1 call · #0282–#0282

    env <vars> python3 - <script>
  242. Other · Source & workspace

    Requested environment setup or inspection related to source & workspace.

    1 call · #0283–#0283

    env <vars> python3 - <script>
  243. Execute · Device memory

    Requested environment setup or inspection related to device memory.

    1 call · #0284–#0284

    env <vars> bash <script> > <path> <n> >& <path>
  244. Execute · Benchmark & validation setup

    Requested environment setup or inspection related to benchmark & validation setup.

    1 call · #0285–#0285

    env <vars> python3 - <script>
  245. Execute · Device memory

    Requested environment setup or inspection related to device memory.

    1 call · #0286–#0286

    env <vars> python3 - <script>
  246. Edit · Device memory

    Requested code edits related to device memory.

    1 call · #0287–#0287

    Apply patch <patch>
  247. Other · Device memory

    Requested environment setup or inspection and repository inspection related to device memory.

    1 call · #0288–#0288

    env <vars> python3 - <script>git diff --check
  248. Validate · Device memory

    Requested environment setup or inspection related to device memory.

    2 calls · #0289–#0290

    env <vars> python3 - <script>
  249. Execute · Device memory

    Requested environment setup or inspection related to device memory.

    1 call · #0291–#0291

    env <vars> python3 - <script>
  250. Validate · Device memory

    1 tool error

    Requested file and log inspection and environment setup or inspection related to device memory.

    1 call · #0292–#0292

    cat > <path> <script>env <vars> python3 <script> > <path> <n> >& <path>
  251. Other · Runtime processes

    Requested environment setup or inspection related to runtime processes.

    1 call · #0293–#0293

    env <vars> python3 - <script>
  252. Execute · Device memory

    1 missing return

    Requested environment setup or inspection related to device memory.

    1 call · #0294–#0294

    env <vars> python3 - <script>env <vars> bash <script> > <path> <n> >& <path>

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/hardware_backend/npu/allocator_npu.py b/python/sglang/srt/hardware_backend/npu/allocator_npu.pyindex 1a6ce9e6e4f73d1f004ed8ba6f109f9b19bb5dbf..2ba1adb79474f59b096ff5d584f07b011a107060 100644--- a/python/sglang/srt/hardware_backend/npu/allocator_npu.py+++ b/python/sglang/srt/hardware_backend/npu/allocator_npu.py@@ -62,17 +62,30 @@ class NPUPagedTokenToKVPoolAllocator(PagedTokenToKVPoolAllocator):                 dtype=torch.int64,                 device=self.device,             )-            max_num_extend_tokens = next_power_of_2(extend_num_tokens)+            # The kernel processes full pages in blocks of 2048 tokens. Smaller+            # bounds all execute one masked iteration, so use the same bound+            # rather than JIT-compiling a variant for each small extension size.+            block_size = 2048+            max_num_extend_tokens = max(+                block_size, next_power_of_2(extend_num_tokens)+            )+            # Slicing the free list alternates its pointer alignment. Triton+            # otherwise compiles another variant when the offset is odd. This+            # small device copy gives all calls the same aligned input pointer.+            free_pages = self.free_pages+            if free_pages.data_ptr() % 16:+                free_pages = free_pages.clone()             bs = prefix_lens.shape[0]             alloc_extend_kernel[(bs,)](                 prefix_lens,                 seq_lens,                 last_loc,-                self.free_pages,+                free_pages,                 out_indices,                 next_power_of_2(bs),                 self.page_size,                 max_num_extend_tokens,+                BLOCK_SIZE=block_size,             )          else:diff --git a/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py b/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.pyindex 89e9de06db1cb0350cb55b83dbaffc15c100fff9..6d0edbffa9c4fdae83df84545ccaae3ab49a662e 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,17 @@ 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()+        # The scheduler already maintains host sequence lengths. Reading a+        # device scalar here would synchronize the stream before every prefill.+        seq_lens_cpu = forward_batch.seq_lens_cpu+        if seq_lens_cpu is None:+            seq_lens_cpu = forward_batch.seq_lens.cpu()+        # Speculative passes can advance device lengths independently.+        seq_lens_max = (+            int(seq_lens_cpu.max())+            if forward_batch.spec_info is None+            else forward_batch.seq_lens.max()+        )         if forward_batch.forward_mode.is_target_verify():             seq_lens_max += self.speculative_num_draft_tokens         elif (@@ -438,29 +448,29 @@ class AscendAttnBackend(AttentionBackend):             and forward_batch.spec_info is not None         ):             seq_lens_max += self.speculative_step_id + 1-        self.forward_metadata.block_tables = (-            self.req_to_token_pool.req_to_token[-                forward_batch.req_pool_indices, :seq_lens_max-            ][:, :: self.page_size]-            // self.page_size-        )+        # Gather only the first token of each page, rather than materializing+        # every token in the longest context and then discarding most of them.+        block_indices = self.req_to_token_pool.req_to_token[+            forward_batch.req_pool_indices, :seq_lens_max : self.page_size+        ]+        self.forward_metadata.block_tables = block_indices // self.page_size         if self.is_hybrid_swa:             self.forward_metadata.block_tables_swa = (-                (-                    self.full_to_swa_index_mapping[-                        self.req_to_token_pool.req_to_token[-                            forward_batch.req_pool_indices, :seq_lens_max-                        ]-                    ][:, :: self.page_size]-                    // self.page_size-                )+                (self.full_to_swa_index_mapping[block_indices] // self.page_size)                 .to(torch.int32)                 .contiguous()             )         if forward_batch.extend_seq_lens is not None:             self.forward_metadata.extend_seq_lens = forward_batch.extend_seq_lens             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.spec_info is None+                and forward_batch.extend_seq_lens_cpu is not None+                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()@@ -469,7 +479,7 @@ class AscendAttnBackend(AttentionBackend):                 self.device             ).int() -        self.forward_metadata.seq_lens_cpu_int = forward_batch.seq_lens_cpu.int()+        self.forward_metadata.seq_lens_cpu_int = seq_lens_cpu.int()         if (             not forward_batch.forward_mode.is_draft_extend_v2()             and not forward_batch.forward_mode.is_target_verify()@@ -1520,6 +1530,16 @@ class AscendAttnBackend(AttentionBackend):                     and not getattr(self, "use_native_sdpa", False)                 ):                     if not self.use_alibi:+                        if any(+                            length % self.page_size+                            for length in forward_batch.extend_prefix_lens_cpu+                        ):+                            # Mixed prefill can leave a prefix between page+                            # boundaries. The paged qlens path gives incorrect+                            # causal attention at that offset; FIA supports it.+                            return self.forward_mixed(+                                q, k, v, layer, forward_batch, save_kv_cache=False+                            )                         query = q.reshape(-1, layer.tp_q_head_num * layer.qk_head_dim)                         attn_output = torch.empty(                             (query.shape[0], layer.tp_q_head_num * layer.v_head_dim),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..277cad48f252a610750c5794aa1806147dcfa376 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@@ -56,6 +56,7 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend):         self._device_id = self._device_module.current_device()         self._tp_group = cuda_graph_runner.model_runner.tp_group         self._capture_stream = None+        self._update_executor: Optional[ThreadPoolExecutor] = None         self._memory_saver_adapter: Optional[Any] = TorchMemorySaverAdapter.create(             enable=enable_memory_saver             and get_bool_env_var("SGLANG_MEMORY_SAVER_CUDA_GRAPH")@@ -165,18 +166,29 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend):             cpu_update_input = [{attr_name: seq_lens}]          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()+        if self._update_executor is None:+            # update must run concurrently with replay. Reuse one device-bound+            # worker instead of creating and joining a thread for every token.+            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:+            # Keep updates ordered and propagate worker errors to the caller.+            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..277ab5c99102ac8a8793813b22f3b8c33cd046d4 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@@ -242,6 +242,16 @@ class NPUGraphRunner(DecodeCudaGraphRunner):             if forward_batch.forward_mode.is_target_verify():                 seq_lens_cpu = forward_batch.seq_lens.cpu() + self.captured_req_width                 seq_lens = seq_lens_cpu.tolist() + [0] * (self.bs - self.raw_bs)+            elif (+                forward_batch.spec_info is None+                and forward_batch.seq_lens_cpu is not None+            ):+                # Ordinary decode advances both mirrors out of place, including+                # under overlap scheduling. Avoid a D2H synchronization after+                # staging graph inputs when the host lengths are already known.+                seq_lens = forward_batch.seq_lens_cpu.tolist() + [0] * (+                    self.bs - self.raw_bs+                )             else:                 seq_lens = forward_batch.seq_lens.cpu().tolist() + [0] * (                     self.bs - self.raw_bsdiff --git a/python/sglang/srt/managers/schedule_policy.py b/python/sglang/srt/managers/schedule_policy.pyindex 39bc02b780f94cb356d7314798203b7c4136dc00..3f1c5d43a31d5b3b5649ac81745d4fa6863dcb2e 100644--- a/python/sglang/srt/managers/schedule_policy.py+++ b/python/sglang/srt/managers/schedule_policy.py@@ -865,7 +865,7 @@ class PrefillAdder:             else AddReqResult.CONTINUE         ) -    def add_chunked_req(self, req: Req):+    def add_chunked_req(self, req: Req, reserved_tokens: int = 0):         if self.dllm_config is not None:             _rem_tokens = self._get_dllm_remain_tokens()         else:@@ -897,6 +897,21 @@ class PrefillAdder:         cand_extend_input_len = len(req.full_untruncated_fill_ids) - len(             req.prefix_indices         )+        shared_chunk_padding = 0+        if (+            self.dllm_config is None+            and reserved_tokens > 0+            and cand_extend_input_len > _rem_tokens+        ):+            # Leave room for a complete waiting prompt without parking the+            # in-flight chunk. KV allocation still rounds up to whole pages,+            # but that padding consumes no prefill compute tokens.+            shared_chunk_tokens = _rem_tokens - reserved_tokens+            if shared_chunk_tokens >= self.page_size:+                _rem_tokens = shared_chunk_tokens+                shared_chunk_padding = (+                    self.ceil_paged_tokens(_rem_tokens) - _rem_tokens+                )         truncated = cand_extend_input_len > _rem_tokens         new_len = min(cand_extend_input_len, _rem_tokens)         req.set_extend_range(len(req.prefix_indices), len(req.prefix_indices) + new_len)@@ -912,6 +927,11 @@ class PrefillAdder:             req.retracted_stain,             mamba_gap_reserve=self._mamba_gap_budget_for_req(req),         )+        # Retain the rounded memory reservations made above. Only return the+        # unused page padding to the compute budgets for this shared chunk.+        if shared_chunk_padding:+            self.rem_chunk_tokens += shared_chunk_padding+            self.rem_input_tokens += shared_chunk_padding          # Return if chunked prefill not finished         return req if truncated else None@@ -1068,6 +1088,16 @@ class PrefillAdder:         if (x := self.prefill_max_requests) is not None and len(self.can_run_list) >= x:             return AddReqResult.OTHER +        if (+            has_chunked_req+            and self.rem_chunk_tokens is not None+            and len(req.full_untruncated_fill_ids) - len(req.prefix_indices)+            > self.rem_chunk_tokens+        ):+            # There is only one slot for an unfinished prefill. Other requests+            # sharing its batch must fit in the remaining budget in full.+            return AddReqResult.OTHER+         if req.sampling_params.ignore_eos and getattr(self.tree_cache, "disable", True):             return self.add_one_req_ignore_eos(req) @@ -1211,6 +1241,10 @@ class PrefillAdder:                     mamba_gap_reserve=self._mamba_gap_budget_for_req(req),                 )             else:+                if has_chunked_req:+                    # An SWA budget can tighten the chunk limit after the+                    # initial check above. Do not create a second partial req.+                    return AddReqResult.OTHER                 # Make sure at least one page is available                 trunc_len = chunk_tokens_limit // self.page_size * self.page_size diff --git a/python/sglang/srt/managers/scheduler.py b/python/sglang/srt/managers/scheduler.pyindex a9615a14c512345b2d63323ff3ebd2fe3d9a0dca..55e630c83a77be98e4da0a881206483a8c90a84d 100644--- a/python/sglang/srt/managers/scheduler.py+++ b/python/sglang/srt/managers/scheduler.py@@ -3090,6 +3090,29 @@ class Scheduler(          return NextBatchPlan(batch_to_run=ret, running_batch=running_batch) +    def _get_num_mixed_decode_tokens(self, running_batch: ScheduleBatch) -> int:+        # Plan mixing before allocating the prefill budget. Logprobs and input+        # embeddings require a separate prefill, so reserve no decode tokens+        # if any candidate needs them. Keep this decision through admission,+        # even if the incompatible candidate does not fit in this batch.+        if (+            not self.is_mixed_chunk+            or running_batch.return_logprob+            or (+                self.chunked_req is not None+                and (+                    self.chunked_req.return_logprob+                    or self.chunked_req.input_embeds is not None+                )+            )+            or any(+                req.return_logprob or req.input_embeds is not None+                for req in self.waiting_queue+            )+        ):+            return 0+        return len(running_batch.reqs)+     def _get_new_batch_prefill_raw(         self,         prefill_delayer_single_pass: Optional[PrefillDelayerSinglePassExecutor],@@ -3156,6 +3179,7 @@ class Scheduler(                 chunked_prefill_size = dynamic_size          # Prefill policy+        num_mixed_decode_tokens = self._get_num_mixed_decode_tokens(running_batch)         adder = PrefillAdder(             self.page_size,             self.tree_cache,@@ -3164,7 +3188,7 @@ class Scheduler(             self.new_token_ratio_tracker.current,             self.max_prefill_tokens,             chunked_prefill_size,-            running_bs if self.is_mixed_chunk else 0,+            num_mixed_decode_tokens,             self.priority_scheduling_preemption_threshold,             max_prefill_bs=int(self.max_prefill_bs),             max_running_requests=self.max_running_requests,@@ -3176,7 +3200,31 @@ class Scheduler(          if self.chunked_req is not None:             self.chunked_req.init_next_round_input()-            self.chunked_req = adder.add_chunked_req(self.chunked_req)+            reserved_tokens = 0+            if (+                _is_npu+                and self.is_mixed_chunk+                and self.ps.pp_size == 1+                and self.waiting_queue+                and not self.enable_lora+                and self.dllm_config is None+                and self.get_num_allocatable_reqs(running_bs) > 1+                and (+                    adder.prefill_max_requests is None or adder.prefill_max_requests > 1+                )+            ):+                # A long prompt must keep advancing, but need not occupy every+                # prefill slot until it finishes. Reserve at most half a chunk+                # for the head of the waiting queue, preserving queue order.+                waiting_req = self.waiting_queue[0]+                waiting_tokens = adder.ceil_paged_tokens(+                    len(waiting_req.origin_input_ids) + len(waiting_req.output_ids)+                )+                if waiting_tokens <= chunked_prefill_size // 2:+                    reserved_tokens = waiting_tokens+            self.chunked_req = adder.add_chunked_req(+                self.chunked_req, reserved_tokens=reserved_tokens+            )          if self.enable_lora:             running_loras = {@@ -3332,7 +3380,7 @@ class Scheduler(          # Mixed-style chunked prefill         if (-            self.is_mixed_chunk+            num_mixed_decode_tokens > 0             and not running_batch.is_empty()             and not (new_batch.return_logprob or running_batch.return_logprob)             # mix_with_running cats input_ids but not input_embeds — shapes would mismatchdiff --git a/python/sglang/test/ascend/test_mixed_chunk_budget.py b/python/sglang/test/ascend/test_mixed_chunk_budget.pynew file mode 100644index 0000000000000000000000000000000000000000..4e54ce213b5a6ffa20fb15d7d9f1247255144449--- /dev/null+++ b/python/sglang/test/ascend/test_mixed_chunk_budget.py@@ -0,0 +1,149 @@+"""Admission tests for sharing a prefill budget with a live chunked request."""++import unittest+from types import SimpleNamespace+from unittest.mock import Mock++from sglang.srt.managers.schedule_policy import AddReqResult, PrefillAdder+from sglang.srt.managers.scheduler import Scheduler+from sglang.srt.server_args import ServerArgs, set_global_server_args_for_scheduler+from sglang.srt.utils.common import Range+++def make_req(length, *, ignore_eos=True):+    req = SimpleNamespace(+        prefix_indices=[],+        full_untruncated_fill_ids=list(range(length)),+        origin_input_ids=list(range(length)),+        output_ids=[],+        sampling_params=SimpleNamespace(max_new_tokens=32, ignore_eos=ignore_eos),+        retracted_stain=False,+    )+    req.set_extend_range = lambda start, end: setattr(+        req, "extend_range", Range(start, end)+    )+    return req+++class TestMixedChunkBudget(unittest.TestCase):+    def setUp(self):+        set_global_server_args_for_scheduler(ServerArgs(model_path="dummy"))++    def make_adder(self, chunk_tokens=32, decode_tokens=3):+        tree_cache = Mock()+        tree_cache.disable = True+        tree_cache.supports_mamba.return_value = False+        tree_cache.evictable_size.return_value = 0+        allocator = Mock()+        allocator.available_size.return_value = 100000+        return PrefillAdder(+            page_size=4,+            tree_cache=tree_cache,+            token_to_kv_pool_allocator=allocator,+            running_batch=SimpleNamespace(reqs=[]),+            new_token_ratio=1.0,+            rem_input_tokens=1024,+            rem_chunk_tokens=chunk_tokens,+            num_mixed_decode_tokens=decode_tokens,+        )++    def test_long_chunk_and_complete_prompt_share_budget(self):+        adder = self.make_adder()+        long_req = make_req(200)+        short_req = make_req(8)+        self.assertIs(adder.add_chunked_req(long_req, reserved_tokens=8), long_req)+        self.assertEqual(long_req.extend_range.length, 21)+        self.assertEqual(adder.rem_chunk_tokens, 8)+        adder.add_one_req(short_req, has_chunked_req=True, truncation_align_size=None)+        self.assertEqual(short_req.extend_range.length, 8)+        self.assertEqual(adder.can_run_list, [long_req, short_req])+        self.assertIsNone(adder.new_chunked_req)+        self.assertEqual(+            sum(req.extend_range.length for req in adder.can_run_list) + 3, 32+        )+        self.assertEqual(adder.rem_chunk_tokens, 0)+        self.assertEqual(adder.rem_input_tokens, 1024 - 32)+        # Decode + rounded input pages + one allocation slack page per req.+        self.assertEqual(adder.cur_rem_token_offset, 3 + 24 + 8 + 2 * 4)++    def test_residual_budget_cannot_create_another_partial_request(self):+        for ignore_eos in (False, True):+            with self.subTest(ignore_eos=ignore_eos):+                adder = self.make_adder()+                long_req = make_req(200)+                adder.add_chunked_req(long_req, reserved_tokens=8)+                adder.add_one_req(+                    make_req(8), has_chunked_req=True, truncation_align_size=None+                )+                rejected = make_req(8, ignore_eos=ignore_eos)+                result = adder.add_one_req(+                    rejected, has_chunked_req=True, truncation_align_size=None+                )+                self.assertEqual(result, AddReqResult.OTHER)+                self.assertNotIn(rejected, adder.can_run_list)+                self.assertIsNone(adder.new_chunked_req)+                self.assertFalse(hasattr(rejected, "extend_range"))++    def test_last_chunk_finishes_without_a_reservation(self):+        adder = self.make_adder()+        req = make_req(24)+        self.assertIsNone(adder.add_chunked_req(req, reserved_tokens=8))+        self.assertEqual(req.extend_range.length, 24)+        self.assertEqual(adder.can_run_list, [req])++    def test_reservation_cannot_park_the_existing_chunk(self):+        adder = self.make_adder(chunk_tokens=8, decode_tokens=5)+        req = make_req(200)+        self.assertIs(adder.add_chunked_req(req, reserved_tokens=8), req)+        self.assertGreater(req.extend_range.length, 0)+        self.assertEqual(adder.can_run_list, [req])++    def test_no_reservation_retains_the_original_chunk_budget(self):+        adder = self.make_adder()+        req = make_req(200)+        self.assertIs(adder.add_chunked_req(req), req)+        self.assertEqual(req.extend_range.length, 29)++    def test_only_decode_requests_that_can_mix_consume_input_budget(self):+        scheduler = Scheduler.__new__(Scheduler)+        scheduler.waiting_queue = []+        for mixed, running_logprob, chunk_logprob, expected in (+            (True, False, False, 3),+            (True, True, False, 0),+            (True, False, True, 0),+            (False, False, False, 0),+        ):+            with self.subTest(+                mixed=mixed, running_logprob=running_logprob, chunk_logprob=chunk_logprob+            ):+                scheduler.is_mixed_chunk = mixed+                scheduler.chunked_req = SimpleNamespace(+                    return_logprob=chunk_logprob, input_embeds=None+                )+                running = SimpleNamespace(+                    reqs=[object(), object(), object()], return_logprob=running_logprob+                )+                self.assertEqual(+                    scheduler._get_num_mixed_decode_tokens(running), expected+                )++    def test_waiting_incompatible_prefill_does_not_reserve_decode_tokens(self):+        scheduler = Scheduler.__new__(Scheduler)+        scheduler.is_mixed_chunk = True+        running = SimpleNamespace(reqs=[object()], return_logprob=False)+        plain = SimpleNamespace(return_logprob=False, input_embeds=None)+        for incompatible in (+            SimpleNamespace(return_logprob=True, input_embeds=None),+            SimpleNamespace(return_logprob=False, input_embeds=[[0.0]]),+        ):+            for chunk in (None, plain, incompatible):+                scheduler.chunked_req = chunk+                scheduler.waiting_queue = [plain, incompatible]+                self.assertEqual(scheduler._get_num_mixed_decode_tokens(running), 0)+            scheduler.chunked_req = incompatible+            scheduler.waiting_queue = [plain]+            self.assertEqual(scheduler._get_num_mixed_decode_tokens(running), 0)+++if __name__ == "__main__":+    unittest.main()diff --git a/python/sglang/test/ascend/test_npu_allocator.py b/python/sglang/test/ascend/test_npu_allocator.pynew file mode 100644index 0000000000000000000000000000000000000000..f73e699375be6ddc7f7e7b872c316184864c9c59--- /dev/null+++ b/python/sglang/test/ascend/test_npu_allocator.py@@ -0,0 +1,69 @@+"""Exercise NPU page allocation across extension-size compilation buckets."""++import unittest++import torch++from sglang.srt.hardware_backend.npu.allocator_npu import (+    NPUPagedTokenToKVPoolAllocator,+)+++@unittest.skipUnless(+    hasattr(torch, "npu") and torch.npu.is_available(), "requires an NPU"+)+class TestNPUExtendAllocation(unittest.TestCase):+    def test_partial_pages_and_multiple_kernel_blocks(self):+        page_size = 128+        for lengths in ([1], [17, 511], [1025, 2090, 7]):+            for free_offset in (0, 1):+                with self.subTest(lengths=lengths, free_offset=free_offset):+                    prefixes = [0, 250, 128][: len(lengths)]+                    seq_lens = [p + n for p, n in zip(prefixes, lengths)]+                    last_locs = [+                        (10 + i) * page_size + (p - 1) % page_size+                        for i, p in enumerate(prefixes)+                    ]+                    pages = list(range(100 + free_offset, 200))+                    expected = []+                    used_pages = 0+                    for prefix, length, last in zip(prefixes, lengths, last_locs):+                        tail = prefix % page_size+                        old_count = min(length, page_size - tail) if tail else 0+                        expected.extend(range(last + 1, last + 1 + old_count))+                        remaining = length - old_count+                        while remaining:+                            count = min(remaining, page_size)+                            start = pages[used_pages] * page_size+                            expected.extend(range(start, start + count))+                            used_pages += 1+                            remaining -= count++                    pool = NPUPagedTokenToKVPoolAllocator.__new__(+                        NPUPagedTokenToKVPoolAllocator+                    )+                    pool.device = "npu"+                    pool.page_size = page_size+                    pool.roundup = page_size - 1+                    pool.debug_mode = True+                    pool.need_sort = False+                    pool.free_pages = torch.arange(+                        100, 200, dtype=torch.int64, device="npu"+                    )[free_offset:]+                    prefix_cpu = torch.tensor(prefixes, dtype=torch.int64)+                    seq_cpu = torch.tensor(seq_lens, dtype=torch.int64)+                    actual = pool.alloc_extend(+                        prefix_cpu.npu(),+                        prefix_cpu,+                        seq_cpu.npu(),+                        seq_cpu,+                        torch.tensor(last_locs, dtype=torch.int64, device="npu"),+                        sum(lengths),+                        num_new_pages=used_pages,+                    )+                    self.assertEqual(actual.cpu().tolist(), expected)+                    self.assertEqual(pool.free_pages.cpu().tolist(), pages[used_pages:])+++if __name__ == "__main__":+    unittest.main()diff --git a/python/sglang/test/ascend/test_npu_graph_host_overhead.py b/python/sglang/test/ascend/test_npu_graph_host_overhead.pynew file mode 100644index 0000000000000000000000000000000000000000..e19e8199ebc0201598f650912c27186135d8d1ce--- /dev/null+++ b/python/sglang/test/ascend/test_npu_graph_host_overhead.py@@ -0,0 +1,234 @@+"""Host metadata and update-worker regression coverage for NPU graph replay."""++import threading+import unittest+from types import SimpleNamespace+from unittest.mock import Mock, patch++import torch++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.layers.radix_attention import AttentionType+from sglang.srt.model_executor.forward_batch_info import ForwardMode+++class TestNPUUpdateWorker(unittest.TestCase):+    def make_backend(self):+        device = SimpleNamespace(current_device=lambda: 0, set_device=Mock())+        backend = NPUCudaGraphBackend(+            SimpleNamespace(+                device_module=device,+                model_runner=SimpleNamespace(tp_group=None),+            )+        )+        self.addCleanup(backend.cleanup)+        return backend, device++    def test_update_overlaps_replay_and_reuses_worker(self):+        backend, device = self.make_backend()+        worker_ids = []+        seen_inputs = []+        update_started = threading.Event()+        replay_started = threading.Event()++        def update(*, cpu_update_input):+            worker_ids.append(threading.get_ident())+            seen_inputs.append(cpu_update_input)+            update_started.set()+            if not replay_started.wait(timeout=5):+                raise RuntimeError("replay did not overlap the update")++        def replay():+            self.assertTrue(update_started.wait(timeout=5))+            replay_started.set()++        output = object()+        backend._graphs[1] = SimpleNamespace(update=update, replay=replay)+        backend._outputs[1] = output+        for lengths in ([7], [8], [9]):+            update_started.clear()+            replay_started.clear()+            self.assertIs(+                backend.replay_with_input_update(+                    1, lengths, attr_name="actual_seq_lengths_kv"+                ),+                output,+            )+        self.assertEqual(len(set(worker_ids)), 1)+        self.assertNotEqual(worker_ids[0], threading.get_ident())+        self.assertEqual(+            seen_inputs,+            [[{"actual_seq_lengths_kv": [n]}] for n in (7, 8, 9)],+        )+        device.set_device.assert_called_once_with(0)+        backend.cleanup()+        self.assertIsNone(backend._update_executor)+        self.assertFalse(backend._graphs)++    def test_update_error_reaches_caller(self):+        backend, _ = self.make_backend()+        backend._graphs[1] = SimpleNamespace(+            update=Mock(side_effect=RuntimeError("update failed")), replay=Mock()+        )+        backend._outputs[1] = object()+        with self.assertRaisesRegex(RuntimeError, "update failed"):+            backend.replay_with_input_update(1, [4], attr_name="lengths")++    def test_replay_error_still_waits_for_update(self):+        backend, _ = self.make_backend()+        replay_started = threading.Event()+        update_finished = threading.Event()++        def update(**kwargs):+            if not replay_started.wait(timeout=5):+                raise RuntimeError("replay did not start")+            update_finished.set()++        def replay():+            replay_started.set()+            raise RuntimeError("replay failed")++        backend._graphs[1] = SimpleNamespace(update=update, replay=replay)+        backend._outputs[1] = object()+        with self.assertRaisesRegex(RuntimeError, "replay failed"):+            backend.replay_with_input_update(1, [4], attr_name="lengths")+        self.assertTrue(update_finished.is_set())+++class TestNPUHostSequenceLengths(unittest.TestCase):+    def test_unaligned_prefill_uses_fia_after_writing_kv_once(self):+        backend = AscendAttnBackend.__new__(AscendAttnBackend)+        backend.page_size = 128+        backend.use_mla = False+        backend.is_dllm_model = False+        backend.is_hybrid_swa = False+        backend.use_fia = False+        backend.use_fa = False+        backend.use_alibi = False+        backend.token_to_kv_pool = Mock()+        backend.forward_metadata = SimpleNamespace(swa_out_cache_loc=None)+        expected = torch.zeros(3, 128)+        backend.forward_mixed = Mock(return_value=expected)+        layer = SimpleNamespace(+            layer_id=0,+            is_cross_attention=False,+            attn_type=AttentionType.DECODER,+            qk_head_dim=128,+            logit_cap=0,+        )+        batch = SimpleNamespace(+            forward_mode=ForwardMode.EXTEND,+            attn_cp_metadata=None,+            out_cache_loc=torch.arange(3),+            encoder_lens=None,+            extend_prefix_lens_cpu=[1023, 0],+        )+        q, k, v = (torch.ones(3, 128) for _ in range(3))+        with patch(+            "sglang.srt.hardware_backend.npu.attention.ascend_backend.is_mla_preprocess_enabled",+            return_value=False,+        ):+            result = backend.forward_extend(q, k, v, layer, batch)+        self.assertIs(result, expected)+        backend.token_to_kv_pool.set_kv_buffer.assert_called_once()+        backend.forward_mixed.assert_called_once_with(+            q, k, v, layer, batch, save_kv_cache=False+        )++    def test_decode_uses_host_lengths_and_pads_graph_batch(self):+        runner = NPUGraphRunner.__new__(NPUGraphRunner)+        runner.load_batch = Mock()+        runner.bs = 4+        runner.raw_bs = 3+        runner.raw_num_token = 3+        runner.is_dllm = False+        runner._make_graph_key = Mock(return_value=4)+        runner._get_update_attr_name = Mock(return_value="actual_seq_lengths_kv")+        runner._get_update_attr_type = Mock(return_value=[])+        runner.model_runner = SimpleNamespace(+            model_config=SimpleNamespace(+                hf_config=SimpleNamespace(architectures=["Qwen3ForCausalLM"])+            )+        )+        runner.backend = SimpleNamespace(+            replay_with_input_update=Mock(+                return_value=LogitsProcessorOutput(next_token_logits=torch.zeros(4, 8))+            )+        )+        device_lengths = Mock()+        device_lengths.cpu.side_effect = AssertionError("unexpected device sync")+        batch = SimpleNamespace(+            needs_forward_metadata_init=lambda: True,+            forward_mode=ForwardMode.DECODE,+            spec_info=None,+            seq_lens=device_lengths,+            seq_lens_cpu=torch.tensor([15, 257, 31]),+        )+        output = runner.execute(batch)+        self.assertEqual(output.next_token_logits.shape, (3, 8))+        self.assertEqual(+            runner.backend.replay_with_input_update.call_args.kwargs["seq_lens"],+            [15, 257, 31, 0],+        )+        device_lengths.cpu.assert_not_called()++    def test_prefill_page_tables_match_tokenwise_gather(self):+        for swa, speculative in ((False, False), (True, False), (False, True)):+            with self.subTest(swa=swa, speculative=speculative):+                backend = AscendAttnBackend.__new__(AscendAttnBackend)+                backend.page_size = 4+                backend.device = "cpu"+                backend.is_hybrid_swa = swa+                backend.use_mla = False+                backend.use_sliding_window_kv_pool = False+                table = torch.arange(3 * 24, dtype=torch.int32).reshape(3, 24)+                backend.req_to_token_pool = SimpleNamespace(req_to_token=table)+                backend.full_to_swa_index_mapping = torch.arange(72) + 8+                device_lengths = Mock()+                device_lengths.int.return_value = torch.tensor([13, 7])+                device_lengths.max.return_value = 13+                if not speculative:+                    device_lengths.max.side_effect = AssertionError("device scalar read")+                extend_lengths = Mock()+                extend_lengths.cpu.return_value = torch.tensor([5, 7])+                if not speculative:+                    extend_lengths.cpu.side_effect = AssertionError("device copy")+                batch = SimpleNamespace(+                    forward_mode=ForwardMode.EXTEND,+                    seq_lens=device_lengths,+                    seq_lens_cpu=torch.tensor([13, 7]),+                    spec_info=object() if speculative else None,+                    req_pool_indices=torch.tensor([2, 0]),+                    extend_seq_lens=extend_lengths,+                    extend_seq_lens_cpu=[5, 7],+                )+                backend.init_forward_metadata(batch)+                metadata = backend.forward_metadata+                selected = table[batch.req_pool_indices, :13]+                torch.testing.assert_close(+                    metadata.block_tables, selected[:, ::4] // 4+                )+                torch.testing.assert_close(+                    metadata.extend_seq_lens_cpu_int,+                    torch.tensor([5, 7], dtype=torch.int32),+                )+                if swa:+                    torch.testing.assert_close(+                        metadata.block_tables_swa,+                        (backend.full_to_swa_index_mapping[selected][:, ::4] // 4).int(),+                    )+                if speculative:+                    device_lengths.max.assert_called_once()+                    extend_lengths.cpu.assert_called_once()+                else:+                    device_lengths.max.assert_not_called()+                    extend_lengths.cpu.assert_not_called()+++if __name__ == "__main__":+    unittest.main()