Inspect · Source & workspace
Requested workspace inspection and file and log inspection related to source & workspace.
2 calls · #0001–#0002
echo <val>ls -l -a <path> <n> > <path>head -n <n>ls -l -a <path>Claude Opus 5 · Serving
Repeated context 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 agentClaude Opus 5 · 184 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 file and log inspection related to source & workspace.
2 calls · #0001–#0002
echo <val>ls -l -a <path> <n> > <path>head -n <n>ls -l -a <path>Requested file and log inspection related to task requirements.
2 calls · #0003–#0004
Read <path>Requested file and log inspection related to source & workspace.
1 call · #0005–#0005
Read <path>Requested file and log inspection related to benchmark & validation setup.
1 call · #0006–#0006
cd <path><command> <args>cat <val>Requested file and log inspection related to task requirements.
2 calls · #0007–#0008
cd <path>wc -l <path>echo <flag>cat <path>Read <path>Requested file and log inspection related to benchmark & validation setup.
1 call · #0009–#0009
cd <path>cat <path>Requested source searches and file and log inspection related to runtime processes.
1 call · #0010–#0010
cd <path>grep -n <val> <path>head -n <n>Requested file and log inspection related to source & workspace.
6 calls · #0011–#0016
Read <path>cd <path>sed -n <val> <path>Requested environment setup or inspection, source searches and file and log inspection related to device memory.
1 call · #0017–#0017
cd <path>envgrep -i -E <val>sortecho <flag><command> <args>head <flag>trueRequested script or workload execution and file and log inspection related to source & workspace.
4 calls · #0018–#0021
date -uecho <val>cd <path>bash <script> <n> >& <path>tail -n <n>Read <path>Requested workspace file updates, script or workload execution and file and log inspection related to benchmark & validation setup.
3 calls · #0022–#0024
cd <path>mkdir -p <path>nohup <val> <path> > <path> <n> >& <path>echo <val>date -utail -n <n> <path>python3 -c <script>wc -c <path>ls -l -a <path> <n> > <path>headRequested workspace inspection and file and log inspection related to source & workspace.
1 call · #0025–#0025
cd <path>lsecho <flag>cat <path> <n> > <path>ls <path>Requested workspace inspection and file and log inspection related to benchmark & validation setup.
1 call · #0026–#0026
date -uls -l -a <path> <n> > <path>echo <flag>tail -n <n> <path> <n> > <path>Requested workspace inspection and file and log inspection related to prefix caching.
1 call · #0027–#0027
cd <path>ls <path>head -n <n>echo <flag>wc -l <path> <path> <path> <path>Requested workspace inspection, file and log inspection and source searches related to benchmark & validation setup.
2 calls · #0028–#0029
date -uls -l -a <path>echo <flag>tail -n <n> <path> <n> > <path>grep -c <val> <path>grep -E <val> <path>tail -n <n>Requested workspace inspection, source searches and file and log inspection related to task requirements.
1 call · #0030–#0030
date -uls <path>grep -E <val> <path>tailecho <val>head -c <n> <path>echopython3 -c <script>Requested workspace inspection, source searches and file and log inspection related to benchmark & validation setup.
2 calls · #0031–#0032
date -uls <path>echo <flag>grep -E <val> <path>tail -n <n>tail -c <n> <path>Requested source searches and file and log inspection related to batching & scheduling.
1 call · #0033–#0033
cd <path>grep -n <val> <path>head -n <n>Requested workspace inspection and file and log inspection related to benchmark & validation setup.
1 call · #0034–#0034
date -uls <path>tail -c <n> <path>Requested workspace inspection, source searches and file and log inspection related to attention kernels.
2 calls · #0035–#0036
cd <path>ls <path>grep -i -E <val>echo <flag>wc -l <path> <n> > <path>grep -r -n <val> <path> <n> > <path>headfind <path> -iname <val>head -n <n>Requested workspace inspection and file and log inspection related to attention kernels.
1 call · #0037–#0037
date -uls <path>tail -c <n> <path>echowc -l <path>Requested workspace inspection, file and log inspection and source searches related to benchmark & validation setup.
5 calls · #0038–#0042
date -uls <path>echo <flag>cat <path>tail -c <n> <path> <n> > <path>echogrep -c <val> <path> <n> > <path>Requested source searches and file and log inspection related to attention kernels.
1 call · #0043–#0043
cd <path>grep -n <val> <path>head -n <n>Requested workspace inspection and file and log inspection related to benchmark & validation setup.
4 calls · #0044–#0047
date -uls <path>echo <flag>cat <path>tail -c <n> <path> <n> > <path>tail -c <n> <path>Requested source searches and file and log inspection related to device memory.
1 call · #0048–#0048
cd <path>grep -n <val> <path>head -n <n>Requested workspace inspection and file and log inspection related to benchmark & validation setup.
1 call · #0049–#0049
date -uls <path>echo <flag>cat <path>Requested workspace inspection and file and log inspection related to batching & scheduling.
1 call · #0050–#0050
date -uls <path>echo <flag>cat <path>tail -c <n> <path>Requested execution waits, workspace inspection and file and log inspection related to benchmark & validation setup.
2 calls · #0051–#0052
<command> <args>sleep <n>date -uls <path>echo <flag>cat <path>cp <path> <path>cd <path>sed -n <val> <path>Requested file and log inspection and script or workload execution related to source & workspace.
2 calls · #0053–#0054
cd <path>sed -n <val> <path>echo <val>cat <val>python3 -m <module>head -n <n>Requested code edits related to runtime processes.
1 call · #0055–#0055
Write <path>Requested code edits related to source & workspace.
1 call · #0056–#0056
Write <path>Requested workspace file updates, script or workload execution and execution waits related to runtime processes.
1 call · #0057–#0057
cd <path>chmod <val> <path> <path>nohup <val> <path> > <path> <n> >& <path>echo <val>sleep <n>date -uRequested file and log inspection related to batching & scheduling.
1 call · #0058–#0058
cd <path>sed -n <val> <path>Requested source searches and file and log inspection related to batching & scheduling.
1 call · #0059–#0059
cd <path>grep -n <val> <path>date -utail -c <n> <path> <n> > <path>Requested file and log inspection related to batching & scheduling.
1 call · #0060–#0060
cd <path>sed -n <val> <path>Requested file and log inspection and service requests related to runtime processes.
1 call · #0061–#0061
date -utail -c <n> <path> <n> > <path>echocurl -s -m <n> <url> <n> >& <path>head -c <n>Requested file and log inspection related to batching & scheduling.
1 call · #0062–#0062
cd <path>sed -n <val> <path>Requested file and log inspection, service requests and execution waits related to runtime processes.
2 calls · #0063–#0064
date -utail -c <n> <path>echocurl -s -m <n> <url> <n> >& <path>head -c <n>echo <val><command> <args>sleep <n>Requested execution waits related to source & workspace.
1 call · #0065–#0065
<command> <args>sleep <n>date -uRequested file and log inspection related to source & workspace.
1 call · #0066–#0066
cd <path><command> <args>tail -n <n>date -uRequested source searches and file and log inspection related to batching & scheduling.
1 call · #0067–#0067
cd <path>grep -E <val> <path>tail -n <n>echo <val>grep -c <val> <path>Requested source searches and file and log inspection related to benchmark & validation setup.
4 calls · #0068–#0071
cd <path>grep -n <val> <path>head -n <n>sed -n <val> <path>Requested code edits related to source & workspace.
1 call · #0072–#0072
Write <path>Requested environment setup or inspection, service requests and execution waits related to task requirements.
1 call · #0073–#0073
cd <path>env <vars>curl -s -X <val> <url> -H <path> -d <val> > <path>sleep <n><command> <args>tail -n <n>date -uRequested source searches and file and log inspection related to benchmark & validation setup.
1 call · #0074–#0074
cd <path>grep -n <val> -A <n> <path>head -n <n>Requested script or workload execution and file and log inspection related to source & workspace.
1 call · #0075–#0075
cd <path>bash <script> <val> <n> <val> <n> >& <path>tail -n <n>date -uRequested script or workload execution and source searches related to source & workspace.
1 call · #0076–#0076
cd <path>python3 - <script>grep -n <val> <path>Requested file and log inspection related to source & workspace.
1 call · #0077–#0077
sed -n <val> <path>Requested code edits related to source & workspace.
1 call · #0078–#0078
Edit <path>Requested environment setup or inspection, service requests and execution waits related to batching & scheduling.
1 call · #0079–#0079
cd <path>env <vars>curl -s -X <val> <url> -H <path> -d <val> > <path>sleep <n><command> <args>tail -n <n>date -uRequested environment setup or inspection, execution waits and file and log inspection related to task requirements.
1 call · #0080–#0080
cd <path>env <vars><command> <args>sleep <n>echo <val>tail -n <n>date -uRequested script or workload execution, file and log inspection and runtime inspection related to batching & scheduling.
2 calls · #0081–#0082
which <val> <n> > <path>python3 -c <script> <n> >& <path>head -n <n>echo <flag>ps <flag> <args>grep -E <val>grep -v <val>headcd <path>env <vars>curl -s -X <val> <url> -H <path> -d <val> > <path>sleep <n>nohup <val> <path> <flag> <args>timeout <n> <val> <val> -p <n> -d <n> -r <n> -o <path> <args>tail -n <n>echo <val>timeout <n> <val> <val> -p <n> -d <n> <flag> <args>date -uRequested script or workload execution related to source & workspace.
1 call · #0083–#0083
cd <path>python3 - <script>Requested file and log inspection related to batching & scheduling.
2 calls · #0084–#0085
cd <path>echo <val>sed -n <val> <path>Requested file and log inspection and source searches related to runtime processes.
1 call · #0086–#0086
cat <path> <n> > <path>tail -n <n>echo <flag>grep -i -E <val> <path>Requested environment setup or inspection, service requests and execution waits related to batching & scheduling.
1 call · #0087–#0087
cd <path>env <vars>curl -s -X <val> <url> -H <path> -d <val> > <path>sleep <n>nohup <val> <path> <flag> <args>timeout <n> <val> <val> -p <n> -d <n> -r <n> -o <path> <args>tail -n <n>tail -n <n> <path>date -uRequested script or workload execution and file and log inspection related to source & workspace.
1 call · #0088–#0088
cd <path>python3 - <script>tail -n <n> <path>Requested environment setup or inspection, source searches and file and log inspection related to batching & scheduling.
1 call · #0089–#0089
cd <path>env <vars><command> <args>grep -E <val>head -n <n>Requested environment setup or inspection, service requests and execution waits related to task requirements.
1 call · #0090–#0090
cd <path>env <vars>curl -s -X <val> <url> -H <path> -d <val> > <path>sleep <n>nohup <val> <path> <flag> <args>timeout <n> <val> <val> -p <n> -d <n> -r <n> -t -i <args>tail -n <n>date -uRequested script or workload execution related to source & workspace.
1 call · #0091–#0091
cd <path>python3 - <script>Requested workspace inspection and script or workload execution related to runtime processes.
1 call · #0092–#0092
cd <path>find <path> -name <path> <n> > <path>echo <flag>python3 -c <script>Requested file and log inspection related to source & workspace.
1 call · #0093–#0093
cd <path>sed -n <val> <path>Requested script or workload execution related to source & workspace.
2 calls · #0094–#0095
cd <path>python3 - <script>date -uecho <flag>Requested script or workload execution and file and log inspection related to source & workspace.
2 calls · #0096–#0097
python3 - <script>cd <path>wc -l <path> <path> <n> > <path>python3 -c <script>Requested file and log inspection, source searches and workspace inspection related to source & workspace.
6 calls · #0098–#0103
Read <path>sed -n <val> <path>grep -n <val> <path>head -n <n>cd <path>lsecho <val>grep -r -n <val> <path>headgrep -n <val> <path> <path>Requested source searches and file and log inspection related to attention kernels.
2 calls · #0104–#0105
cd <path>grep -n <val> <path>head -n <n>sed -n <val> <path>Requested file and log inspection related to source & workspace.
1 call · #0106–#0106
Read <path>Requested code edits related to source & workspace.
1 call · #0107–#0107
Edit <path>Requested file and log inspection related to source & workspace.
1 call · #0108–#0108
sed -n <val> <path>Requested code edits related to source & workspace.
5 calls · #0109–#0113
Edit <path>Requested script or workload execution and repository inspection related to source & workspace.
1 call · #0114–#0114
cd <path>python3 -m <module> <script>echo <val>git diff --statRequested runtime inspection, file and log inspection and source searches related to runtime processes.
6 calls · #0115–#0120
date -ups -o <val> -p <n> <n> <n> <n> > <path>headecho <flag><command> <args>grep <val>echo <val>ls -l -a <path> <n> > <path>head -n <n>cd <path>curl -s -m <n> <url> > <path> <n> >& <path>cat <path>kill <n> <n> > <path>sleep <n>kill <flag> <args>pkill <flag> <args>tail -n <val>mv -f <val> <val> <n> > <path>nohup <path> > <path> <n> >& <path>pgrep <flag> <args>tail -n <n> <path> <n> > <path>trueecho <path>grep -i -E <val> <path> <n> > <path>tail -n <n>Requested script or workload execution and file and log inspection related to source & workspace.
1 call · #0121–#0121
cd <path><script> <args>tail -n <n>Requested script or workload execution related to latency & request handling.
1 call · #0122–#0122
cd <path>python3 - <script>Requested script or workload execution and file and log inspection related to source & workspace.
2 calls · #0123–#0124
cd <path><script> <args>tail -n <n>date -uRequested process termination, execution waits and runtime inspection related to benchmark & validation setup.
1 call · #0125–#0125
pkill -f <val> <n> > <path>sleep <n>pkill <flag> <args>echo <val>pgrep <flag> <args>headcurl -s -m <n> <url> > <path> <n> >& <path>date -uRequested runtime inspection, file and log inspection and service requests related to runtime processes.
1 call · #0126–#0126
date -uecho <val>pgrep <flag> <args>head -n <n>curl -s -m <n> <url> > <path> <n> >& <path>Requested process termination, execution waits and runtime inspection related to device memory.
1 call · #0127–#0127
kill <flag> <args>sleep <n>echo <val>pgrep <flag> <args>grep -v <path>head -n <n>npu-smi info <n> > <path>date -uRequested workspace inspection, script or workload execution and file and log inspection related to benchmark & validation setup.
3 calls · #0128–#0130
ls -l -a <path> <n> > <path>echo <val>python3 -c <script>cd <val>timeout <n> <path> > <path> <n> >& <path>date -utail -n <n> <path>cd <path>python3 - <script>Requested file and log inspection, execution waits and runtime inspection related to benchmark & validation setup.
6 calls · #0131–#0136
cat <path>echo <val>date -ucd <val><command> <args>truesleep <n>pgrep <flag> <args>grep -v <path>head -n <n>tail -c <n> <path> <n> > <path>echohead <flag>find <val> -name <val> <flag> <args>cut <flag>find <val> <val> -maxdepth <n> -name <val> <flag> <args>cd <path>python3 - <script>Requested repository inspection, runtime inspection and source searches related to device memory.
1 call · #0137–#0137
cd <path>git diff > <path>echo <path>git status <flag>echo <val>pgrep <flag> <args>grep -v <path>head -n <n><command> <args>npu-smi info <n> > <path>grep -E <val>date -uRequested source searches and file and log inspection related to source & workspace.
5 calls · #0138–#0142
cd <path>grep -n <val> <path>head -n <n>echo <val>grep -r -n <val> <path> <n> > <path>sed -n <val> <path>sed -n <val><command> <args>head <flag>grep -n <val> <val>Requested code edits related to source & workspace.
2 calls · #0143–#0144
Edit <path>Requested file and log inspection related to source & workspace.
1 call · #0145–#0145
Read <path>Requested code edits related to source & workspace.
2 calls · #0146–#0147
Edit <path>Requested file and log inspection related to source & workspace.
1 call · #0148–#0148
Read <path>Requested code edits related to source & workspace.
1 call · #0149–#0149
Edit <path>Requested file and log inspection related to source & workspace.
1 call · #0150–#0150
Read <path>Requested code edits related to source & workspace.
2 calls · #0151–#0152
Edit <path>Requested script or workload execution and source searches related to source & workspace.
1 call · #0153–#0153
cd <path>python3 -m <module> <script>echo <val>grep -n <val> <path>echo <path>date -uRequested workspace file updates, execution waits and source searches related to runtime processes.
1 call · #0154–#0154
cd <path>mv -f <val> <val> <n> > <path>true<command> <args>sleep <n>date -ugrep -i -E <val> <path> <n> > <path>tail -n <n>Requested script or workload execution and file and log inspection related to source & workspace.
2 calls · #0155–#0156
cd <path><script> <args>tail -n <n>date -uecho <val>Requested process termination, execution waits and runtime inspection related to device memory.
1 call · #0157–#0157
pkill -f <val> <n> > <path>truesleep <n>pkill <flag> <args>echo <val>pgrep <flag> <args>grep -v <path>head -n <n>npu-smi info <n> > <path>grep -E <val>date -uRequested runtime inspection, source searches and file and log inspection related to device memory.
1 call · #0158–#0158
date -uecho <val>pgrep <flag> <args>grep -v <path>head -n <n>npu-smi info <n> > <path>grep -E <val>cd <val>timeout <n> <path> > <path> <n> >& <path>Requested script or workload execution, runtime inspection and source searches related to benchmark & validation setup.
1 call · #0159–#0159
cd <path>python3 - <script>echo <val>pgrep <flag> <args>grep -v <path>head -n <n><command> <args>date -uRequested execution waits, runtime inspection and source searches related to benchmark & validation setup.
1 call · #0160–#0160
cd <val><command> <args>truesleep <n>date -upgrep <flag> <args>grep -v <path>head -n <n>echo <val>Requested file and log inspection and source searches related to source & workspace.
2 calls · #0161–#0162
Read <path>cd <path>grep -r -n <val> --include <path> <path>grep -v <path>head -n <n>echo <val>Requested execution waits, runtime inspection and source searches related to benchmark & validation setup.
4 calls · #0163–#0166
sleep <n>date -uecho <val>pgrep <flag> <args>grep -v <path>head -n <n>wc -c <path> <n> > <path>cd <path>python3 - <script>Requested code edits related to source & workspace.
4 calls · #0167–#0170
Edit <path>Requested file and log inspection related to source & workspace.
1 call · #0171–#0171
Read <path>Requested code edits related to source & workspace.
1 call · #0172–#0172
Edit <path>Requested script or workload execution, source searches and file and log inspection related to source & workspace.
1 call · #0173–#0173
cd <path>python3 -m <module> <script>echo <val>echo <path>grep -n <val> <path>head -n <n>date -uRequested script or workload execution related to benchmark & validation setup.
2 calls · #0174–#0175
cd <val>timeout <n> <path> > <path> <n> >& <path>echo <val>date -ucd <path>python3 - <script>Requested script or workload execution, file and log inspection and runtime inspection related to device memory.
1 call · #0176–#0176
cd <val>timeout <n> <path> <n> >& <path>tail -n <n>echo <val>pgrep <flag> <args>grep -v <path>head -n <n><command> <args>npu-smi info <n> > <path>grep -E <val>git <val> <val>date -uRequested repository inspection, source searches and file and log inspection related to source & workspace.
2 calls · #0177–#0178
cd <path>echo <path>git status <flag>echo <val>git status <flag> <args>grep -v <val>head -n <n>git <val> <val>find <path> -name <val> <flag> <args>git diff --statdate -ugit diffRequested workspace file updates, workspace inspection and repository inspection related to device memory.
1 call · #0179–#0179
cd <path>cp <path> <path> <n> > <path>truerm -rf <path>rm -f <path>echo <val>ls <path> <n> > <path>echo <path>git status <flag>git diff --statpgrep <flag> <args>grep -v <path>head -n <n><command> <args>npu-smi info <n> > <path>grep -E <val>python3 -m <module> <script>find <path> -name <val> -path <val> <flag> <args>date -uRequested environment setup or inspection, workspace inspection and file and log inspection related to device memory.
1 call · #0180–#0180
env <vars>ls -l -a <val> <n> > <path>headecho <val>cat <path> <n> > <path>Requested code edits related to device memory.
3 calls · #0181–#0183
Write <path>Requested repository inspection, runtime inspection and source searches related to device memory.
1 call · #0184–#0184
cd <path>echo <val>git status <flag>pgrep <flag> <args>grep -v <path>head -n <n><command> <args>npu-smi info <n> > <path>grep -E <val>echo <path>ls -d <path> <n> > <path>date -u03 / CANDIDATE ARTIFACT
Read code changes as Git diffs. Identifying strings are masked; binary files are listed by their full relative names.
Base commit: 340db9201005fc64635bb25db1d2538f955761c3
@@ -43,6 +43,25 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend): inside the graph. replay_with_input_update substitutes fresh seq_lens without re-recording.""" + # --- persistent graph-update worker (see replay_with_input_update) ---+ # NPUGraph.update() re-invokes every captured attention op to regenerate+ # its device task params. It must run on a thread other than the one+ # calling replay(), but spawning a fresh thread per decode pass costs+ # both thread-creation time and GIL churn on the hot path, so one worker+ # is created lazily and reused.+ #+ # This state is class-level on purpose: torch_npu runs every update on+ # the single _GraphDispatchMode.update_stream shared by the whole+ # process, so updates from different backend instances (e.g. target and+ # draft runners) must serialize against each other, not just per graph.+ _update_lock = threading.Lock()+ _update_thread: Optional[threading.Thread] = None+ _update_request = threading.Event()+ _update_complete = threading.Event()+ _update_job: Optional[tuple] = None+ _update_exc: Optional[BaseException] = None+ _update_inflight = False+ def __init__( self, cuda_graph_runner: BaseCudaGraphRunner,@@ -64,6 +83,83 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend): cuda_graph_runner, "enable_torch_compile", False ) + # ------------------------------------------------------------------+ # Graph-update worker+ # ------------------------------------------------------------------++ @staticmethod+ def _update_worker_loop() -> None:+ """Serve graph.update() calls for the lifetime of the process.++ set_device is paid once per device rather than per pass.+ """+ cls = NPUCudaGraphBackend+ current_device = None+ while True:+ cls._update_request.wait()+ cls._update_request.clear()+ device_module, device_id, graph, cpu_update_input = cls._update_job+ try:+ if current_device != device_id:+ device_module.set_device(device_id)+ current_device = device_id+ graph.update(cpu_update_input=cpu_update_input)+ except BaseException as exc: # surfaced at the next barrier+ cls._update_exc = exc+ finally:+ cls._update_job = None+ cls._update_complete.set()++ @staticmethod+ def _ensure_update_worker() -> None:+ cls = NPUCudaGraphBackend+ if cls._update_thread is None:+ with cls._update_lock:+ if cls._update_thread is None:+ thread = threading.Thread(+ target=cls._update_worker_loop,+ name="npu-graph-update",+ daemon=True,+ )+ thread.start()+ cls._update_thread = thread++ @staticmethod+ def _wait_for_update() -> None:+ """Barrier for the in-flight graph.update(), if any.++ Deferred rather than taken immediately after replay(): the graph's+ captured per-layer ExternalEvent waits already order the update+ against the replay on the device, so the host only has to be sure+ one update has finished before it starts the next one (they share+ record.args/kwargs and the update stream). Delaying the barrier+ lets scheduler CPU work overlap the update instead of idling on it.+ """+ cls = NPUCudaGraphBackend+ if not cls._update_inflight:+ return+ cls._update_complete.wait()+ cls._update_complete.clear()+ cls._update_inflight = False+ if cls._update_exc is not None:+ exc = cls._update_exc+ cls._update_exc = None+ raise exc++ def _submit_update(self, graph: Any, cpu_update_input: list) -> None:+ # Bind the class explicitly, not type(self): the worker state has to+ # stay process-wide even if this class is ever subclassed.+ cls = NPUCudaGraphBackend+ cls._ensure_update_worker()+ cls._update_job = (+ self._device_module,+ self._device_id,+ graph,+ cpu_update_input,+ )+ cls._update_inflight = True+ cls._update_request.set()+ @contextmanager def capture_session(self, stream): if self._pool is None:@@ -84,6 +180,10 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend): ) -> None: import torch_npu # noqa: F401 (verifies NPU availability) + # Capture mutates the same dispatch-record / update-stream state an+ # in-flight update touches.+ self._wait_for_update()+ # Two warmups so kernels are loaded and one-time setup is paid before capture. # post_warmup_hook lets the attention backend reset state that warmup mutated. for _ in range(2):@@ -139,6 +239,7 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend): static_forward_batch: ForwardBatch, **kwargs, ) -> Any:+ self._wait_for_update() self._graphs[shape_key].replay() return self._outputs[shape_key] @@ -166,17 +267,19 @@ class NPUCudaGraphBackend(BaseCudaGraphBackend): graph = self._graphs[shape_key] - def _update():- self._device_module.set_device(self._device_id)- graph.update(cpu_update_input=cpu_update_input)-- thread = threading.Thread(target=_update)- thread.start()+ # Barrier for the *previous* pass's update before mutating the shared+ # dispatch records / update stream again.+ self._wait_for_update()+ self._submit_update(graph, cpu_update_input) graph.replay()- thread.join() return self._outputs[shape_key] def cleanup(self) -> None:+ # Drain any in-flight update before dropping the graphs it refers to.+ # The worker itself is process-wide and stays alive: another backend+ # instance may still be using it, and it holds no graph reference+ # between jobs (_update_job is cleared after each one).+ self._wait_for_update() self._graphs.clear() self._outputs.clear() self._pool = None