GPT-6 Astra · Serving

S02 · Saturation

Valid

Online saturation throughput 1dev · Implementation Optimization

1.50×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
171Inspect
13Edit
18Validate
16Execute
13Profile
30Other

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 timeline226 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 · Source & workspace

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

    1 call · #0001–#0001

    pwdprintenv <vars>
  2. Inspect · Task requirements

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

    3 calls · #0002–#0004

    rg --files -g <val> -g <path> -g <path> -g <path> -g <path> <args>cat <path> <path><command> <args>
  3. Inspect · Source & workspace

    Requested repository inspection related to source & workspace.

    1 call · #0005–#0005

    git status --short
  4. Inspect · Task requirements

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

    2 calls · #0006–#0007

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

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

    1 call · #0008–#0008

    cat <path> <path> <path> <path> <path>
  6. Inspect · Source & workspace

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

    2 calls · #0009–#0010

    cat <path>rg --files <path>rg <val>
  7. Other · Task requirements

    Requested script or workload execution related to task requirements.

    1 call · #0011–#0011

    python - <script>
  8. Other · Source & workspace

    1 tool error

    Requested script or workload execution related to source & workspace.

    1 call · #0012–#0012

    bash <script>
  9. Inspect · Benchmark & validation setup

    Requested source searches related to benchmark & validation setup.

    1 call · #0013–#0013

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

    Requested file and log inspection related to source & workspace.

    1 call · #0014–#0014

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

    Requested environment setup or inspection related to source & workspace.

    1 call · #0015–#0015

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

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

    4 calls · #0016–#0019

    sed -n <val> <path>rg -n <val> <path>head -n <n>printenv <vars>
  13. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0020–#0020

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

    Requested file and log inspection related to source & workspace.

    1 call · #0021–#0021

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

    Requested file and log inspection related to attention kernels.

    1 call · #0022–#0022

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

    1 tool error

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

    1 call · #0023–#0023

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

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

    1 call · #0024–#0024

    ls -l -a <val>sed -n <val> <path>
  18. Inspect · Attention kernels

    Requested source searches related to attention kernels.

    1 call · #0025–#0025

    rg -n <val> <path> <path> <path>
  19. Other · Device memory

    Requested runtime inspection related to device memory.

    1 call · #0026–#0026

    npu-smi info
  20. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0027–#0027

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

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

    1 call · #0028–#0028

    tail -n <n> <path>
  22. Inspect · Speculative decoding

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

    1 call · #0029–#0029

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

    Requested file and log inspection related to attention kernels.

    1 call · #0030–#0030

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

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

    2 calls · #0031–#0032

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

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

    1 call · #0033–#0033

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

    Requested file and log inspection related to source & workspace.

    1 call · #0034–#0034

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

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

    1 call · #0035–#0035

    cat <path>rg -n <val> <path> <path> <path> <path>
  28. Inspect · Batching & scheduling

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

    1 call · #0036–#0036

    rg -n <val> <path> <path> <path>head -n <n>cat <path>
  29. Inspect · Benchmark & validation setup

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

    2 calls · #0037–#0038

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

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

    1 call · #0039–#0039

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

    Requested file and log inspection related to source & workspace.

    1 call · #0040–#0040

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

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

    1 call · #0041–#0041

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

    1 tool error

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

    1 call · #0042–#0042

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

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

    1 call · #0043–#0043

    tail -n <n> <path>cut -c <val>
  35. Inspect · Runtime processes

    Requested runtime inspection and source searches related to runtime processes.

    1 call · #0044–#0044

    ps <flag> <args>rg <val>cut -c <val>
  36. Inspect · Batching & scheduling

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

    1 call · #0045–#0045

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

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

    1 call · #0046–#0046

    rg --files <val>rg <val>rg -n <val> <path>sed -n <val> <path>
  38. Inspect · Device memory

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

    1 call · #0047–#0047

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

    Requested file and log inspection related to attention kernels.

    1 call · #0048–#0048

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

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

    1 call · #0049–#0049

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

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

    1 call · #0050–#0050

    cat <path>rg -n <val> <path> <path>rg -n <val> <path>
  42. Inspect · Dependencies & build setup

    Requested source searches and file and log inspection related to dependencies & build setup.

    1 call · #0051–#0051

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

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

    1 call · #0052–#0052

    python - <script>
  44. Profile · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0053–#0053

    env <vars> python - <script>
  45. Validate · Benchmark & validation setup

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

    1 call · #0054–#0054

    python - <script>
  46. Inspect · Source & workspace

    1 tool error

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

    1 call · #0055–#0055

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

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

    1 call · #0056–#0056

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

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

    1 call · #0057–#0057

    cat <path>rg --files <path>rg <val>
  49. Inspect · Runtime processes

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

    1 call · #0058–#0058

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

    1 tool error

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

    2 calls · #0059–#0060

    rg -n <val> <path>head -n <n>rg --files <path>rg <val>
  51. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0061–#0061

    python - <script>
  52. Inspect · Source & workspace

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

    2 calls · #0062–#0063

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

    Requested script or workload execution related to source & workspace.

    1 call · #0064–#0064

    python - <script>
  54. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0065–#0065

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

    Requested file and log inspection related to source & workspace.

    1 call · #0066–#0066

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

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

    1 call · #0067–#0067

    git diff --statrg --files <path>rg <val>head -n <n>
  57. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0068–#0068

    python - <script>
  58. Inspect · Source & workspace

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

    2 calls · #0069–#0070

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

    Requested script or workload execution related to source & workspace.

    1 call · #0071–#0071

    python - <script>
  60. Profile · Task requirements

    Requested file and log inspection related to task requirements.

    1 call · #0072–#0072

    cat > <path> <script>
  61. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0073–#0073

    python - <script>
  62. Inspect · Attention kernels

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

    1 call · #0074–#0074

    cat <path>rg -n <val> <path>head -n <n>
  63. Inspect · Source & workspace

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

    1 call · #0075–#0075

    rg -n <val> <path>rg -n <val> <path> -g <path>head -n <n>
  64. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0076–#0076

    python - <script>
  65. Validate · Benchmark & validation setup

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

    1 call · #0077–#0077

    command -v <val> <val> <val>sed -n <val> <path>rg -n <val> <path>
  66. Inspect · Source & workspace

    Requested repository inspection related to source & workspace.

    1 call · #0078–#0078

    git status --short
  67. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0079–#0079

    python - <script>
  68. Execute · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0080–#0080

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

    1 tool error

    Requested source searches related to batching & scheduling.

    1 call · #0081–#0081

    rg -n <val> <path> <path> -g <path>rg -n <val> <path>
  70. Execute · Benchmark & validation setup

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

    1 call · #0082–#0082

    python - <script>
  71. Validate · Benchmark & validation setup

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

    1 call · #0083–#0083

    python - <script>
  72. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0084–#0084

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

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

    1 call · #0085–#0085

    rg -n <val> <path>cat <path>head -n <n>
  74. Inspect · Source & workspace

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

    1 call · #0086–#0086

    tail -n <n> <path>git diff --check
  75. Inspect · Batching & scheduling

    Requested file and log inspection related to batching & scheduling.

    1 call · #0087–#0087

    sed -n <val> <path>
  76. Validate · Source & workspace

    Requested environment setup or inspection related to source & workspace.

    1 call · #0088–#0088

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

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

    2 calls · #0089–#0090

    rg -n <val> <path>tail -n <n>sed -n <val> <path>tail -n <n> <path>python - <script>
  78. Inspect · Attention kernels

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

    1 call · #0091–#0091

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

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

    4 calls · #0092–#0095

    git diff <flag> <args>rg -n <val> <path>head -n <n>sed -n <val> <path>python - <script>rg -n <val> <path> <path>
  80. Inspect · KV-cache management

    Requested source searches and file and log inspection related to kv-cache management.

    1 call · #0096–#0096

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

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

    2 calls · #0097–#0098

    tail -n <n> <path>git diff --numstatps <flag> <args>rg <path>cut -c <val>
  82. Inspect · Source & workspace

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

    1 call · #0099–#0099

    rg -n <val> <path>head -n <n>
  83. Execute · Batching & scheduling

    Requested script or workload execution related to batching & scheduling.

    1 call · #0100–#0100

    python - <script>
  84. Validate · Batching & scheduling

    Requested environment setup or inspection related to batching & scheduling.

    1 call · #0101–#0101

    env <vars> pytest -q <path> <path> <path> > <path> <n> >& <path>
  85. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0102–#0102

    sed -n <val> <path>
  86. Execute · Benchmark & validation setup

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

    1 call · #0103–#0103

    tail -n <n> <path>python - <script>
  87. Inspect · Source & workspace

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

    2 calls · #0104–#0105

    rg --files <path>rg <val>head -n <n>rg -n <val> <path> -g <path>
  88. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0106–#0106

    python - <script>
  89. Inspect · Attention kernels

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

    1 call · #0107–#0107

    rg -n <val> <path>head -n <n>
  90. Execute · Batching & scheduling

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

    1 call · #0108–#0108

    tail -n <n> <path>python - <script>
  91. Execute · Benchmark & validation setup

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

    1 call · #0109–#0109

    python <script> <val> <val> > <path> <n> >& <path>
  92. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0110–#0110

    cat > <path> <script>
  93. Execute · Benchmark & validation setup

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

    1 call · #0111–#0111

    python - <script>
  94. Validate · Benchmark & validation setup

    Requested script or workload execution, repository inspection and environment setup or inspection related to benchmark & validation setup.

    1 call · #0112–#0112

    python - <script>git diff > <path>env <vars> python <script> > <path> <n> >& <path>
  95. Edit · Batching & scheduling

    Requested code edits related to batching & scheduling.

    1 call · #0113–#0113

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

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

    1 call · #0114–#0114

    tail -n <n> <path>
  97. Other · Benchmark & validation setup

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

    1 call · #0115–#0115

    python - <script>
  98. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0116–#0116

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

    Requested repository inspection related to source & workspace.

    1 call · #0117–#0117

    git diff --check
  100. Inspect · Batching & scheduling

    Requested file and log inspection related to batching & scheduling.

    1 call · #0118–#0118

    sed -n <val> <path>
  101. Execute · Benchmark & validation setup

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

    1 call · #0119–#0119

    python - <script>
  102. Validate · Source & workspace

    Requested environment setup or inspection related to source & workspace.

    1 call · #0120–#0120

    env <vars> python -m <module> <val> > <path> <n> >& <path>
  103. Inspect · Attention kernels

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

    1 call · #0121–#0121

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

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

    1 call · #0122–#0122

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

    Requested file and log inspection related to attention kernels.

    1 call · #0123–#0123

    sed -n <val> <path>
  106. Execute · Benchmark & validation setup

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

    1 call · #0124–#0124

    python - <script>
  107. Other · Source & workspace

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

    1 call · #0125–#0125

    python - <script>sed -n <val> <path>
  108. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0126–#0126

    cat > <path> <script>
  109. Execute · Benchmark & validation setup

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

    2 calls · #0127–#0128

    python - <script>python <script> <val> <val> > <path> <n> >& <path>
  110. Validate · Benchmark & validation setup

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

    1 call · #0129–#0129

    python - <script>
  111. Edit · Batching & scheduling

    Requested code edits related to batching & scheduling.

    1 call · #0130–#0130

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

    1 tool error

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

    1 call · #0131–#0131

    python - <script>env <vars> python <script> > <path> <n> >& <path>
  113. Profile · Rollout generation

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

    1 call · #0132–#0132

    python - <script>tail -n <n> <path>
  114. Inspect · Source & workspace

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

    1 call · #0133–#0133

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

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

    1 call · #0134–#0134

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

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

    1 call · #0135–#0135

    git diff --statgit diff --checkpython - <script>
  117. Profile · Benchmark & validation setup

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

    1 call · #0136–#0136

    python - <script>
  118. Inspect · Source & workspace

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

    1 call · #0137–#0137

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

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

    1 call · #0138–#0138

    sed -n <val> <path>rg --files <path>rg <val>head -n <n>
  120. Profile · Benchmark & validation setup

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

    1 call · #0139–#0139

    python - <script>
  121. Inspect · Attention kernels

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

    1 call · #0140–#0140

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

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

    2 calls · #0141–#0142

    rg -n <val> <path> <path> -g <val>head -n <n>git status --short
  123. Profile · Benchmark & validation setup

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

    1 call · #0143–#0143

    python - <script>
  124. Validate · Task requirements

    Requested environment setup or inspection related to task requirements.

    1 call · #0144–#0144

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

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

    1 call · #0145–#0145

    tail -c <n> <path>
  126. Inspect · Source & workspace

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

    1 call · #0146–#0146

    ls -l <val>head -c <n> <val>sed -n <val> <path>rg -n <val> <path> -g <val>head -n <n>
  127. Profile · Benchmark & validation setup

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

    1 call · #0147–#0147

    python - <script>
  128. Profile · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0148–#0148

    python <script> <val> <val> > <path> <n> >& <path>
  129. Inspect · Source & workspace

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

    1 call · #0149–#0149

    rg --files <path>head -n <n>
  130. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0150–#0150

    python - <script>
  131. Profile · Source & workspace

    Requested script or workload execution related to source & workspace.

    2 calls · #0151–#0152

    python - <script>
  132. Inspect · Benchmark & validation setup

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

    1 call · #0153–#0153

    tail -n <n> <path>
  133. Other · Benchmark & validation setup

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

    1 call · #0154–#0154

    cd <val>env <vars> python <script> > <path> <n> >& <path>
  134. Inspect · Benchmark & validation setup

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

    1 call · #0155–#0155

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

    Requested file and log inspection related to source & workspace.

    1 call · #0156–#0156

    cat <path>head -n <n>
  136. Profile · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0157–#0157

    python - <script>
  137. Inspect · Attention kernels

    Requested file and log inspection, environment setup or inspection and source searches related to attention kernels.

    3 calls · #0158–#0160

    cat > <path> <script>cd <val>env <vars> python <script> > <path> <n> >& <path>rg -n <val> <path>tail -n <n>sed -n <val> <path>
    2 more command sketches
    tail -n <n> <path>git diff --check
  138. Validate · Benchmark & validation setup

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

    1 call · #0161–#0161

    python - <script>
  139. Other · Attention kernels

    Requested script or workload execution related to attention kernels.

    1 call · #0162–#0162

    python - <script>
  140. Inspect · Benchmark & validation setup

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

    1 call · #0163–#0163

    cat > <path> <script>cd <val>env <vars> python <script> > <path> <n> >& <path>
  141. Inspect · Source & workspace

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

    1 call · #0164–#0164

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

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

    1 call · #0165–#0165

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

    Requested file and log inspection related to attention kernels.

    1 call · #0166–#0166

    cat <path>
  144. Inspect · Source & workspace

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

    5 calls · #0167–#0171

    sed -n <val> <path>git status --shortcat <path>
  145. Inspect · Task requirements

    Requested file and log inspection related to task requirements.

    1 call · #0172–#0172

    cat <path> <path>
  146. Inspect · Attention kernels

    Requested file and log inspection related to attention kernels.

    1 call · #0173–#0173

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

    Requested file and log inspection related to source & workspace.

    1 call · #0174–#0174

    cat <path>
  148. Inspect · Attention kernels

    1 tool error

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

    1 call · #0175–#0175

    cat > <path> <script>cd <val>python <script> > <path> <n> >& <path>
  149. Other · Attention kernels

    Requested script or workload execution related to attention kernels.

    1 call · #0176–#0176

    python - <script>cd <val>python <script> > <path> <n> >& <path>
  150. Inspect · Source & workspace

    Requested file and log inspection related to source & workspace.

    1 call · #0177–#0177

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

    Requested file and log inspection related to attention kernels.

    1 call · #0178–#0178

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

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

    1 call · #0179–#0179

    cat <path>
  153. Inspect · Attention kernels

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

    1 call · #0180–#0180

    cat > <path> <script>cd <val>timeout <n> <val> <path> > <path> <n> >& <path>
  154. Inspect · Benchmark & validation setup

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

    1 call · #0181–#0181

    cat <path>
  155. Inspect · Attention kernels

    1 tool error

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

    3 calls · #0182–#0184

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

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

    1 call · #0185–#0185

    rg --files <path>head -n <n>
  157. Inspect · Rollout generation

    Requested source searches related to rollout generation.

    1 call · #0186–#0186

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

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

    1 call · #0187–#0187

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

    Requested file and log inspection related to source & workspace.

    1 call · #0188–#0188

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

    1 tool error

    Requested script or workload execution related to source & workspace.

    2 calls · #0189–#0190

    python - <script>
  161. Inspect · Attention kernels

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

    1 call · #0191–#0191

    cat > <path> <script>cd <val>timeout <n> <val> <path> > <path> <n> >& <path>
  162. Inspect · Benchmark & validation setup

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

    1 call · #0192–#0192

    cat <path>
  163. Other · Source & workspace

    Requested workspace file updates related to source & workspace.

    1 call · #0193–#0193

    cp <path> <path>
  164. Edit · Attention kernels

    Requested code edits related to attention kernels.

    1 call · #0194–#0194

    Apply patch <patch>
  165. Inspect · Attention kernels

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

    1 call · #0195–#0195

    git diff --checkpython -m <module> <script> <script> <script>
  166. Inspect · Benchmark & validation setup

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

    1 call · #0196–#0196

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

    Requested repository inspection and source searches related to attention kernels.

    1 call · #0197–#0197

    git diff --statrg -n <val> <path> <path> <path>
  168. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0198–#0198

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

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

    1 call · #0199–#0199

    tail -n <n> <path>
  170. Validate · Source & workspace

    Requested environment setup or inspection related to source & workspace.

    1 call · #0200–#0200

    env <vars> python -m <module> <script> > <path> <n> >& <path>
  171. Inspect · Benchmark & validation setup

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

    1 call · #0201–#0201

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

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

    2 calls · #0202–#0203

    du <flag> <args>rg --files <val> <path>rg <val>head -n <n>
  173. Inspect · Benchmark & validation setup

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

    1 call · #0204–#0204

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

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

    2 calls · #0205–#0206

    python - <script>rg -n <val> <path> --max-count <n>cut -c <val>tail -n <n> <path>
  175. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0207–#0207

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

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

    1 call · #0208–#0208

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

    Requested script or workload execution related to source & workspace.

    1 call · #0209–#0209

    python - <script>
  178. Execute · Benchmark & validation setup

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

    1 call · #0210–#0210

    python <script> <val> <val> > <path> <n> >& <path>
  179. Inspect · Batching & scheduling

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

    1 call · #0211–#0211

    rg -n -A <n> -B <n> <val> <path>sed -n <val> <path>rg -n <val> <path> <path>
  180. Inspect · Benchmark & validation setup

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

    1 call · #0212–#0212

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

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

    1 call · #0213–#0213

    python - <script>git diff > <path>
  182. Other · Attention kernels

    Requested script or workload execution related to attention kernels.

    1 call · #0214–#0214

    python - <script>
  183. Edit · Batching & scheduling

    Requested code edits related to batching & scheduling.

    1 call · #0215–#0215

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

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

    1 call · #0216–#0216

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

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

    1 call · #0217–#0217

    rg -n <val> <path>head -n <n>
  186. Edit · Source & workspace

    Requested code edits related to source & workspace.

    1 call · #0218–#0218

    Apply patch <patch>
  187. Validate · Source & workspace

    Requested environment setup or inspection related to source & workspace.

    1 call · #0219–#0219

    env <vars> python -m <module> <script> > <path> <n> >& <path>
  188. Inspect · Benchmark & validation setup

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

    1 call · #0220–#0220

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

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

    1 call · #0221–#0221

    python - <script>tail -n <n> <path>
  190. Inspect · Batching & scheduling

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

    2 calls · #0222–#0223

    tail -n <n> <path>ps <flag> <args>rg <val>cut -c <val>python - <script>git diff --stat
  191. Other · Source & workspace

    Requested script or workload execution related to source & workspace.

    1 call · #0224–#0224

    bash <script> > <path> <n> >& <path>
  192. Execute · Benchmark & validation setup

    1 tool error

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

    1 call · #0225–#0225

    python <script> <val> <val> > <path> <n> >& <path>
  193. Inspect · Source & workspace

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

    1 call · #0226–#0226

    rg -n -A <n> -B <n> <val> <path>sed -n <val> <path>
  194. Inspect · Benchmark & validation setup

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

    1 call · #0227–#0227

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

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

    1 call · #0228–#0228

    git <val> <val> <flag>rg -n <val> <path>tail -n <n>
  196. Execute · Benchmark & validation setup

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

    1 call · #0229–#0229

    python - <script>
  197. Edit · Attention kernels

    Requested code edits related to attention kernels.

    1 call · #0230–#0230

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

    Requested code edits related to source & workspace.

    1 call · #0231–#0231

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

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

    1 call · #0232–#0232

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

    Requested repository inspection related to source & workspace.

    1 call · #0233–#0233

    git diff --checkgit status --short
  201. Validate · Source & workspace

    Requested environment setup or inspection related to source & workspace.

    1 call · #0234–#0234

    env <vars> python -m <module> <script> > <path> <n> >& <path>
  202. Validate · Benchmark & validation setup

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

    1 call · #0235–#0235

    env <vars> pytest -q <path> <path> <path> > <path> <n> >& <path>
  203. Inspect · Benchmark & validation setup

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

    3 calls · #0236–#0238

    rg -n <val> <path> <path>head -n <n>ls <flag> <args>ls -l -a <path>ps <flag> <args>rg <val>
    2 more command sketches
    cut -c <val>tail -n <n> <path>
  204. Other · Source & workspace

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

    1 call · #0239–#0239

    python - <script>ls -l -a <path>
  205. Profile · Benchmark & validation setup

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

    1 call · #0240–#0240

    python <script> <val> <val> > <path> <n> >& <path>
  206. Inspect · Benchmark & validation setup

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

    1 call · #0241–#0241

    cat <path>tail -n <n> <path>ls -l -h <path>
  207. Inspect · Source & workspace

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

    1 call · #0242–#0242

    du <flag> <args>rg --files --hidden <path>head -n <n>
  208. Profile · Attention kernels

    Requested script or workload execution related to attention kernels.

    1 call · #0243–#0243

    python - <script>
  209. Inspect · Benchmark & validation setup

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

    1 call · #0244–#0244

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

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

    1 call · #0245–#0245

    sed -n <val> <path>python - <script>
  211. Inspect · Device memory

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

    1 call · #0246–#0246

    rg -n -A <n> -B <n> <val> <path>head -n <n>rg -n -A <n> <val> <path>
  212. Execute · Benchmark & validation setup

    1 tool error

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

    1 call · #0247–#0247

    tail -n <n> <path>python - <script>
  213. Inspect · Device memory

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

    1 call · #0248–#0248

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

    Requested repository inspection related to attention kernels.

    1 call · #0249–#0249

    git diff <flag> <args>
  215. Inspect · Benchmark & validation setup

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

    1 call · #0250–#0250

    tail -n <n> <path>
  216. Edit · Attention kernels

    Requested code edits related to attention kernels.

    1 call · #0251–#0251

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

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

    1 call · #0252–#0252

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

    Requested source searches and script or workload execution related to runtime processes.

    1 call · #0253–#0253

    rg -n -A <n> <val> <path>python - <script>
  219. Execute · Benchmark & validation setup

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

    1 call · #0254–#0254

    python <script> <val> <val> > <path> <n> >& <path>
  220. Inspect · Attention kernels

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

    1 call · #0255–#0255

    git diff --checkpython - <script>
  221. Inspect · Batching & scheduling

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

    1 call · #0256–#0256

    git <val> <val> <flag>ps <flag> <args>rg <val>cut -c <val>
  222. Inspect · Benchmark & validation setup

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

    1 call · #0257–#0257

    tail -n <n> <path>ls -l -a <val>
  223. Validate · Task requirements

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

    1 call · #0258–#0258

    python - <script>env <vars> bash <script> > <path> <n> >& <path>
  224. Inspect · Benchmark & validation setup

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

    1 call · #0259–#0259

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

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

    1 call · #0260–#0260

    bash <script> > <path> <n> >& <path>cat <path>
  226. Other · Runtime processes

    Requested script or workload execution and repository inspection related to runtime processes.

    1 call · #0261–#0261

    python - <script>git diff --checkgit status --short

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 · 4 changed files

