Inspect · Source & workspace
Requested workspace inspection and environment setup or inspection related to source & workspace.
1 call · #0001–#0001
pwdprintenv <vars>GPT-6 Astra · Serving
Offline throughput 1dev · Implementation Optimization
01 / PROCESS MAP
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 · 232 visible calls
02 / EVENT SEQUENCE
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.
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>.
Requested workspace inspection and environment setup or inspection related to source & workspace.
1 call · #0001–#0001
pwdprintenv <vars>Requested repository inspection and source searches related to task requirements.
1 call · #0002–#0002
git status --shortrg --files -g <val> -g <path> -g <path> <path> <n> > <path>Requested file and log inspection related to task requirements.
1 call · #0003–#0003
cat <path> <path><command> <args>cat <val>Requested file and log inspection related to benchmark & validation setup.
1 call · #0004–#0004
cat <path> <path> <path> <path> <path> <path>Requested file and log inspection, source searches and environment setup or inspection related to task requirements.
2 calls · #0005–#0006
cat <path> <path> <path> <path>rg --files <path>rg --files -g <val> -g <val> <path>head -n <n>printenv <vars>Requested source searches related to benchmark & validation setup.
1 call · #0007–#0007
rg -n <val> <path>Requested script or workload execution related to task requirements.
1 call · #0008–#0008
python3 - <script>Requested script or workload execution related to source & workspace.
1 call · #0009–#0009
bash <script>Requested file and log inspection related to source & workspace.
1 call · #0010–#0010
sed -n <val> <path>Requested source searches, file and log inspection and runtime inspection related to device memory.
1 call · #0011–#0011
rg --files <path> <path> <val>head -n <n>npu-smi infoRequested environment setup or inspection related to source & workspace.
1 call · #0012–#0012
env <vars> bash <script>Requested source searches and file and log inspection related to benchmark & validation setup.
1 call · #0013–#0013
rg -n <val> <path>sed -n <val> <path>Requested file and log inspection and source searches related to attention kernels.
1 call · #0014–#0014
sed -n <val> <path>rg -n <val> <path>Requested file and log inspection related to source & workspace.
1 call · #0015–#0015
sed -n <val> <path>Requested environment setup or inspection related to task requirements.
1 call · #0016–#0016
env <vars> bash <script> > <path>Requested file and log inspection related to attention kernels.
1 call · #0017–#0017
sed -n <val> <path>Requested file and log inspection related to source & workspace.
1 call · #0018–#0018
sed -n <val> <path>cat <path>Requested file and log inspection related to benchmark & validation setup.
1 call · #0019–#0019
tail -n <n> <path>cat <path>Requested source searches and file and log inspection related to batching & scheduling.
1 call · #0020–#0020
rg -n <val> <path> <path> <path>head -n <n>sed -n <val> <path>Requested file and log inspection related to attention kernels.
1 call · #0021–#0021
sed -n <val> <path>Requested runtime inspection, file and log inspection and workspace inspection related to benchmark & validation setup.
2 calls · #0022–#0023
ps <flag> <args>head -n <n>ls -l <val>tail -n <n> <path>sed -n <val> <path>Requested source searches and file and log inspection related to source & workspace.
1 call · #0024–#0024
rg -n <val> <path>tail -n <n>cat <path>Requested source searches and file and log inspection related to benchmark & validation setup.
1 call · #0025–#0025
rg -n <val> <path>head -n <n>tail -n <n> <path>Requested file and log inspection and source searches related to attention kernels.
1 call · #0026–#0026
sed -n <val> <path>rg -n <val> <path>Requested source searches and file and log inspection related to runtime processes.
1 call · #0027–#0027
rg -n <val> <path> <path>sed -n <val> <path>Requested file and log inspection and workspace inspection related to benchmark & validation setup.
1 call · #0028–#0028
tail -n <n> <path>cut <flag>ls -l <path> <n> > <path>Requested file and log inspection related to benchmark & validation setup.
1 call · #0029–#0029
sed -n <val> <path>tail -n <n> <path>cut <flag>Requested file and log inspection and source searches related to attention kernels.
3 calls · #0030–#0032
sed -n <val> <path>rg -n <val> <path>tail -n <n>rg --files <val>rg <val>head -n <n>rg -n <val> <path> <path> <path>tail -n <n> <path>cut <flag>cat <path>Requested file and log inspection and workspace inspection related to benchmark & validation setup.
1 call · #0033–#0033
tail -n <n> <path>cut <flag>cat <path>ls -l <path> <n> > <path>Requested source searches and file and log inspection related to runtime processes.
1 call · #0034–#0034
rg --files <path>rg <val>head -n <n>sed -n <val> <path>Requested runtime inspection, file and log inspection and source searches related to device memory.
1 call · #0035–#0035
ps <flag> <args>head -n <n>npu-smi inforg --files <val>tail -n <n>Requested environment setup or inspection related to task requirements.
1 call · #0036–#0036
env <vars> python3 - <script>Requested file and log inspection and script or workload execution related to benchmark & validation setup.
1 call · #0037–#0037
cat <path>python3 - <script>Requested file and log inspection, source searches and workspace inspection related to attention kernels.
2 calls · #0038–#0039
sed -n <val> <path>rg -n <val> <path>head -n <n>ls -l <val>Requested repository inspection, file and log inspection and source searches related to source & workspace.
2 calls · #0040–#0041
git show <path>sed -n <val>rg -n <val> <path>tail -n <n>sed -n <val> <path>wc -ltail -n <n> <path>cut <flag>Requested environment setup or inspection related to task requirements.
1 call · #0042–#0042
env <vars> bash <script> > <path> <n> >& <path>Requested file and log inspection related to benchmark & validation setup.
1 call · #0043–#0043
tail -n <n> <path>cut <flag>cat <path>cat <path> <n> > <path>Requested source searches and file and log inspection related to benchmark & validation setup.
1 call · #0044–#0044
rg --files <path>head -n <n>sed -n <val> <path>rg -n <val> <path>tail -n <n>rg -n <val> <path> <path>Requested source searches and file and log inspection related to batching & scheduling.
1 call · #0045–#0045
rg -n <val> <path>tail -n <n>cut <flag>cat <path>Requested file and log inspection related to source & workspace.
1 call · #0046–#0046
cat <path>tail -n <n> <path>cut <flag>cat <path> <n> > <path>Requested file and log inspection and source searches related to benchmark & validation setup.
1 call · #0047–#0047
sed -n <val> <path>rg -n <val> <path> <path>head -n <n>rg -n <val> <path> -g <path>Requested environment setup or inspection related to attention kernels.
1 call · #0048–#0048
env <vars> python3 -m <module> -q <script> <script> > <path> <n> >& <path>Requested source searches and file and log inspection related to source & workspace.
1 call · #0049–#0049
rg -n <val> <path>sed -n <val> <path>rg -n <val> <path> <path> <path>cat <path>Requested file and log inspection and source searches related to attention kernels.
1 call · #0050–#0050
sed -n <val> <path>rg -n <val> <path> <path>rg --files <path>rg <val>Requested workspace inspection and file and log inspection related to source & workspace.
1 call · #0051–#0051
ls -l -t <val>head -n <n>tail -n <n> <path> <n> > <path>cut <flag>cat <path>Requested source searches and file and log inspection related to batching & scheduling.
1 call · #0052–#0052
rg <path> <path>tail -n <n>rg -n <val> <path>head -n <n>sed -n <val> <path>Requested file and log inspection and workspace inspection related to source & workspace.
1 call · #0053–#0053
sed -n <val> <path>tail -n <n> <path>cut <flag>ls -l -t <val>head -n <n>Requested source searches and file and log inspection related to runtime processes.
2 calls · #0054–#0055
rg -n <val> <path>head -n <n>rg -n <val> <path> <path>tail -n <n>sed -n <val> <path>cat <path>rg <val> <path>Requested file and log inspection and source searches related to source & workspace.
2 calls · #0056–#0057
sed -n <val> <path>rg -n <val> <path>head -n <n>tail -n <n> <path> <n> > <path>cut <flag>Requested file and log inspection related to benchmark & validation setup.
1 call · #0058–#0058
cat > <path> <script>Requested workspace inspection, file and log inspection and source searches related to runtime processes.
2 calls · #0059–#0060
ls -l -t <val>head -n <n>tail -n <n> <path> <n> > <path>cut <flag>rg -n <val> <path>rg -n <val> <path> <path>tail -n <n>sed -n <val> <path>Requested source searches and file and log inspection related to batching & scheduling.
1 call · #0061–#0061
rg -n <val> <path> <path> <path>sed -n <val> <path>rg -n <val> <path>head -n <n>cat <path> <n> > <path>Requested source searches and file and log inspection related to source & workspace.
1 call · #0062–#0062
rg -n <val> <path> -g <val>head -n <n>sed -n <val> <path>rg --files <path>rg <val>Requested file and log inspection, source searches and workspace inspection related to batching & scheduling.
2 calls · #0063–#0064
sed -n <val> <path>rg <val> <path>ls -l -t <val>head -n <n>Requested file and log inspection and source searches related to runtime processes.
1 call · #0065–#0065
sed -n <val> <path>rg <val> <path>head -n <n>Requested source searches and file and log inspection related to source & workspace.
1 call · #0066–#0066
rg -n <val> <path>head -n <n>sed -n <val> <path>tail -n <n> <path>cut <flag>Requested file and log inspection related to rollout generation.
1 call · #0067–#0067
cat > <path> <script>Requested file and log inspection and source searches related to attention kernels.
1 call · #0068–#0068
sed -n <val> <path>rg <val> <path>tail -n <n>Requested file and log inspection and source searches related to runtime processes.
1 call · #0069–#0069
sed -n <val> <path>rg -n <val> <path> <path>tail -n <n>Requested source searches, file and log inspection and script or workload execution related to source & workspace.
1 call · #0070–#0070
rg -n <val> <path>head -n <n>tail -n <n> <path> <n> > <path>cut <flag>python3 - <script>Requested script or workload execution, workspace inspection and file and log inspection related to latency & request handling.
1 call · #0071–#0071
python3 - <script>ls -l -t <val>head -n <n>tail -n <n> <path>cut <flag>Requested repository inspection, script or workload execution and file and log inspection related to source & workspace.
2 calls · #0072–#0073
git status --shortpython3 - <script>tail -n <n> <path>cut <flag>cat <path>ls -l <path> <path> <n> > <path>Requested environment setup or inspection related to task requirements.
1 call · #0074–#0074
env <vars> bash <script> > <path> <n> >& <path>Requested file and log inspection related to benchmark & validation setup.
1 call · #0075–#0075
tail -n <n> <path>cut <flag>cat <path>Requested script or workload execution and file and log inspection related to latency & request handling.
1 call · #0076–#0076
python3 - <script>cat <path>Requested file and log inspection, runtime inspection and workspace inspection related to source & workspace.
3 calls · #0077–#0079
tail -n <n> <path>cat <path>tail -n <n> <path> <n> > <path>cut <flag>ps <flag> <args>head -n <n>ls -l <path>rg -n <val> <path>Requested source searches and file and log inspection related to device memory.
1 call · #0080–#0080
rg -n <val> <path>sed -n <val> <path>tail -n <n> <path>cut <flag>Requested file and log inspection and source searches related to source & workspace.
1 call · #0081–#0081
tail -n <n> <path>cut <flag>rg --files <path> <n> > <path>head -n <n>cat <path>Requested file and log inspection and source searches related to attention kernels.
1 call · #0082–#0082
sed -n <val> <path>rg -n <val> <path>head -n <n>Requested file and log inspection and source searches related to source & workspace.
1 call · #0083–#0083
tail -n <n> <path>cut <flag>rg --files <path> <n> > <path>head -n <n>cat <path>Requested code edits related to attention kernels.
1 call · #0084–#0084
Apply patch <patch>Requested repository inspection and file and log inspection related to source & workspace.
1 call · #0085–#0085
git diff --statgit diff --checktail -n <n> <path>cut <flag>Requested environment setup or inspection related to task requirements.
1 call · #0086–#0086
env <vars> python3 - <script>Requested source searches, file and log inspection and repository inspection related to source & workspace.
1 call · #0087–#0087
rg --files <path>head -n <n>cat <path>git diff --checkRequested script or workload execution related to source & workspace.
2 calls · #0088–#0089
python3 - <script>Requested environment setup or inspection related to attention kernels.
1 call · #0090–#0090
env <vars> python3 -m <module> -q <script> <script> > <path> <n> >& <path>Requested file and log inspection related to attention kernels.
1 call · #0091–#0091
sed -n <val> <path>tail -n <n> <path>cut <flag>Requested environment setup or inspection related to task requirements.
1 call · #0092–#0092
env <vars> python3 <script> <val> > <path> <n> >& <path>Requested source searches and file and log inspection related to attention kernels.
1 call · #0093–#0093
rg -n <val> <path> <path> <path>head -n <n>sed -n <val> <path>tail -n <n> <path>Requested source searches and file and log inspection related to source & workspace.
1 call · #0094–#0094
rg -n <val> <path> <path>head -n <n>rg -n <val> <path> -g <path>sed -n <val> <path>Requested source searches and file and log inspection related to dependencies & build setup.
2 calls · #0095–#0096
rg -n <val> <path>head -n <n>sed -n <val> <path>rg -n <val> <path> <path>tail -n <n> <path>cut <flag>Requested source searches and file and log inspection related to attention kernels.
2 calls · #0097–#0098
rg -n <val> <path>sed -n <val> <path>head -n <n>tail -n <n> <path>cut <flag>Requested environment setup or inspection related to task requirements.
1 call · #0099–#0099
env <vars> python3 <script> <val> <flag> <args>Requested file and log inspection related to source & workspace.
1 call · #0100–#0100
sed -n <val> <path>tail -n <n> <path>cut <flag>cat <path> <n> > <path>head -n <n>Requested code edits related to source & workspace.
2 calls · #0101–#0102
Apply patch <patch>Requested repository inspection and file and log inspection related to benchmark & validation setup.
1 call · #0103–#0103
git diff --checktail -n <n> <path>cut <flag>cat <path>Requested source searches, file and log inspection and repository inspection related to attention kernels.
1 call · #0104–#0104
rg -n <val> <val> <path> <path>rg --files <path>rg <path>cat <path>tail -n <n>git diff --statRequested environment setup or inspection related to benchmark & validation setup.
1 call · #0105–#0105
env <vars> python3 -m <module> -q <script> > <path> <n> >& <path>Requested repository inspection and environment setup or inspection related to task requirements.
1 call · #0106–#0106
git diff --checkenv <vars> python3 <script> <val> > <path> <n> >& <path>Requested script or workload execution and file and log inspection related to benchmark & validation setup.
1 call · #0107–#0107
python3 - <script>cat <path>tail -n <n>tail -n <n> <path>cut <flag>Requested file and log inspection and source searches related to attention kernels.
1 call · #0108–#0108
<command> <args>sed -n <val> <path>rg -n <val> <path>tail -n <n>tail -n <n> <path>cut <flag>Requested source searches, file and log inspection and environment setup or inspection related to task requirements.
1 call · #0109–#0109
rg -n -B <n> -A <n> <val> <path>tail -n <n>env <vars> python3 <script> <val> <flag> <args>Requested file and log inspection and repository inspection related to source & workspace.
2 calls · #0110–#0111
tail -n <n> <path>git status --shortsed -n <val> <path>Requested file and log inspection related to task requirements.
1 call · #0112–#0112
cat <path>Requested file and log inspection related to source & workspace.
1 call · #0113–#0113
sed -n <val> <path>cat <path>Requested source searches related to attention kernels.
1 call · #0114–#0114
rg -n <val> <path>rg -n <val> <path> <path>Requested file and log inspection related to source & workspace.
1 call · #0115–#0115
sed -n <val> <path>cat <path>Requested code edits related to source & workspace.
1 call · #0116–#0116
Apply patch <patch>Requested file and log inspection, source searches and runtime inspection related to attention kernels.
6 calls · #0117–#0122
sed -n <val> <path>rg -n <val> <path>tail -n <n> <path>rg -n <val> <path> <path> -g <path>head -n <n>ps <flag> <args>rg <val>rg -n <val> <path> -g <path>Requested source searches and file and log inspection related to task requirements.
1 call · #0123–#0123
rg -n <val> <path> <path> <path>head -n <n>sed -n <val> <path>Requested file and log inspection and source searches related to attention kernels.
1 call · #0124–#0124
tail -n <n> <path>sed -n <val> <path>rg -n <val> <path>head -n <n>Requested file and log inspection related to source & workspace.
2 calls · #0125–#0126
tail -n <n> <path>cut -c <val>sed -n <val> <path>Requested environment setup or inspection related to task requirements.
1 call · #0127–#0127
env <vars> python3 <script> <val> <flag> <args>Requested file and log inspection related to source & workspace.
1 call · #0128–#0128
tail -n <n> <path>cut -c <val>Requested code edits related to source & workspace.
1 call · #0129–#0129
Apply patch <patch>Requested script or workload execution, source searches and repository inspection related to attention kernels.
2 calls · #0130–#0131
python3 - <script>rg -n <val> <path>git diff --checkRequested code edits related to attention kernels.
1 call · #0132–#0132
Apply patch <patch>Requested file and log inspection and source searches related to source & workspace.
2 calls · #0133–#0134
tail -n <n> <path>cut -c <val>sed -n <val> <path>rg -n <val> <path>rg --files <val>rg <val>head -n <n>Requested file and log inspection and environment setup or inspection related to attention kernels.
2 calls · #0135–#0136
cat <path>cat > <path> <script>env <vars> python3 <script> > <path> <n> >& <path>Requested file and log inspection and repository inspection related to source & workspace.
1 call · #0137–#0137
tail -n <n> <path>cut -c <val>git diff --statRequested code edits related to attention kernels.
1 call · #0138–#0138
Apply patch <patch>Requested file and log inspection, repository inspection and runtime inspection related to source & workspace.
3 calls · #0139–#0141
tail -n <n> <path>cut -c <val>git diff --checkps <flag> <args>rg <val>head -n <n>cat > <path> <script>Requested environment setup or inspection related to attention kernels.
1 call · #0142–#0142
env <vars> bash <script> > <path> <n> >& <path>Requested file and log inspection and source searches related to source & workspace.
2 calls · #0143–#0144
tail -n <n> <path>cut -c <val>cat <path>rg -n <val> <path>sed -n <val> <path>Requested source searches, workspace inspection and file and log inspection related to runtime processes.
1 call · #0145–#0145
rg -n <val> <path>ls -l -a <path>head -n <n>Requested file and log inspection and source searches related to source & workspace.
1 call · #0146–#0146
cat <path>sed -n <val> <path>rg -n <val> <val> <path> -g <val>Requested source searches, file and log inspection and environment setup or inspection related to attention kernels.
1 call · #0147–#0147
rg --files <path>head -n <n>rg -n <val> <path>tail -n <n> <path>cut -c <val>envrg <val>Requested source searches, file and log inspection and environment setup or inspection related to source & workspace.
4 calls · #0148–#0151
rg -a -l -F <val> <path> <path> <path> <path> <n> > <path>tail -n <n> <path>cut -c <val><command> <args>rg -n -C <n> <val>head -n <n>envrg <val>cat <path>Requested script or workload execution and environment setup or inspection related to source & workspace.
2 calls · #0152–#0153
python3 - <script>env <vars> python3 <script> > <path> <n> >& <path>Requested script or workload execution related to attention kernels.
1 call · #0154–#0154
python3 - <script>Requested code edits related to source & workspace.
1 call · #0155–#0155
Apply patch <patch>Requested file and log inspection related to attention kernels.
1 call · #0156–#0156
cat <path>tail -n <n>sed -n <val> <path>Requested script or workload execution and environment setup or inspection related to attention kernels.
1 call · #0157–#0157
python3 - <script>env <vars> bash <script> > <path> <n> >& <path>Requested source searches and file and log inspection related to benchmark & validation setup.
1 call · #0158–#0158
rg -n <val> <path> <path> -g <path>rg --files <val>rg <val>head -n <n>tail -n <n> <path>cut -c <val>Requested file and log inspection, environment setup or inspection and source searches related to benchmark & validation setup.
1 call · #0159–#0159
sed -n <val> <path>envrg <val>cut -c <val>tail -n <n> <path>Requested source searches, file and log inspection and repository inspection related to source & workspace.
1 call · #0160–#0160
rg --files <val>rg <val>head -n <n>cat <path>git status --shortRequested file and log inspection and source searches related to benchmark & validation setup.
1 call · #0161–#0161
tail -n <n> <path>cut -c <val>rg --files <path>head -n <n>Requested file and log inspection and workspace inspection related to runtime processes.
1 call · #0162–#0162
tail -n <n> <path>cut -c <val>ls -t <val>head -n <n>Requested script or workload execution and environment setup or inspection related to source & workspace.
1 call · #0163–#0163
python3 - <script>env <vars> python3 <script> > <path> <n> >& <path>Requested environment setup or inspection related to task requirements.
1 call · #0164–#0164
env <vars> python3 <script> <val> > <path> <n> >& <path>Requested file and log inspection and script or workload execution related to attention kernels.
1 call · #0165–#0165
tail -n <n> <path>cut -c <val>python3 - <script>Requested code edits related to attention kernels.
1 call · #0166–#0166
Apply patch <patch>Requested file and log inspection related to source & workspace.
1 call · #0167–#0167
sed -n <val> <path>tail -n <n> <path>cut -c <val>Requested environment setup or inspection related to attention kernels.
2 calls · #0168–#0169
env <vars> python3 -m <module> -q <script> <script> <script> > <path> <n> <args>env <vars> python3 -m <module> -q <script> > <path> <n> >& <path>Requested file and log inspection related to source & workspace.
2 calls · #0170–#0171
tail -n <n> <path>cut -c <val>sed -n <val> <path>Requested file and log inspection and environment setup or inspection related to task requirements.
1 call · #0172–#0172
tail -n <n> <path>cut -c <val>env <vars> python3 <script> <val> <flag> <args>Requested file and log inspection and repository inspection related to attention kernels.
1 call · #0173–#0173
tail -n <n> <path>cut -c <val>git diff <flag> <args>Requested environment setup or inspection related to attention kernels.
1 call · #0174–#0174
env <vars> python3 -m <module> -q <script> <script> > <path> <n> >& <path>Requested environment setup or inspection related to benchmark & validation setup.
1 call · #0175–#0175
env <vars> python3 -m <module> -q <script> > <path> <n> >& <path>Requested code edits related to attention kernels.
1 call · #0176–#0176
Apply patch <patch>Requested file and log inspection related to source & workspace.
2 calls · #0177–#0178
tail -n <n> <path>cut -c <val>Requested code edits related to attention kernels.
1 call · #0179–#0179
Apply patch <patch>Requested script or workload execution related to runtime processes.
1 call · #0180–#0180
python3 - <script>Requested file and log inspection, repository inspection and source searches related to source & workspace.
1 call · #0181–#0181
tail -n <n> <path>cut -c <val>git diff --checkrg -n <val> <path> -g <path>head -n <n>Requested script or workload execution and environment setup or inspection related to attention kernels.
1 call · #0182–#0182
python3 - <script>env <vars> python3 <script> > <path> <n> >& <path>Requested file and log inspection, runtime inspection and source searches related to source & workspace.
1 call · #0183–#0183
tail -n <n> <path>cut -c <val>ps <flag> <args>rg <val>head -n <n>Requested repository inspection and script or workload execution related to attention kernels.
1 call · #0184–#0184
git diff --numstatpython3 - <script>Requested file and log inspection and script or workload execution related to benchmark & validation setup.
1 call · #0185–#0185
tail -n <n> <path>cut -c <val>python3 - <script>Requested file and log inspection and source searches related to batching & scheduling.
2 calls · #0186–#0187
sed -n <val> <path>rg -n <val> <path>head -n <n>rg -n <val> <path> <path> <path>tail -n <n> <path>cut -c <val>Requested environment setup or inspection related to task requirements.
1 call · #0188–#0188
env <vars> python3 <script> <val> > <path> <n> >& <path>Requested file and log inspection, source searches and repository inspection related to benchmark & validation setup.
3 calls · #0189–#0191
tail -n <n> <path>cut -c <val>rg -n <val> <path> -g <path>head -n <n>sed -n <val> <path>git status --shortrg -n <val> <path>Requested environment setup or inspection related to task requirements.
1 call · #0192–#0192
env <vars> python3 <script> <val> <flag> <args>Requested file and log inspection related to source & workspace.
1 call · #0193–#0193
tail -n <n> <path>cut -c <val>Requested code edits related to source & workspace.
2 calls · #0194–#0195
Apply patch <patch>Requested repository inspection and file and log inspection related to benchmark & validation setup.
1 call · #0196–#0196
git diff --checktail -n <n> <path>cut -c <val>Requested environment setup or inspection related to benchmark & validation setup.
1 call · #0197–#0197
env <vars> python3 -m <module> -q <script> <script> > <path> <n> >& <path>Requested environment setup or inspection related to task requirements.
1 call · #0198–#0198
env <vars> python3 <script> <val> > <path> <n> >& <path>Requested code edits related to source & workspace.
1 call · #0199–#0199
Apply patch <patch>Requested file and log inspection and script or workload execution related to benchmark & validation setup.
1 call · #0200–#0200
tail -n <n> <path>cut -c <val>python3 - <script>Requested file and log inspection and repository inspection related to source & workspace.
1 call · #0201–#0201
tail -n <n> <path>cut -c <val>git diff --statsed -n <val> <path>Requested file and log inspection and environment setup or inspection related to task requirements.
1 call · #0202–#0202
tail -n <n> <path>env <vars> python3 <script> <val> <flag> <args>Requested file and log inspection and source searches related to benchmark & validation setup.
1 call · #0203–#0203
tail -n <n> <path>cut -c <val>sed -n <val> <path>rg -n <val> <path>Requested code edits related to source & workspace.
1 call · #0204–#0204
Apply patch <patch>Requested file and log inspection related to benchmark & validation setup.
1 call · #0205–#0205
sed -n <val> <path>cat <path>Requested file and log inspection and repository inspection related to source & workspace.
1 call · #0206–#0206
tail -n <n> <path>cut -c <val>git diff --checkRequested code edits related to source & workspace.
1 call · #0207–#0207
Apply patch <patch>Requested script or workload execution related to benchmark & validation setup.
1 call · #0208–#0208
python3 - <script>Requested script or workload execution and environment setup or inspection related to task requirements.
1 call · #0209–#0209
python3 - <script>env <vars> python3 <script> <val> <flag> <args>Requested file and log inspection related to source & workspace.
1 call · #0210–#0210
tail -n <n> <path>cut -c <val>Requested source searches, file and log inspection and repository inspection related to benchmark & validation setup.
1 call · #0211–#0211
rg -n <val> <path>tail -n <n>git diff --checkRequested file and log inspection and script or workload execution related to benchmark & validation setup.
1 call · #0212–#0212
sed -n <val> <path>python3 - <script>Requested environment setup or inspection related to attention kernels.
1 call · #0213–#0213
env <vars> python3 -m <module> -q <script> > <path> <n> >& <path>Requested file and log inspection, runtime inspection and source searches related to benchmark & validation setup.
2 calls · #0214–#0215
tail -n <n> <path>cut -c <val>sed -n <val> <path>ps <flag> <args>rg <val>head -n <n>Requested environment setup or inspection related to task requirements.
1 call · #0216–#0216
env <vars> bash <script> > <path> <n> >& <path>Requested script or workload execution related to runtime processes.
1 call · #0217–#0217
python3 - <script>Requested script or workload execution related to benchmark & validation setup.
1 call · #0218–#0218
python3 - <script>Requested environment setup or inspection related to task requirements.
1 call · #0219–#0219
env <vars> bash <script> > <path> <n> >& <path>Requested script or workload execution, source searches and file and log inspection related to benchmark & validation setup.
2 calls · #0220–#0221
python3 - <script>rg -n <val> <path>tail -n <n>Requested file and log inspection and script or workload execution related to runtime processes.
1 call · #0222–#0222
sed -n <val> <path>python3 - <script>Requested script or workload execution related to latency & request handling.
2 calls · #0223–#0224
python3 - <script>Requested script or workload execution related to runtime processes.
1 call · #0225–#0225
python3 - <script>Requested environment setup or inspection related to task requirements.
1 call · #0226–#0226
env <vars> bash <script> > <path> <n> >& <path>Requested script or workload execution related to latency & request handling.
1 call · #0227–#0227
python3 - <script>Requested script or workload execution related to benchmark & validation setup.
1 call · #0228–#0228
python3 - <script>Requested script or workload execution related to source & workspace.
1 call · #0229–#0229
bash <script> > <path> <n> >& <path>Requested workspace inspection, repository inspection and runtime inspection related to device memory.
1 call · #0230–#0230
stat -c <val> <val>git diff --checkgit status --shortnpu-smi infoRequested script or workload execution related to benchmark & validation setup.
1 call · #0231–#0231
python3 - <script>Requested repository inspection and script or workload execution related to source & workspace.
1 call · #0232–#0232
git diff --checkpython3 - <script>03 / CANDIDATE ARTIFACT
Read code changes as Git diffs. Identifying strings are masked; binary files are listed by their full relative names.
Base commit: 340db9201005fc64635bb25db1d2538f955761c3
@@ -430,7 +430,12 @@ 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 a host mirror. Reading the maximum+ # from the device here would synchronize every eager decode step.+ seq_lens_cpu = forward_batch.seq_lens_cpu+ if seq_lens_cpu is None:+ seq_lens_cpu = forward_batch.seq_lens.cpu()+ seq_lens_max = int(seq_lens_cpu.max()) if forward_batch.forward_mode.is_target_verify(): seq_lens_max += self.speculative_num_draft_tokens elif (@@ -440,8 +445,8 @@ class AscendAttnBackend(AttentionBackend): 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]+ forward_batch.req_pool_indices, : seq_lens_max : self.page_size+ ] // self.page_size ) if self.is_hybrid_swa:@@ -449,9 +454,10 @@ class AscendAttnBackend(AttentionBackend): ( self.full_to_swa_index_mapping[ self.req_to_token_pool.req_to_token[- forward_batch.req_pool_indices, :seq_lens_max+ forward_batch.req_pool_indices,+ : seq_lens_max : self.page_size, ]- ][:, :: self.page_size]+ ] // self.page_size ) .to(torch.int32)@@ -460,7 +466,9 @@ class AscendAttnBackend(AttentionBackend): 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)+ if 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 +477,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()@@ -0,0 +1,239 @@+# Copyright 2023-2024 SGLang Team+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ==============================================================================+"""Token-tiled QKV normalization and full NeoX rotation for Ascend."""++import torch+import triton+import triton.language as tl+import triton.language.extra.cann.extension as al+from sgl_kernel_npu.norm.split_qkv_rmsnorm_rope import (+ split_qkv_rmsnorm_rope as _scalar_row_qkv,+)+from sgl_kernel_npu.utils.triton_utils import get_device_properties+++@triton.jit+def _scalar_reciprocal_std(variance, EPS: tl.constexpr, ROWS: tl.constexpr):+ # Ascend lowers a singleton reciprocal square root differently from a+ # vector one. Retain the scalar-row kernel's rounding for each KV head.+ result = tl.zeros((ROWS,), dtype=tl.float32)+ for row in tl.static_range(ROWS):+ value = al.extract_slice(+ variance, offsets=(row,), sizes=(1,), strides=(1,)+ )+ value = 1 / tl.sqrt(value + EPS)+ result = al.insert_slice(+ result, value, offsets=(row,), sizes=(1,), strides=(1,)+ )+ return result+++@triton.jit+def _full_neox_rope(values, sin, cos, ROWS: tl.constexpr, HEAD_DIM: tl.constexpr):+ first = al.extract_slice(+ values,+ offsets=(0, 0),+ sizes=(ROWS, HEAD_DIM // 2),+ strides=(1, 1),+ )+ second = al.extract_slice(+ values,+ offsets=(0, HEAD_DIM // 2),+ sizes=(ROWS, HEAD_DIM // 2),+ strides=(1, 1),+ )+ rotated = tl.zeros((ROWS, HEAD_DIM), dtype=tl.float32)+ rotated = al.insert_slice(+ rotated,+ -second,+ offsets=(0, 0),+ sizes=(ROWS, HEAD_DIM // 2),+ strides=(1, 1),+ )+ rotated = al.insert_slice(+ rotated,+ first,+ offsets=(0, HEAD_DIM // 2),+ sizes=(ROWS, HEAD_DIM // 2),+ strides=(1, 1),+ )+ return rotated * sin + values * cos+++@triton.jit+def _split_qkv_rmsnorm_rope_tiled_kernel(+ input_ptr,+ sin_ptr,+ cos_ptr,+ q_ptr,+ k_ptr,+ v_ptr,+ q_weight_ptr,+ q_bias_ptr,+ k_weight_ptr,+ k_bias_ptr,+ batch_size,+ Q_HIDDEN: tl.constexpr,+ KV_HIDDEN: tl.constexpr,+ EPS: tl.constexpr,+ BIAS: tl.constexpr,+ NORMS: tl.constexpr,+ HEAD_DIM: tl.constexpr,+ Q_GROUP: tl.constexpr,+ BLOCK_ROWS: tl.constexpr,+):+ # Tile tokens as well as heads, retaining each head's reduction and+ # arithmetic order. Bound the tile size to fit in vector memory.+ head = tl.program_id(1)+ dims = tl.arange(0, HEAD_DIM)+ q_rows = tl.arange(0, BLOCK_ROWS * Q_GROUP)+ kv_rows = tl.arange(0, BLOCK_ROWS)+ q_cols = (head * Q_GROUP + q_rows % Q_GROUP)[:, None] * HEAD_DIM + dims[None, :]+ kv_cols = head * HEAD_DIM + dims[None, :]+ TOTAL_HIDDEN: tl.constexpr = Q_HIDDEN + 2 * KV_HIDDEN+ if NORMS:+ q_weight = tl.load(q_weight_ptr + dims).to(tl.float32)+ k_weight = tl.load(k_weight_ptr + dims).to(tl.float32)+ if BIAS:+ q_bias = tl.load(q_bias_ptr + dims).to(tl.float32)+ k_bias = tl.load(k_bias_ptr + dims).to(tl.float32)++ for base in tl.range(+ tl.program_id(0) * BLOCK_ROWS,+ batch_size,+ tl.num_programs(0) * BLOCK_ROWS,+ ):+ q_tokens = base + q_rows // Q_GROUP+ q_mask = q_tokens[:, None] < batch_size+ q = tl.load(+ input_ptr + q_tokens[:, None] * TOTAL_HIDDEN + q_cols,+ mask=q_mask,+ other=0.0,+ ).to(tl.float32)+ if NORMS:+ q_variance = tl.sum(q * q, axis=1) / HEAD_DIM+ if Q_GROUP == 1:+ q_std = _scalar_reciprocal_std(q_variance, EPS, BLOCK_ROWS)+ else:+ q_std = 1 / tl.sqrt(q_variance + EPS)+ q = q * q_std[:, None]+ if BIAS:+ q = q * q_weight + q_bias+ else:+ q = q * q_weight+ q_rope_offsets = q_tokens[:, None] * HEAD_DIM + dims[None, :]+ q_sin = tl.load(sin_ptr + q_rope_offsets, mask=q_mask, other=0.0).to(tl.float32)+ q_cos = tl.load(cos_ptr + q_rope_offsets, mask=q_mask, other=0.0).to(tl.float32)+ q = _full_neox_rope(q, q_sin, q_cos, BLOCK_ROWS * Q_GROUP, HEAD_DIM)+ tl.store(q_ptr + q_tokens[:, None] * Q_HIDDEN + q_cols, q, mask=q_mask)++ kv_tokens = base + kv_rows+ kv_mask = kv_tokens[:, None] < batch_size+ kv_offsets = kv_tokens[:, None] * TOTAL_HIDDEN + Q_HIDDEN + kv_cols+ k = tl.load(input_ptr + kv_offsets, mask=kv_mask, other=0.0).to(tl.float32)+ if NORMS:+ k_variance = tl.sum(k * k, axis=1) / HEAD_DIM+ k_std = _scalar_reciprocal_std(k_variance, EPS, BLOCK_ROWS)+ k = k * k_std[:, None]+ if BIAS:+ k = k * k_weight + k_bias+ else:+ k = k * k_weight+ k_rope_offsets = kv_tokens[:, None] * HEAD_DIM + dims[None, :]+ k_sin = tl.load(sin_ptr + k_rope_offsets, mask=kv_mask, other=0.0).to(+ tl.float32+ )+ k_cos = tl.load(cos_ptr + k_rope_offsets, mask=kv_mask, other=0.0).to(+ tl.float32+ )+ k = _full_neox_rope(k, k_sin, k_cos, BLOCK_ROWS, HEAD_DIM)+ tl.store(k_ptr + kv_tokens[:, None] * KV_HIDDEN + kv_cols, k, mask=kv_mask)+ v = tl.load(input_ptr + kv_offsets + KV_HIDDEN, mask=kv_mask, other=0.0)+ tl.store(v_ptr + kv_tokens[:, None] * KV_HIDDEN + kv_cols, v, mask=kv_mask)+++def split_qkv_rmsnorm_rope(+ input,+ sin,+ cos,+ q_hidden_size,+ kv_hidden_size,+ head_dim,+ eps=None,+ q_weight=None,+ k_weight=None,+ q_bias=None,+ k_bias=None,+ is_neox_style=True,+):+ _, vector_cores = get_device_properties()+ kv_heads = kv_hidden_size // head_dim+ row_programs = (vector_cores + kv_heads - 1) // kv_heads+ batch_size = input.shape[0]+ q_group = q_hidden_size // kv_hidden_size+ if (+ not is_neox_style+ or sin.shape[-1] != head_dim+ or batch_size <= row_programs+ or input.dtype not in (torch.bfloat16, torch.float16)+ or triton.next_power_of_2(q_group) != q_group+ or q_group * head_dim > 4096+ ):+ return _scalar_row_qkv(+ input,+ sin,+ cos,+ q_hidden_size,+ kv_hidden_size,+ head_dim,+ eps=eps,+ q_weight=q_weight,+ k_weight=k_weight,+ q_bias=q_bias,+ k_bias=k_bias,+ is_neox_style=is_neox_style,+ )++ assert triton.next_power_of_2(head_dim) == head_dim+ assert q_hidden_size % kv_hidden_size == 0+ block_rows = min(+ 16,+ triton.next_power_of_2(triton.cdiv(batch_size, row_programs)),+ max(1, 4096 // (q_group * head_dim)),+ )+ q = torch.empty(batch_size, q_hidden_size, device=input.device, dtype=input.dtype)+ k = torch.empty(batch_size, kv_hidden_size, device=input.device, dtype=input.dtype)+ v = torch.empty(batch_size, kv_hidden_size, device=input.device, dtype=input.dtype)+ _split_qkv_rmsnorm_rope_tiled_kernel[(row_programs, kv_heads)](+ input,+ sin,+ cos,+ q,+ k,+ v,+ q_weight,+ q_bias,+ k_weight,+ k_bias,+ batch_size,+ q_hidden_size,+ kv_hidden_size,+ eps,+ q_bias is not None,+ eps is not None,+ head_dim,+ q_group,+ block_rows,+ )+ return q, k, v@@ -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@@ -51,6 +51,8 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend): ) -> None: self._graphs: Dict[Any, Any] = {} self._outputs: Dict[Any, Any] = {}+ self._replay_done: Dict[Any, Any] = {}+ self._update_executor: Optional[ThreadPoolExecutor] = None self._pool = None self._device_module = cuda_graph_runner.device_module self._device_id = self._device_module.current_device()@@ -140,8 +142,16 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend): **kwargs, ) -> Any: self._graphs[shape_key].replay()+ self._record_replay_done(shape_key) return self._outputs[shape_key] + def _record_replay_done(self, shape_key: ShapeKey) -> None:+ event = self._replay_done.get(shape_key)+ if event is None:+ event = self._device_module.Event()+ self._replay_done[shape_key] = event+ event.record(self._device_module.current_stream())+ def replay_with_input_update( self, shape_key: ShapeKey,@@ -165,18 +175,36 @@ 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()+ # Updates run on a separate stream and reuse the graph's task metadata+ # and external events. Its preceding replay must have consumed them+ # before another update, including consecutive chunks of a large batch.+ previous_replay = self._replay_done.get(shape_key)+ if previous_replay is not None:+ previous_replay.synchronize()+ if self._update_executor is None:+ self._update_executor = ThreadPoolExecutor(+ max_workers=1,+ thread_name_prefix="sglang-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+ ) graph.replay()- thread.join()+ self._record_replay_done(shape_key)+ # Propagate tiling/update failures to the runner instead of losing+ # exceptions in a detached thread.+ 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+ for event in self._replay_done.values():+ event.synchronize()+ self._replay_done.clear() self._graphs.clear() self._outputs.clear() self._pool = None@@ -13,7 +13,7 @@ # ============================================================================== """Run the model with NPU graph and torch.compile. -NPUGraphRunner is a thin subclass of DecodeCudaGraphRunner: the+NPUGraphRunner extends DecodeCudaGraphRunner: the factory returns NPUCudaGraphBackend for NPU devices, so all capture/replay mechanics live in the backend. This class adds: - NPU-specific patch_model monkey-patch for the decode-Full +@@ -22,6 +22,7 @@ capture/replay mechanics live in the backend. This class adds: - Replay override that issues an async NPUGraph.update for seq_lens before replay (skipped for deepseek-nsa). - Smaller cache_loc dtype (int32 instead of int64).+ - Chunked replay for small Qwen3 decoders above the capture ceiling. """ from __future__ import annotations@@ -29,6 +30,7 @@ from __future__ import annotations import logging import os from contextlib import contextmanager+from copy import copy from pathlib import Path from typing import TYPE_CHECKING, Dict, Optional, Union @@ -116,6 +118,104 @@ class NPUGraphRunner(DecodeCudaGraphRunner): in ("MiMoV2ForCausalLM", "MiMoV2FlashForCausalLM", "Step3p5ForCausalLM") for arch in (model_runner.model_config.hf_config.architectures or []) )+ from sglang.srt.hardware_backend.npu.attention.ascend_backend import (+ AscendAttnBackend,+ )++ # Small decoders are often limited by eager operator dispatch. Reuse+ # the configured graphs in request-sized chunks when the live batch+ # exceeds the capture ceiling; never capture a larger graph.+ self._split_decode_enabled = (+ type(self.attn_backend) is AscendAttnBackend+ and model_runner.model_config.attention_arch == AttentionArch.MHA+ and model_runner.model_config.hf_config.model_type == "qwen3"+ and model_runner.model_config.hidden_size <= 2048+ and model_runner.is_generation+ and not model_runner.is_multimodal+ and not model_runner.is_hybrid_swa+ and model_runner.spec_algorithm.is_none()+ and self.tp_size == self.dp_size == self.pp_size == 1+ and not self.is_encoder_decoder+ and not self.is_dllm+ and not self.disable_padding+ and not self.enable_torch_compile+ and not self.require_mlp_sync+ and not self.enable_two_batch_overlap+ and not self.enable_pdmux+ and not self.use_ngram_embedding+ and not envs.SGLANG_ENABLE_OVERLAP_PLAN_STREAM.get()+ and not model_runner.server_args.enable_lora+ )++ def _can_split_decode_batch(self, forward_batch: ForwardBatch) -> bool:+ return (+ self._split_decode_enabled+ # Limit repeated weight reads once the batch is large enough to+ # amortize eager dispatch on its own.+ and self.max_bs < forward_batch.batch_size <= 4 * self.max_bs+ and forward_batch.forward_mode.is_decode()+ and forward_batch.spec_info is None+ and forward_batch.seq_lens_cpu is not None+ and forward_batch.input_embeds is None+ and forward_batch.replace_embeds is None+ and forward_batch.mrope_positions is None+ and forward_batch.num_token_non_padded is None+ and forward_batch.needs_forward_metadata_init()+ )++ @staticmethod+ def _slice_decode_batch(forward_batch: ForwardBatch, start: int, end: int):+ batch = copy(forward_batch)+ batch.batch_size = end - start+ for name in (+ "input_ids",+ "positions",+ "req_pool_indices",+ "seq_lens",+ "seq_lens_cpu",+ "orig_seq_lens",+ "out_cache_loc",+ "rids_int",+ "bootstrap_room_ids_int",+ "rids",+ "lora_ids",+ "top_logprobs_nums",+ "token_ids_logprobs",+ ):+ value = getattr(forward_batch, name, None)+ if value is not None:+ setattr(batch, name, value[start:end])+ batch.seq_lens_sum = int(batch.seq_lens_cpu.sum())+ batch.num_token_non_padded_cpu = batch.batch_size+ batch.forward_metadata_ready = False+ return batch++ def can_run_graph(self, forward_batch: ForwardBatch):+ if super().can_run_graph(forward_batch):+ return True+ if not self._can_split_decode_batch(forward_batch):+ return False+ return super().can_run_graph(+ self._slice_decode_batch(forward_batch, 0, self.max_bs)+ )++ def _execute_split_decode(self, forward_batch: ForwardBatch):+ result = LogitsProcessorOutput(next_token_logits=None)+ for start in range(0, forward_batch.batch_size, self.max_bs):+ end = min(start + self.max_bs, forward_batch.batch_size)+ output = self.execute(self._slice_decode_batch(forward_batch, start, end))+ # All capture buckets can share storage. Copy each chunk before+ # replaying another graph, including when its batch size differs.+ for name in ("next_token_logits", "hidden_states"):+ value = getattr(output, name)+ if value is None:+ continue+ target = getattr(result, name)+ if target is None:+ target = value.new_empty((forward_batch.batch_size, *value.shape[1:]))+ setattr(result, name, target)+ target[start:end].copy_(value)+ return result def _init_arch_map(self): if self.is_dllm:@@ -211,6 +311,8 @@ class NPUGraphRunner(DecodeCudaGraphRunner): forward_batch: ForwardBatch, pp_proxy_tensors: Optional[PPProxyTensors] = None, ) -> Union[LogitsProcessorOutput, PPProxyTensors]:+ if self._can_split_decode_batch(forward_batch):+ return self._execute_split_decode(forward_batch) if forward_batch.needs_forward_metadata_init(): self.load_batch(forward_batch, pp_proxy_tensors) else:@@ -243,9 +345,13 @@ class NPUGraphRunner(DecodeCudaGraphRunner): seq_lens_cpu = forward_batch.seq_lens.cpu() + self.captured_req_width seq_lens = seq_lens_cpu.tolist() + [0] * (self.bs - self.raw_bs) else:- seq_lens = forward_batch.seq_lens.cpu().tolist() + [0] * (- self.bs - self.raw_bs- )+ # Ordinary decode has an up-to-date scheduler mirror. Keep the+ # device read for speculative steps, which can change lengths+ # independently of that mirror.+ seq_lens_cpu = forward_batch.seq_lens_cpu+ if seq_lens_cpu is None or forward_batch.spec_info is not None:+ seq_lens_cpu = forward_batch.seq_lens.cpu()+ seq_lens = seq_lens_cpu.tolist() + [0] * (self.bs - self.raw_bs) output = self.backend.replay_with_input_update( graph_key, seq_lens=seq_lens,@@ -121,7 +121,12 @@ class EagerRunner(BaseRunner): device=mr.device, max_bs=max_bs, max_num_token=max_num_token,- cache_loc_dtype=torch.int64,+ # Ascend's cache-write operator consumes int32 slot indices. Stage+ # them once, as the NPU graph runner does, instead of casting the+ # same locations in every attention layer.+ cache_loc_dtype=(+ torch.int32 if torch.device(mr.device).type == "npu" else torch.int64+ ), enable_mamba_track=( sa.enable_mamba_extra_buffer() and mr.spec_algorithm.is_none() ),@@ -55,8 +55,9 @@ if _use_aiter: pass if _is_npu:- from sgl_kernel_npu.norm.split_qkv_rmsnorm_rope import split_qkv_rmsnorm_rope-+ from sglang.srt.hardware_backend.npu.attention.qkv_rmsnorm_rope import (+ split_qkv_rmsnorm_rope,+ ) from sglang.srt.hardware_backend.npu.cmo import get_cmo_stream, wait_cmo_stream @@ -0,0 +1,105 @@+"""CPU tests for splitting NPU decode graph replays across requests."""++import unittest+from dataclasses import replace+from types import SimpleNamespace++import torch++from sglang.srt.hardware_backend.npu.graph_runner.npu_graph_runner import NPUGraphRunner+from sglang.srt.layers.logits_processor import LogitsProcessorOutput+from sglang.srt.model_executor.forward_batch_info import ForwardBatch, ForwardMode+++def make_batch(size=9):+ lengths = torch.arange(10, 10 + size)+ return ForwardBatch(+ forward_mode=ForwardMode.DECODE,+ batch_size=size,+ input_ids=torch.arange(size),+ positions=lengths - 1,+ req_pool_indices=torch.arange(size) + 20,+ seq_lens=lengths.clone(),+ seq_lens_cpu=lengths.clone(),+ orig_seq_lens=lengths.clone(),+ out_cache_loc=torch.arange(size) + 100,+ seq_lens_sum=int(lengths.sum()),+ num_token_non_padded_cpu=size,+ rids=[str(i) for i in range(size)],+ )+++class TestNPUDecodeGraphBatches(unittest.TestCase):+ def test_slice_keeps_request_fields_aligned(self):+ batch = make_batch()+ view = NPUGraphRunner._slice_decode_batch(batch, 4, 8)+ self.assertEqual(view.batch_size, 4)+ self.assertEqual(view.num_token_non_padded_cpu, 4)+ self.assertEqual(view.seq_lens_sum, sum(range(14, 18)))+ self.assertEqual(view.rids, ["4", "5", "6", "7"])+ for name in (+ "input_ids",+ "positions",+ "req_pool_indices",+ "seq_lens",+ "seq_lens_cpu",+ "orig_seq_lens",+ "out_cache_loc",+ ):+ torch.testing.assert_close(getattr(view, name), getattr(batch, name)[4:8])+ self.assertEqual(batch.batch_size, 9)+ self.assertEqual(batch.seq_lens_sum, sum(range(10, 19)))++ def test_replays_copy_outputs_before_shared_storage_is_reused(self):+ batch = make_batch()+ runner = NPUGraphRunner.__new__(NPUGraphRunner)+ runner.max_bs = 4+ shared_logits = torch.empty(4, 2)+ shared_hidden = torch.empty(4, 3)+ sizes = []++ def replay(chunk):+ sizes.append(chunk.batch_size)+ n = chunk.batch_size+ shared_logits[:n].copy_(chunk.input_ids[:, None].expand(n, 2))+ shared_hidden[:n].copy_(chunk.positions[:, None].expand(n, 3))+ return LogitsProcessorOutput(+ next_token_logits=shared_logits[:n], hidden_states=shared_hidden[:n]+ )++ runner.execute = replay+ output = runner._execute_split_decode(batch)+ self.assertEqual(sizes, [4, 4, 1])+ torch.testing.assert_close(+ output.next_token_logits, batch.input_ids[:, None].expand(9, 2).float()+ )+ torch.testing.assert_close(+ output.hidden_states, batch.positions[:, None].expand(9, 3).float()+ )+ shared_logits.zero_()+ self.assertEqual(output.next_token_logits[-1, 0].item(), 8)++ def test_unsupported_batches_do_not_split(self):+ runner = SimpleNamespace(_split_decode_enabled=True, max_bs=4)+ can_split = NPUGraphRunner._can_split_decode_batch+ batch = make_batch()+ self.assertTrue(can_split(runner, batch))+ for candidate in (+ make_batch(4),+ make_batch(17),+ replace(batch, forward_mode=ForwardMode.EXTEND),+ replace(batch, spec_info=object()),+ replace(batch, seq_lens_cpu=None),+ replace(batch, input_embeds=torch.empty(9, 2)),+ replace(batch, replace_embeds=torch.empty(1, 2)),+ replace(batch, mrope_positions=torch.empty(3, 9)),+ replace(batch, num_token_non_padded=torch.tensor(9)),+ replace(batch, forward_metadata_ready=True),+ ):+ self.assertFalse(can_split(runner, candidate))+ runner._split_decode_enabled = False+ self.assertFalse(can_split(runner, batch))+++if __name__ == "__main__":+ unittest.main()@@ -0,0 +1,107 @@+"""CPU tests for NPU graph update ordering, worker lifetime and failures."""++import threading+import unittest+from types import SimpleNamespace+from unittest.mock import Mock++import torch++from sglang.srt.hardware_backend.npu.graph_runner.npu_cudagraph_backend import (+ NPUCudaGraphBackend,+)+++class FakeEvent:+ def __init__(self):+ self.records = 0+ self.synchronizations = 0++ def record(self, stream):+ self.records += 1++ def synchronize(self):+ self.synchronizations += 1+++def make_backend():+ backend = NPUCudaGraphBackend.__new__(NPUCudaGraphBackend)+ backend._graphs = {key: Mock() for key in ("small", "large")}+ backend._outputs = {key: object() for key in backend._graphs}+ backend._replay_done = {}+ backend._update_executor = None+ backend._device_id = 0+ backend._device_module = SimpleNamespace(+ Event=FakeEvent, current_stream=lambda: None, set_device=Mock()+ )+ backend._pool = None+ return backend+++class TestNPUGraphUpdates(unittest.TestCase):+ def setUp(self):+ self.backend = make_backend()+ self.addCleanup(self.backend.cleanup)++ def test_reuse_waits_for_the_same_graph(self):+ backend = self.backend+ backend.replay_with_input_update("small", [10], "lengths")+ first = backend._replay_done["small"]+ backend.replay_with_input_update("large", [20, 30], "lengths")+ second = backend._replay_done["large"]+ self.assertEqual(first.synchronizations, 0)+ self.assertEqual(second.synchronizations, 0)++ def update_again(**kwargs):+ self.assertEqual(first.synchronizations, 1)++ backend._graphs["small"].update.side_effect = update_again+ result = backend.replay_with_input_update("small", [11], "lengths")+ self.assertIs(result, backend._outputs["small"])+ self.assertEqual(first.records, 2)+ self.assertEqual(second.synchronizations, 0)++ def test_worker_is_reused_and_legacy_tensor_metadata_is_preserved(self):+ backend = self.backend+ worker_ids = []++ def remember_worker(**kwargs):+ worker_ids.append(threading.get_ident())++ backend._graphs["small"].update.side_effect = remember_worker+ for length in (10, 11):+ backend.replay_with_input_update(+ "small", [length], "context_lens", torch.empty(0)+ )+ self.assertEqual(len(set(worker_ids)), 1)+ self.assertNotEqual(worker_ids[0], threading.get_ident())+ backend._device_module.set_device.assert_called_once_with(0)+ kwargs = backend._graphs["small"].update.call_args.kwargs+ torch.testing.assert_close(+ kwargs["cpu_update_input"][0]["context_lens"],+ torch.tensor([11], dtype=torch.int32),+ )++ def test_update_errors_propagate(self):+ self.backend._graphs["small"].update.side_effect = RuntimeError("tiling failed")+ with self.assertRaisesRegex(RuntimeError, "tiling failed"):+ self.backend.replay_with_input_update("small", [10], "lengths")++ def test_cleanup_finishes_replays_and_releases_worker(self):+ backend = self.backend+ metadata = [{"lengths": [10]}, {"lengths": [11]}]+ backend.replay_with_input_update("small", None, cpu_update_input=metadata)+ backend._graphs["small"].update.assert_called_once_with(+ cpu_update_input=metadata+ )+ event = backend._replay_done["small"]+ backend.cleanup()+ self.assertEqual(event.synchronizations, 1)+ self.assertIsNone(backend._update_executor)+ self.assertFalse(backend._replay_done)+ self.assertFalse(backend._graphs)+ self.assertFalse(backend._outputs)+++if __name__ == "__main__":+ unittest.main()@@ -0,0 +1,95 @@+"""Regression coverage for token tiling in the fused QKV kernel."""++import pytest+import torch++torch_npu = pytest.importorskip("torch_npu")+if not torch_npu.npu.is_available():+ pytest.skip("Ascend NPU is required", allow_module_level=True)++from sgl_kernel_npu.norm.split_qkv_rmsnorm_rope import (+ split_qkv_rmsnorm_rope_kernel,+)+from sgl_kernel_npu.utils.triton_utils import get_device_properties++from sglang.srt.hardware_backend.npu.attention.qkv_rmsnorm_rope import (+ split_qkv_rmsnorm_rope,+)+++@pytest.mark.parametrize(+ "batch,q_heads,kv_heads,head_dim,eps,bias,dtype",+ [+ (1, 16, 8, 128, 1e-6, False, torch.bfloat16),+ (7, 16, 8, 128, 1e-6, False, torch.bfloat16),+ (64, 16, 8, 128, 1e-6, False, torch.bfloat16),+ (160, 16, 8, 128, 1e-6, False, torch.bfloat16),+ (8192, 16, 8, 128, 1e-6, False, torch.bfloat16),+ (133, 8, 8, 64, 1e-6, True, torch.bfloat16),+ (133, 16, 4, 256, None, False, torch.bfloat16),+ (133, 16, 4, 256, 1e-6, True, torch.float16),+ (133, 16, 8, 128, None, False, torch.float16),+ ],+)+def test_tiled_qkv_matches_scalar_rows(+ batch, q_heads, kv_heads, head_dim, eps, bias, dtype+):+ torch.manual_seed(34891)+ q_hidden, kv_hidden = q_heads * head_dim, kv_heads * head_dim+ total_hidden = q_hidden + 2 * kv_hidden+ qkv = torch.randn(batch, total_hidden, dtype=dtype, device="npu")+ angles = torch.randn(batch, head_dim // 2, device="npu").repeat(1, 2)+ sin, cos = angles.sin().to(dtype), angles.cos().to(dtype)+ q_weight, k_weight, q_bias, k_bias = [+ torch.randn(head_dim, dtype=dtype, device="npu") for _ in range(4)+ ]+ if eps is None:+ q_weight = k_weight = None+ if not bias:+ q_bias = k_bias = None++ actual = split_qkv_rmsnorm_rope(+ qkv,+ sin,+ cos,+ q_hidden,+ kv_hidden,+ head_dim,+ eps=eps,+ q_weight=q_weight,+ k_weight=k_weight,+ q_bias=q_bias,+ k_bias=k_bias,+ )+ expected = tuple(torch.empty_like(value) for value in actual)+ _, vector_cores = get_device_properties()+ rows = (vector_cores + kv_heads - 1) // kv_heads+ split_qkv_rmsnorm_rope_kernel[(rows, kv_heads, 1)](+ qkv,+ sin,+ cos,+ *expected,+ q_weight,+ q_bias,+ k_weight,+ k_bias,+ batch,+ q_hidden,+ kv_hidden,+ total_hidden,+ eps,+ q_heads // kv_heads * head_dim,+ head_dim,+ bias,+ eps is not None,+ head_dim,+ head_dim,+ head_dim // 2,+ 0,+ DO_PARTIAL=False,+ DO_HALF=True,+ )+ # Singleton normalization must retain the scalar kernel's rounding even+ # though loads and stores now process a tile of tokens.+ for result, reference in zip(actual, expected):+ torch.testing.assert_close(result, reference, rtol=0, atol=0)