Base commit: 340db9201005fc64635bb25db1d2538f955761c3

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..c0b389508a19ad496e0ee66f0545267c3689a611 100644--- a/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py+++ b/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py@@ -89,6 +89,8 @@ class ForwardMetadata:      # swa attention mask for graph mode decode     swa_mask: Optional[torch.Tensor] = None+    # Mask the unused suffix when graph decode lengths are rounded to pages.+    decode_mask: Optional[torch.Tensor] = None      # prefix cache     prefix_lens: Optional[torch.Tensor] = None@@ -380,6 +382,19 @@ class AscendAttnBackend(AttentionBackend):             self.dllm_block_size = self.dllm_config.block_size          self.attn_cp_size = model_runner.ps.attn_cp_size+        # Plain decode can mask a page's unused suffix on device, keeping the+        # FIA host length bindings unchanged until a request crosses a page.+        self.use_graph_seq_len_padding = (+            type(self) is AscendAttnBackend+            and not self.use_mla+            and not self.is_hybrid_swa+            and not self.use_sliding_window_kv_pool+            and not self.is_dllm_model+            and not self.enable_torch_compile+            and not self.use_alibi+            and not model_runner.model_config.is_encoder_decoder+            and model_runner.spec_algorithm.is_none()+        )      def _is_swa_layer(self, layer: RadixAttention) -> bool:         return (@@ -560,6 +575,18 @@ class AscendAttnBackend(AttentionBackend):                 device=self.device,             ),         }+        if self.use_graph_seq_len_padding:+            padded_context_len = (+                self.graph_metadata["block_tables"].shape[1] * self.page_size+            )+            self.graph_metadata["decode_mask"] = torch.ones(+                (max_bs, 1, 1, padded_context_len),+                dtype=torch.bool,+                device=self.device,+            )+            self.graph_metadata["decode_indices"] = torch.arange(+                padded_context_len, dtype=torch.int32, device=self.device+            )         if self.is_hybrid_swa:             self.graph_metadata["block_tables_swa"] = torch.empty(                 (max_bs, total_context_len // self.page_size),@@ -607,6 +634,8 @@ class AscendAttnBackend(AttentionBackend):         """Create and store the per-bs ForwardMetadata for CUDA graph capture."""         metadata = ForwardMetadata()         metadata.block_tables = self.graph_metadata["block_tables"][:bs, :]+        if self.use_graph_seq_len_padding:+            metadata.decode_mask = self.graph_metadata["decode_mask"][:bs]         if self.is_hybrid_swa:             metadata.block_tables_swa = self.graph_metadata["block_tables_swa"][:bs, :]             metadata.swa_mask = self.graph_metadata["swa_mask"][:bs, :, :]@@ -731,6 +760,14 @@ class AscendAttnBackend(AttentionBackend):         elif forward_mode.is_decode_or_idle() and spec_info is not None:             seq_lens = seq_lens + self.speculative_step_offset_npu         metadata.seq_lens[:bs].copy_(seq_lens[:bs])+        if metadata.decode_mask is not None:+            # Keep true token lengths on device while the graph's host length+            # bindings advance only at cache-page boundaries.+            torch.ge(+                self.graph_metadata["decode_indices"][None, :],+                metadata.seq_lens[:bs, None],+                out=metadata.decode_mask[:, 0, 0, :],+            )          self.forward_metadata = metadata @@ -2336,7 +2373,7 @@ class AscendAttnBackend(AttentionBackend):                 attn_mask = self.forward_metadata.swa_mask             else:                 block_tables = self.forward_metadata.block_tables-                attn_mask = None+                attn_mask = self.forward_metadata.decode_mask             k_cache = self.token_to_kv_pool.get_key_buffer(layer.layer_id).view(                 -1, self.page_size, layer.tp_k_head_num * layer.qk_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..dfef4b01d1aa17e10a59a70a6ce73b5c27485bcc 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,8 +12,9 @@ non-NPU hosts.  from __future__ import annotations -import threading+from concurrent.futures import ThreadPoolExecutor from contextlib import AbstractContextManager, contextmanager+from copy import deepcopy from functools import partial from typing import TYPE_CHECKING, Any, Callable, Dict, Optional @@ -63,6 +64,9 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend):         self._enable_torch_compile = getattr(             cuda_graph_runner, "enable_torch_compile", False         )+        self._update_executor: Optional[ThreadPoolExecutor] = None+        self._padded_input_graphs = set()+        self._cached_update_inputs: Dict[Any, Any] = {}      @contextmanager     def capture_session(self, stream):@@ -125,6 +129,29 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend):          self._graphs[shape_key] = graph         self._outputs[shape_key] = out+        self._cached_update_inputs.pop(shape_key, None)+        self._padded_input_graphs.discard(shape_key)+        records = graph.graph_dispatch_mode.graph_dispatch_records+        # Only round lengths when every dynamic operator consumes the decode+        # mask. Other attention operators retain their exact host lengths.+        if records and all(+            record.op_cache_entry.__name__+            == "npu_fused_infer_attention_score.out"+            and record.kwargs.get("atten_mask") is not None+            for record in records+        ):+            self._padded_input_graphs.add(shape_key)++    def supports_padded_sequence_lengths(self, shape_key: ShapeKey) -> bool:+        return shape_key in self._padded_input_graphs++    @staticmethod+    def _signal_input_bindings(graph) -> None:+        mode = graph.graph_dispatch_mode+        # Replay resets these events, so even unchanged bindings need a fresh+        # signal for every recorded operator on every replay.+        for record in mode.graph_dispatch_records:+            record.event.record(mode.update_stream)      def can_run(self, forward_batch: ForwardBatch, shape_key: ShapeKey) -> bool:         return shape_key in self._graphs@@ -149,6 +176,7 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend):         attr_name: str = None,         attr_type: Any = None,         cpu_update_input: list = None,+        cache_input_bindings: bool = False,     ) -> Any:         """Rebind seq_lens on the recorded NPU graph in a background         thread, then replay. Used when the model is not deepseek-nsa.@@ -158,6 +186,10 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend):            Constructs cpu_update_input=[{attr_name: seq_lens}] internally.         2. cpu_update_input: A list of {attr_name: seq_lens} dicts,            one per speculative step.  Used by EAGLE draft runners.++        cache_input_bindings is for masked decode attention with Python-list+        lengths. When the lengths match the last update, signal the captured+        events without rebuilding the same operator bindings.         """         if cpu_update_input is None:             if isinstance(attr_type, torch.Tensor):@@ -165,18 +197,43 @@ 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:+            # Device selection is thread-local. Reuse one device-bound worker+            # instead of creating a thread and initializing its NPU context on+            # every decode step. Updates still overlap graph execution.+            self._update_executor = ThreadPoolExecutor(+                max_workers=1,+                thread_name_prefix="sglang-npu-graph-update",+                initializer=self._device_module.set_device,+                initargs=(self._device_id,),+            )+        if (+            cache_input_bindings+            and self._cached_update_inputs.get(shape_key) == cpu_update_input+        ):+            update = self._update_executor.submit(self._signal_input_bindings, graph)+        else:+            update = self._update_executor.submit(+                graph.update, cpu_update_input=cpu_update_input+            )+        try:+            graph.replay()+        finally:+            # Drain the update even when replay fails, and propagate worker+            # errors rather than silently losing them in a background thread.+            update.result()+        if cache_input_bindings:+            self._cached_update_inputs[shape_key] = deepcopy(cpu_update_input)+        else:+            self._cached_update_inputs.pop(shape_key, None)         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._padded_input_graphs.clear()+        self._cached_update_inputs.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..58ffafabe858a13d3c07f69dca7463c2a94b6419 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@@ -239,6 +239,10 @@ class NPUGraphRunner(DecodeCudaGraphRunner):             is_deepseek_dsa(self.model_runner.model_config.hf_config)             or is_deepseek_v4(self.model_runner.model_config.hf_config)         ):+            # The device-to-host read also completes the preceding replay.+            # Preserve it: cached-binding signals must follow that replay's+            # event resets, and the request-table snapshot must finish before+            # the scheduler writes the next batch's shared inputs.             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)@@ -246,11 +250,22 @@ class NPUGraphRunner(DecodeCudaGraphRunner):                 seq_lens = forward_batch.seq_lens.cpu().tolist() + [0] * (                     self.bs - self.raw_bs                 )+            cache_input_bindings = (+                getattr(self.attn_backend, "use_graph_seq_len_padding", False)+                and self.backend.supports_padded_sequence_lengths(graph_key)+            )+            if cache_input_bindings:+                page_size = self.attn_backend.page_size+                seq_lens = [+                    (length + page_size - 1) // page_size * page_size+                    for length in seq_lens+                ]             output = self.backend.replay_with_input_update(                 graph_key,                 seq_lens=seq_lens,                 attr_name=self._get_update_attr_name(),                 attr_type=self._get_update_attr_type(),+                cache_input_bindings=cache_input_bindings,             )         else:             output = self.backend.replay(graph_key, forward_batch)diff --git a/python/sglang/test/test_npu_cudagraph_backend.py b/python/sglang/test/test_npu_cudagraph_backend.pynew file mode 100644index 0000000000000000000000000000000000000000..b0bcaf745a9240666c1921d8956dba053ba07471--- /dev/null+++ b/python/sglang/test/test_npu_cudagraph_backend.py@@ -0,0 +1,201 @@+"""CPU tests for NPU graph updates, binding reuse, and worker lifetime."""++import threading+import unittest+from contextlib import nullcontext+from types import SimpleNamespace+from unittest.mock import Mock, patch++import torch++from sglang.srt.hardware_backend.npu.graph_runner.npu_cudagraph_backend import (+    NPUCudaGraphBackend,+)+++class TestNPUCudaGraphBackend(unittest.TestCase):+    def setUp(self):+        self.device = Mock()+        self.device.current_device.return_value = 3+        self.backend = NPUCudaGraphBackend(+            SimpleNamespace(+                device_module=self.device,+                model_runner=SimpleNamespace(tp_group=None),+            )+        )+        self.addCleanup(self.backend.cleanup)+        self.graph = Mock()+        self.output = object()+        self.backend._graphs[1] = self.graph+        self.backend._outputs[1] = self.output++    def test_reuses_device_bound_worker_and_joins_on_cleanup(self):+        workers = []+        inputs = []++        def update(*, cpu_update_input):+            workers.append(threading.current_thread())+            inputs.append(cpu_update_input)++        self.graph.update.side_effect = update+        for lengths in ([13], [14], [15]):+            self.assertIs(+                self.backend.replay_with_input_update(+                    1, lengths, "actual_seq_lengths_kv", []+                ),+                self.output,+            )+        self.assertTrue(all(worker is workers[0] for worker in workers))+        self.device.set_device.assert_called_once_with(3)+        self.assertEqual(+            inputs,+            [[{"actual_seq_lengths_kv": [length]}] for length in (13, 14, 15)],+        )+        self.backend.cleanup()+        self.assertFalse(workers[0].is_alive())+        self.assertFalse(self.backend._graphs)++    def test_update_overlaps_replay_and_finishes_before_return(self):+        replay_started = threading.Event()+        update_finished = threading.Event()++        def update(*, cpu_update_input):+            if not replay_started.wait(timeout=5):+                raise RuntimeError("Replay did not overlap the graph update")+            update_finished.set()++        self.graph.update.side_effect = update+        self.graph.replay.side_effect = replay_started.set+        self.backend.replay_with_input_update(1, [13], "actual_seq_lengths_kv", [])+        self.assertTrue(update_finished.is_set())++    def test_update_failure_reaches_caller(self):+        self.graph.update.side_effect = ValueError("invalid graph update")+        with self.assertRaisesRegex(ValueError, "invalid graph update"):+            self.backend.replay_with_input_update(1, [13], "actual_seq_lengths_kv", [])++    def test_replay_failure_still_waits_for_update(self):+        replay_started = threading.Event()+        update_finished = threading.Event()++        def update(*, cpu_update_input):+            if not replay_started.wait(timeout=5):+                raise RuntimeError("Replay did not start")+            update_finished.set()++        def replay():+            replay_started.set()+            raise ValueError("invalid graph replay")++        self.graph.update.side_effect = update+        self.graph.replay.side_effect = replay+        with self.assertRaisesRegex(ValueError, "invalid graph replay"):+            self.backend.replay_with_input_update(1, [13], "actual_seq_lengths_kv", [])+        self.assertTrue(update_finished.is_set())++    def test_tensor_and_multistep_update_inputs(self):+        self.backend.replay_with_input_update(1, [7, 8], "context_lens", torch.Tensor())+        tensor = self.graph.update.call_args.kwargs["cpu_update_input"][0][+            "context_lens"+        ]+        self.assertEqual(tensor.dtype, torch.int32)+        self.assertEqual(tensor.device.type, "cpu")+        self.assertEqual(tensor.tolist(), [7, 8])++        inputs = [{"actual_seq_lengths_kv": [7]}, {"actual_seq_lengths_kv": [8]}]+        self.backend.replay_with_input_update(1, None, cpu_update_input=inputs)+        self.assertIs(self.graph.update.call_args.kwargs["cpu_update_input"], inputs)++    def test_reuses_bindings_and_signals_every_record(self):+        stream = object()+        events = [Mock(), Mock()]+        self.graph.graph_dispatch_mode = SimpleNamespace(+            update_stream=stream,+            graph_dispatch_records=[SimpleNamespace(event=event) for event in events],+        )+        for _ in range(3):+            self.backend.replay_with_input_update(+                1, [128, 256], "actual_seq_lengths_kv", [], cache_input_bindings=True+            )+        self.graph.update.assert_called_once()+        self.assertEqual(self.graph.replay.call_count, 3)+        for event in events:+            self.assertEqual(event.record.call_count, 2)+            event.record.assert_called_with(stream)++    def test_binding_cache_snapshots_inputs_and_invalidates_uncached_updates(self):+        lengths = [128, 256]+        self.backend.replay_with_input_update(+            1, lengths, "actual_seq_lengths_kv", [], cache_input_bindings=True+        )+        lengths[0] = 256+        self.backend.replay_with_input_update(+            1, lengths, "actual_seq_lengths_kv", [], cache_input_bindings=True+        )+        self.assertEqual(self.graph.update.call_count, 2)+        self.backend.replay_with_input_update(+            1, [384, 256], "actual_seq_lengths_kv", []+        )+        self.backend.replay_with_input_update(+            1, lengths, "actual_seq_lengths_kv", [], cache_input_bindings=True+        )+        self.assertEqual(self.graph.update.call_count, 4)+        self.backend.cleanup()+        self.assertFalse(self.backend._cached_update_inputs)++    def test_binding_cache_is_per_graph(self):+        other_graph = Mock()+        self.backend._graphs[2] = other_graph+        self.backend._outputs[2] = object()+        for key in (1, 2):+            self.backend.replay_with_input_update(+                key, [128], "actual_seq_lengths_kv", [], cache_input_bindings=True+            )+        self.graph.update.assert_called_once()+        other_graph.update.assert_called_once()++    def test_recapture_checks_all_operators_and_invalidates_bindings(self):+        self.backend._tp_group = Mock()+        masked = SimpleNamespace(+            op_cache_entry=SimpleNamespace(+                __name__="npu_fused_infer_attention_score.out"+            ),+            kwargs={"atten_mask": object()},+        )+        unmasked = SimpleNamespace(+            op_cache_entry=masked.op_cache_entry, kwargs={"atten_mask": None}+        )+        other = SimpleNamespace(+            op_cache_entry=SimpleNamespace(__name__="other_attention.out"),+            kwargs={"atten_mask": object()},+        )+        for records, supported in (+            ([masked], True),+            ([masked, unmasked], False),+            ([masked, other], False),+            ([], False),+        ):+            with self.subTest(supported=supported, records=len(records)):+                graph = SimpleNamespace(+                    graph_dispatch_mode=SimpleNamespace(+                        graph_dispatch_records=records+                    )+                )+                npu = SimpleNamespace(+                    NPUGraph=lambda: graph,+                    graph=lambda *args, **kwargs: nullcontext(),+                )+                self.backend._cached_update_inputs[1] = [{"old_lengths": [128]}]+                with (+                    patch.dict("sys.modules", {"torch_npu": Mock()}),+                    patch.object(torch, "npu", npu, create=True),+                ):+                    self.backend.capture_one(1, lambda: self.output)+                self.assertEqual(+                    self.backend.supports_padded_sequence_lengths(1), supported+                )+                self.assertNotIn(1, self.backend._cached_update_inputs)+++if __name__ == "__main__":+    unittest.main()