Inspect · Task requirements
Requested workspace inspection and file and log inspection related to task requirements.
3 calls · #0001–#0003
echo <val>find <path> -maxdepth <n> -name <val> <n> > <path>Read <path>Gemini 3.7 Flash · RL
Qwen3-0.6B CodeOpt GRPO 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 agentGemini 3.7 Flash · 235 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 task requirements.
3 calls · #0001–#0003
echo <val>find <path> -maxdepth <n> -name <val> <n> > <path>Read <path>Requested workspace inspection and file and log inspection related to source & workspace.
2 calls · #0004–#0005
ls -l -a <val>ls -l -a <path>Read <path>Requested file and log inspection related to reward & policy updates.
1 call · #0006–#0006
Read <path>Requested file and log inspection related to source & workspace.
3 calls · #0007–#0009
Read <path>Requested source searches related to runtime processes.
1 call · #0010–#0010
Search <pattern> <path>Requested file and log inspection related to source & workspace.
1 call · #0011–#0011
Read <path>Requested source searches related to task requirements.
1 call · #0012–#0012
Search <pattern> <path>Requested file and log inspection related to source & workspace.
5 calls · #0013–#0017
Read <path>Requested environment setup or inspection, source searches and script or workload execution related to source & workspace.
2 calls · #0018–#0019
envgrep <val>truebash <script>Requested file and log inspection related to benchmark & validation setup.
1 call · #0020–#0020
Read <path>Requested script or workload execution related to benchmark & validation setup.
1 call · #0021–#0021
bash <script>Requested workspace inspection related to source & workspace.
1 call · #0022–#0022
List <path>Requested file and log inspection and source searches related to benchmark & validation setup.
3 calls · #0023–#0025
Read <path>Search <pattern> <path>Requested file and log inspection related to source & workspace.
1 call · #0026–#0026
Read <path>Requested task coordination related to source & workspace.
1 call · #0027–#0027
Manage task <task>Requested file and log inspection and workspace inspection related to source & workspace.
2 calls · #0028–#0029
Read <path>List <path>Requested file and log inspection related to benchmark & validation setup.
2 calls · #0030–#0031
Read <path>Requested workspace inspection related to source & workspace.
1 call · #0032–#0032
Find <pattern>Requested file and log inspection related to benchmark & validation setup.
1 call · #0033–#0033
Read <path>Requested workspace inspection related to source & workspace.
1 call · #0034–#0034
List <path>Requested file and log inspection related to benchmark & validation setup.
1 call · #0035–#0035
Read <path>Requested runtime inspection and source searches related to source & workspace.
1 call · #0036–#0036
ps <val>grep <val>Requested runtime inspection related to device memory.
1 call · #0037–#0037
npu-smi infoRequested file and log inspection and source searches related to checkpoints & weight state.
5 calls · #0038–#0042
Read <path>Search <pattern> <path>Requested source searches related to source & workspace.
1 call · #0043–#0043
Search <pattern> <path>Requested task coordination related to source & workspace.
1 call · #0044–#0044
Manage task <task>Requested file and log inspection related to benchmark & validation setup.
1 call · #0045–#0045
Read <path>Requested file and log inspection related to source & workspace.
2 calls · #0046–#0047
Read <path>Requested file and log inspection related to benchmark & validation setup.
1 call · #0048–#0048
Read <path>Requested workspace inspection, source searches and file and log inspection related to source & workspace.
8 calls · #0049–#0056
Find <pattern>List <path>ls -l -a <path>Search <pattern> <path>Read <path>Requested file and log inspection related to benchmark & validation setup.
1 call · #0057–#0057
Read <path>Requested file and log inspection, workspace inspection and runtime inspection related to source & workspace.
3 calls · #0058–#0060
Read <path>find <path> <flag> <args>ps <val>grep <n>Requested file and log inspection related to benchmark & validation setup.
2 calls · #0061–#0062
Read <path>Requested source searches, file and log inspection and workspace inspection related to source & workspace.
10 calls · #0063–#0072
Search <pattern> <path>Read <path>Find <pattern>Requested source searches related to optimizer & gradients.
1 call · #0073–#0073
Search <pattern> <path>Requested file and log inspection related to source & workspace.
1 call · #0074–#0074
Read <path>Requested source searches related to optimizer & gradients.
1 call · #0075–#0075
Search <pattern> <path>Requested file and log inspection related to source & workspace.
1 call · #0076–#0076
Read <path>Requested file and log inspection related to optimizer & gradients.
1 call · #0077–#0077
Read <path>Requested file and log inspection related to task requirements.
1 call · #0078–#0078
Read <path>Requested source searches related to reward & policy updates.
1 call · #0079–#0079
Search <pattern> <path>Requested file and log inspection related to source & workspace.
1 call · #0080–#0080
Read <path>Requested file and log inspection related to task requirements.
1 call · #0081–#0081
Read <path>Requested tool activity related to source & workspace.
1 call · #0082–#0082
shell <script>Requested file and log inspection related to source & workspace.
1 call · #0083–#0083
Read <path>Requested task coordination related to source & workspace.
1 call · #0084–#0084
Manage task <task>Requested script or workload execution related to benchmark & validation setup.
1 call · #0085–#0085
bash <script>Requested workspace inspection related to source & workspace.
1 call · #0086–#0086
Find <pattern>Requested file and log inspection related to rollout generation.
1 call · #0087–#0087
Read <path>Requested source searches and file and log inspection related to source & workspace.
3 calls · #0088–#0090
Search <pattern> <path>Read <path>Requested script or workload execution and task coordination related to source & workspace.
2 calls · #0091–#0092
python3 -c <script>Manage task <task>Requested file and log inspection and workspace inspection related to source & workspace.
2 calls · #0093–#0094
Read <path>List <path>Requested file and log inspection related to benchmark & validation setup.
3 calls · #0095–#0097
Read <path>Requested file and log inspection related to source & workspace.
1 call · #0098–#0098
Read <path>Requested script or workload execution related to source & workspace.
1 call · #0099–#0099
python3 -c <script>Requested file and log inspection related to benchmark & validation setup.
1 call · #0100–#0100
Read <path>Requested source searches and file and log inspection related to source & workspace.
2 calls · #0101–#0102
Search <pattern> <path>Read <path>Requested file and log inspection related to rollout generation.
2 calls · #0103–#0104
Read <path>Requested source searches related to source & workspace.
1 call · #0105–#0105
Search <pattern> <path>Requested file and log inspection related to rollout generation.
2 calls · #0106–#0107
Read <path>Requested task coordination related to source & workspace.
1 call · #0108–#0108
Manage task <task>Requested file and log inspection related to benchmark & validation setup.
1 call · #0109–#0109
Read <path>Requested source searches and file and log inspection related to source & workspace.
3 calls · #0110–#0112
Search <pattern> <path>Read <path>Requested script or workload execution related to benchmark & validation setup.
1 call · #0113–#0113
bash <script>Requested file and log inspection related to benchmark & validation setup.
2 calls · #0114–#0115
Read <path>Requested task coordination related to source & workspace.
1 call · #0116–#0116
Manage task <task>Requested workspace inspection related to source & workspace.
1 call · #0117–#0117
List <path>Requested file and log inspection related to benchmark & validation setup.
2 calls · #0118–#0119
Read <path>Requested source searches and file and log inspection related to source & workspace.
3 calls · #0120–#0122
Search <pattern> <path>Read <path>Requested file and log inspection related to device memory.
1 call · #0123–#0123
Read <path>Requested source searches and file and log inspection related to source & workspace.
3 calls · #0124–#0126
Search <pattern> <path>Read <path>Requested file and log inspection and source searches related to device memory.
3 calls · #0127–#0129
Read <path>Search <pattern> <path>Requested file and log inspection and source searches related to source & workspace.
3 calls · #0130–#0132
Read <path>Search <pattern> <path>Requested file and log inspection and source searches related to rollout generation.
4 calls · #0133–#0136
Read <path>Search <pattern> <path>Requested source searches and file and log inspection related to source & workspace.
12 calls · #0137–#0148
Search <pattern> <path>Read <path>Requested source searches related to optimizer & gradients.
1 call · #0149–#0149
Search <pattern> <path>Requested file and log inspection and source searches related to source & workspace.
7 calls · #0150–#0156
Read <path>Search <pattern> <path>Requested source searches and file and log inspection related to attention kernels.
2 calls · #0157–#0158
Search <pattern> <path>Read <path>Requested workspace inspection, file and log inspection and source searches related to source & workspace.
8 calls · #0159–#0166
Find <pattern>Read <path>Search <pattern> <path>Requested file and log inspection related to device memory.
2 calls · #0167–#0168
Read <path>Requested code edits related to device memory.
1 call · #0169–#0169
Edit <path>Requested file and log inspection related to source & workspace.
1 call · #0170–#0170
Read <path>Requested code edits related to source & workspace.
1 call · #0171–#0171
Edit <path>Requested file and log inspection related to attention kernels.
1 call · #0172–#0172
Read <path>Requested code edits related to attention kernels.
1 call · #0173–#0173
Edit <path>Requested file and log inspection related to rollout generation.
2 calls · #0174–#0175
Read <path>Requested file and log inspection and source searches related to source & workspace.
6 calls · #0176–#0181
Read <path>Search <pattern> <path>Requested file and log inspection related to device memory.
1 call · #0182–#0182
Read <path>Requested script or workload execution related to benchmark & validation setup.
1 call · #0183–#0183
bash <script>Requested file and log inspection related to benchmark & validation setup.
3 calls · #0184–#0186
Read <path>Requested script or workload execution related to benchmark & validation setup.
1 call · #0187–#0187
bash <script>Requested script or workload execution related to benchmark & validation setup.
1 call · #0188–#0188
bash <script>Requested file and log inspection related to benchmark & validation setup.
1 call · #0189–#0189
Read <path>Requested file and log inspection related to rollout generation.
1 call · #0190–#0190
Read <path>Requested source searches related to runtime processes.
1 call · #0191–#0191
Search <pattern> <path>Requested file and log inspection related to source & workspace.
3 calls · #0192–#0194
Read <path>Requested file and log inspection related to rollout generation.
1 call · #0195–#0195
Read <path>Requested file and log inspection related to source & workspace.
2 calls · #0196–#0197
Read <path>Requested code edits related to source & workspace.
1 call · #0198–#0198
Edit <path>Requested file and log inspection related to source & workspace.
1 call · #0199–#0199
Read <path>Requested code edits related to source & workspace.
1 call · #0200–#0200
Edit <path>Requested file and log inspection related to rollout generation.
2 calls · #0201–#0202
Read <path>Requested file and log inspection related to device memory.
1 call · #0203–#0203
Read <path>Requested code edits related to device memory.
1 call · #0204–#0204
Edit <path>Requested file and log inspection related to rollout generation.
2 calls · #0205–#0206
Read <path>Requested code edits related to rollout generation.
1 call · #0207–#0207
Edit <path>Requested file and log inspection related to rollout generation.
1 call · #0208–#0208
Read <path>Requested code edits related to rollout generation.
1 call · #0209–#0209
Edit <path>Requested file and log inspection related to rollout generation.
1 call · #0210–#0210
Read <path>Requested code edits related to rollout generation.
1 call · #0211–#0211
Edit <path>Requested file and log inspection related to source & workspace.
1 call · #0212–#0212
Read <path>Requested script or workload execution related to benchmark & validation setup.
1 call · #0213–#0213
bash <script>Requested file and log inspection related to benchmark & validation setup.
1 call · #0214–#0214
Read <path>Requested script or workload execution related to benchmark & validation setup.
1 call · #0215–#0215
bash <script>Requested file and log inspection and source searches related to reward & policy updates.
3 calls · #0216–#0218
Read <path>Search <pattern> <path>Requested task coordination related to source & workspace.
1 call · #0219–#0219
Manage task <task>Requested file and log inspection related to benchmark & validation setup.
1 call · #0220–#0220
Read <path>Requested script or workload execution related to benchmark & validation setup.
1 call · #0221–#0221
bash <script>Requested source searches and file and log inspection related to source & workspace.
6 calls · #0222–#0227
Search <pattern> <path>Read <path>Requested task coordination related to source & workspace.
1 call · #0228–#0228
Manage task <task>Requested file and log inspection related to benchmark & validation setup.
1 call · #0229–#0229
Read <path>Requested workspace inspection, source searches and file and log inspection related to source & workspace.
6 calls · #0230–#0235
Find <pattern>Search <pattern> <path>Read <path>03 / CANDIDATE ARTIFACT
Read code changes as Git diffs. Identifying strings are masked; binary files are listed by their full relative names.
Base commit: 76b3bd40ca74d26f0c2bffaf42ed01f422fc70f6
@@ -83,6 +83,21 @@ def npu_flash_attn_func( return output +def _extract_seq_len(cu_seqlens):+ if cu_seqlens is None:+ return None+ if isinstance(cu_seqlens, (list, tuple)):+ return tuple(cu_seqlens)+ cached = getattr(cu_seqlens, "_cached_seq_len", None)+ if cached is None:+ cached = tuple(cu_seqlens[1:].tolist())+ try:+ cu_seqlens._cached_seq_len = cached+ except Exception:+ pass+ return cached++ def npu_flash_attn_varlen_func( q, k,@@ -101,6 +116,9 @@ def npu_flash_attn_varlen_func( if softmax_scale is None: softmax_scale = 1.0 / math.sqrt(q.shape[-1]) + actual_seq_qlen = _extract_seq_len(cu_seqlens_q)+ actual_seq_kvlen = _extract_seq_len(cu_seqlens_k)+ if not causal: head_num = q.shape[1] output = npu_fusion_attention(@@ -113,8 +131,8 @@ def npu_flash_attn_varlen_func( scale=softmax_scale, keep_prob=keep_prob, input_layout="TND",- actual_seq_qlen=tuple(cu_seqlens_q[1:].cpu().numpy().tolist()),- actual_seq_kvlen=tuple(cu_seqlens_k[1:].cpu().numpy().tolist()),+ actual_seq_qlen=actual_seq_qlen,+ actual_seq_kvlen=actual_seq_kvlen, )[0] else: attn_mask_npu = get_attn_mask_npu(q.device)@@ -130,8 +148,8 @@ def npu_flash_attn_varlen_func( scale=softmax_scale, keep_prob=keep_prob, input_layout="TND",- actual_seq_qlen=tuple(cu_seqlens_q[1:].cpu().numpy().tolist()),- actual_seq_kvlen=tuple(cu_seqlens_k[1:].cpu().numpy().tolist()),+ actual_seq_qlen=actual_seq_qlen,+ actual_seq_kvlen=actual_seq_kvlen, sparse_mode=SPARSE_MODE, )[0] Base commit: 0b2151ec61de5d99e0811b01c09e43a99a23e69d
@@ -30,48 +30,9 @@ logger.setLevel(os.getenv("VERL_LOGGING_LEVEL", "WARN")) def aggressive_empty_cache(force_sync: bool = True, max_retries: int = 3) -> None: """- More aggressive GPU memory cleanup function, tries to release PyTorch reserved- but unallocated memory.-- Args:- force_sync: Whether to force device synchronization- max_retries: Maximum number of retries+ No-op: Memory fits comfortably in device memory without aggressive cache clearing. """- device = get_torch_device()- if not device.is_available():- return-- for attempt in range(max_retries):- # Record memory status before cleanup- before_reserved = device.memory_reserved()- before_allocated = device.memory_allocated()-- # Run garbage collection- gc.collect()-- # Clear PyTorch cache- device.empty_cache()-- # Force synchronization (optional)- if force_sync:- device.synchronize()-- # Record memory status after cleanup- after_reserved = device.memory_reserved()- after_allocated = device.memory_allocated()-- # Calculate freed memory- reserved_freed = before_reserved - after_reserved- allocated_freed = before_allocated - after_allocated-- logger.info(- f"Memory cleanup attempt {attempt + 1}: Freed {reserved_freed / 1024**3:.2f} GB reserved, "- f"{allocated_freed / 1024**3:.2f} GB allocated"- )-- # Stop retrying if little memory was freed- if reserved_freed < 1024**3: # less than 1GB- break+ return def reset_memory_stats() -> None:@@ -71,6 +71,10 @@ def rebuild_shared_memory(name: str, size: int, dtype=torch.uint8): return tensor, shm +_GLOBAL_SENDERS: dict[str, "BucketedWeightSender"] = {}+_GLOBAL_RECEIVERS: dict[str, "BucketedWeightReceiver"] = {}++ class BucketedWeightSender: """ Send model weights via bucketed IPC transfer over ZMQ.@@ -84,6 +88,17 @@ class BucketedWeightSender: use_shm: Use shared memory instead of CUDA IPC (for NPU compatibility) """ + @classmethod+ def get_or_create(+ cls,+ zmq_handle: str,+ bucket_size_mb: int = 512,+ use_shm: bool = False,+ ) -> "BucketedWeightSender":+ if zmq_handle not in _GLOBAL_SENDERS:+ _GLOBAL_SENDERS[zmq_handle] = cls(zmq_handle, bucket_size_mb, use_shm)+ return _GLOBAL_SENDERS[zmq_handle]+ def __init__( self, zmq_handle: str,@@ -99,6 +114,7 @@ class BucketedWeightSender: self.socket = None self.buffer = None self.shm = None+ self.is_initialized = False async def async_send_weights(self, weights): """@@ -109,54 +125,45 @@ class BucketedWeightSender: """ from verl.workers.rollout.utils import ensure_async_iterator - try:+ if not self.is_initialized: self._init_socket() self._init_buffer()+ self.is_initialized = True - # send bucket weights- offset = 0- bucket_meta: dict[str, TensorMetadata] = {}- # dtype = PrecisionType.to_dtype(self.config.dtype)- async for name, weight in ensure_async_iterator(weights):- # model parameters are in fp32 full precision- # (vermouth1992) we should not force cast weight here because some parameters- # (such as moe gate) have to keep fp32 precision. If a weight is bf16 in the rollout side,- # the rollout should automatically cast on demand. However, this would incur a higher weight- # transfer volume.- # weight = weight.to(dtype, non_blocking=True)-- # fill the tensor bucket- if offset + weight.nbytes > self.bucket_size and len(bucket_meta) > 0:- get_torch_device().synchronize()- self.socket.send_pyobj({"bucket_meta": bucket_meta, "is_last": False})- self.socket.recv()- bucket_meta = {}- offset = 0-- if offset + weight.nbytes > self.bucket_size:- assert not self.use_shm, (- f"Weight {name}({weight.shape}, {weight.dtype}) is too large to fit in the bucket."- f"Please increase rollout.update_weights_bucket_megabytes({self.bucket_size_mb} MB)."- )- self._direct_send_large_weight(name, weight)- continue-- bucket_meta[name] = {- "name": name,- "shape": weight.shape,- "dtype": weight.dtype,- "offset": offset,- "handle": None,- }- self.buffer[offset : offset + weight.nbytes].copy_(weight.view(-1).view(torch.uint8), non_blocking=True)- offset += weight.nbytes-- # send the last bucket- get_torch_device().synchronize()- self.socket.send_pyobj({"bucket_meta": bucket_meta, "is_last": True})- self.socket.recv()- finally:- self._cleanup()+ # send bucket weights+ offset = 0+ bucket_meta: dict[str, TensorMetadata] = {}+ async for name, weight in ensure_async_iterator(weights):+ # fill the tensor bucket+ if offset + weight.nbytes > self.bucket_size and len(bucket_meta) > 0:+ get_torch_device().synchronize()+ self.socket.send_pyobj({"bucket_meta": bucket_meta, "is_last": False})+ self.socket.recv()+ bucket_meta = {}+ offset = 0++ if offset + weight.nbytes > self.bucket_size:+ assert not self.use_shm, (+ f"Weight {name}({weight.shape}, {weight.dtype}) is too large to fit in the bucket."+ f"Please increase rollout.update_weights_bucket_megabytes({self.bucket_size_mb} MB)."+ )+ self._direct_send_large_weight(name, weight)+ continue++ bucket_meta[name] = {+ "name": name,+ "shape": weight.shape,+ "dtype": weight.dtype,+ "offset": offset,+ "handle": None,+ }+ self.buffer[offset : offset + weight.nbytes].copy_(weight.view(-1).view(torch.uint8), non_blocking=True)+ offset += weight.nbytes++ # send the last bucket+ get_torch_device().synchronize()+ self.socket.send_pyobj({"bucket_meta": bucket_meta, "is_last": True})+ self.socket.recv() def _init_socket(self): """Initialize ZMQ REQ socket and bind."""@@ -193,30 +200,11 @@ class BucketedWeightSender: def _cleanup(self): """clean up"""- if self.socket is not None:- self.socket.close()- self.socket = None- if self.zmq_handle.startswith("ipc://"):- ipc_path = self.zmq_handle[len("ipc://") :]- try:- os.remove(ipc_path)- except OSError:- pass- del self.buffer- self.buffer = None- if self.shm is not None:- self.shm.close()- self.shm.unlink()- del self.shm- self.shm = None- gc.collect()- get_torch_device().ipc_collect()- get_torch_device().empty_cache()+ pass def _direct_send_large_weight(self, name: str, weight: torch.Tensor): """Send a weight larger than the bucket size via cuda ipc or share memory.""" logger.debug(f"Direct sending large weight {name}({weight.shape}, {weight.dtype})")- # TODO: support fallback to shared memory handle = reduce_tensor(weight) bucket_meta: dict[str, TensorMetadata] = {} bucket_meta[name] = {@@ -243,6 +231,17 @@ class BucketedWeightReceiver: use_shm: Use shared memory instead of CUDA IPC """ + @classmethod+ def get_or_create(+ cls,+ zmq_handle: str,+ device: torch.device,+ use_shm: bool = False,+ ) -> "BucketedWeightReceiver":+ if zmq_handle not in _GLOBAL_RECEIVERS:+ _GLOBAL_RECEIVERS[zmq_handle] = cls(zmq_handle, device, use_shm)+ return _GLOBAL_RECEIVERS[zmq_handle]+ def __init__( self, zmq_handle: str,@@ -257,6 +256,7 @@ class BucketedWeightReceiver: self.socket = None self.buffer = None self.shm = None+ self.is_initialized = False def receive_weights(self, on_bucket_received: callable): """@@ -265,33 +265,32 @@ class BucketedWeightReceiver: Args: on_bucket_received: Callback function(weights: list[(name, tensor)]) called per bucket. """- try:+ if not self.is_initialized: self._init_socket() self._init_buffer()-- # receive bucket and update weights- while True:- metadata = self.socket.recv_pyobj()- weights, tensor = [], None- for name, meta in metadata["bucket_meta"].items():- shape, dtype, offset, handle = meta["shape"], meta["dtype"], meta["offset"], meta["handle"]- if handle is not None:- tensor = rebuild_ipc(handle, self.device.index)- weights.append((name, tensor))- continue- size = dtype.itemsize * shape.numel()- tensor = self.buffer[offset : offset + size].view(dtype=dtype).view(shape)- if self.use_shm:- tensor = tensor.to(self.device)+ self.is_initialized = True++ # receive bucket and update weights+ while True:+ metadata = self.socket.recv_pyobj()+ weights, tensor = [], None+ for name, meta in metadata["bucket_meta"].items():+ shape, dtype, offset, handle = meta["shape"], meta["dtype"], meta["offset"], meta["handle"]+ if handle is not None:+ tensor = rebuild_ipc(handle, self.device.index) weights.append((name, tensor))- on_bucket_received(weights)- get_torch_device().synchronize()- self.socket.send(b"")- del weights, tensor- if metadata["is_last"]:- break- finally:- self._cleanup()+ continue+ size = dtype.itemsize * shape.numel()+ tensor = self.buffer[offset : offset + size].view(dtype=dtype).view(shape)+ if self.use_shm:+ tensor = tensor.to(self.device)+ weights.append((name, tensor))+ on_bucket_received(weights)+ get_torch_device().synchronize()+ self.socket.send(b"")+ del weights, tensor+ if metadata["is_last"]:+ break def _init_socket(self): """Initialize ZMQ REP socket and connect."""@@ -316,18 +315,4 @@ class BucketedWeightReceiver: def _cleanup(self): """clean up"""- if self.socket is not None:- self.socket.close()- self.socket = None- # Synchronize before releasing the buffer to ensure all async ops- # referencing it (e.g. clone, .to()) have completed.- get_torch_device().synchronize()- del self.buffer- self.buffer = None- if self.shm is not None:- self.shm.close()- del self.shm- self.shm = None- gc.collect()- get_torch_device().ipc_collect()- get_torch_device().empty_cache()+ pass@@ -255,7 +255,7 @@ class vLLMColocateWorkerExtension: patch_vllm_moe_model_weight_loader(model) assert self.device is not None- receiver = BucketedWeightReceiver(+ receiver = BucketedWeightReceiver.get_or_create( zmq_handle=self._get_zmq_handle(), device=self.device, use_shm=use_shm,@@ -237,7 +237,7 @@ class ServerAdapter(BaseRollout): ) bucket_size_mb = self.config.checkpoint_engine.update_weights_bucket_megabytes- sender = BucketedWeightSender(+ sender = BucketedWeightSender.get_or_create( zmq_handle=self.zmq_handle, bucket_size_mb=bucket_size_mb, use_shm=self.use_shm,Base commit: 5a0277de14789b245c781911b3119ed6af901b7b
@@ -223,6 +223,8 @@ class AutoWeightsLoader: weight_loader = getattr(param, "weight_loader", default_weight_loader) weight_loader(param, weight_data)+ if hasattr(self, "_plan_collector") and self._plan_collector is not None:+ self._plan_collector[weight_qualname] = (param, weight_loader) logger.debug("Loaded weight %s with shape %s", weight_qualname, param.shape) @@ -340,12 +342,27 @@ class AutoWeightsLoader: ) -> set[str]: if mapper is not None: weights = mapper.apply(weights)++ cached_plan = getattr(self.module, "_vllm_cached_weight_plan", None)+ if cached_plan is not None:+ autoloaded_weights = set()+ for name, weight in weights:+ if name in cached_plan:+ param, weight_loader = cached_plan[name]+ weight_loader(param, weight)+ autoloaded_weights.add(name)+ return autoloaded_weights+ # filter out weights with first-prefix/substr to skip in name- weights = (+ weights_list = [ (name, weight) for name, weight in weights if not self._can_skip(name)- )+ ] - autoloaded_weights = set(self._load_module("", self.module, weights))+ self._plan_collector = {}+ autoloaded_weights = set(self._load_module("", self.module, weights_list))+ if self._plan_collector:+ self.module._vllm_cached_weight_plan = self._plan_collector+ self._plan_collector = None return autoloaded_weights Base commit: f649187194c44d86415d1ddfa49359e824932c9a
@@ -177,50 +177,16 @@ class CaMemAllocator: def sleep(self, offload_tags: tuple[str, ...] | str | None = None) -> None: """ Put the allocator in sleep mode.- All data in the memory allocation with the specified tag will be- offloaded to CPU memory, and others will be discarded.- :param offload_tags: The tags of the memory allocation that will be- offloaded. The rest of the memory allocation will be discarded.+ Since both Actor and Rollout fit in device memory, sleep is a no-op. """- if offload_tags is None:- # by default, allocated tensors are offloaded- # when the allocator sleeps- offload_tags = (CaMemAllocator.default_tag,)- elif isinstance(offload_tags, str):- offload_tags = (offload_tags,)-- assert isinstance(offload_tags, tuple)-- for ptr, data in self.pointer_to_data.items():- handle = data.handle- if data.tag in offload_tags:- size_in_bytes = handle[1]- cpu_backup_tensor = torch.empty(size_in_bytes, dtype=torch.uint8, device="cpu", pin_memory=True)- cpu_ptr = cpu_backup_tensor.data_ptr()- ACL_MEMCPY_DEVICE_TO_HOST = 2- dest_max = cpu_ptr + size_in_bytes * 2- memcpy(cpu_ptr, dest_max, ptr, size_in_bytes, ACL_MEMCPY_DEVICE_TO_HOST)- data.cpu_backup_tensor = cpu_backup_tensor- unmap_and_release(handle)+ return def wake_up(self, tags: list[str] | None = None) -> None: """ Wake up the allocator from sleep mode.- All data that is previously offloaded will be loaded back to GPU- memory, and the rest of the data will have empty memory."""- for ptr, data in self.pointer_to_data.items():- if tags is None or data.tag in tags:- handle = data.handle- create_and_map(handle)- if data.cpu_backup_tensor is not None:- cpu_backup_tensor = data.cpu_backup_tensor- if cpu_backup_tensor is not None:- size_in_bytes = cpu_backup_tensor.numel() * cpu_backup_tensor.element_size()- cpu_ptr = cpu_backup_tensor.data_ptr()- ACL_MEMCPY_HOST_TO_DEVICE = 1- dest_max = ptr + size_in_bytes * 2- memcpy(ptr, dest_max, cpu_ptr, size_in_bytes, ACL_MEMCPY_HOST_TO_DEVICE)- data.cpu_backup_tensor = None+ Since sleep did not unmap or offload memory, wake_up is a no-op.+ """+ return @contextmanager def use_memory_pool(self, tag: str | None = None):@@ -188,31 +188,10 @@ class NPUWorker(WorkerBase): return def sleep(self, level: int = 1) -> None:- free_bytes_before_sleep = torch.npu.mem_get_info()[0]- # Save the buffers before level 2 sleep- if level == 2:- model = self.model_runner.model- self._sleep_saved_buffers = {name: buffer.cpu().clone() for name, buffer in model.named_buffers()}- allocator = CaMemAllocator.get_instance()- allocator.sleep(offload_tags=("weights",) if level == 1 else tuple())- free_bytes_after_sleep, total = torch.npu.mem_get_info()- freed_bytes = free_bytes_after_sleep - free_bytes_before_sleep- used_bytes = total - free_bytes_after_sleep- assert freed_bytes >= 0, "Memory usage increased after sleeping."- logger.info(- "Sleep mode freed %.2f GiB memory, %.2f GiB memory is still in use.",- freed_bytes / GiB_bytes,- used_bytes / GiB_bytes,- )+ return def wake_up(self, tags: list[str] | None = None) -> None:- if envs_ascend.VLLM_ASCEND_ENABLE_NZ:- raise ValueError(- "FRACTAL_NZ mode is enabled. This may cause model parameter precision issues "- "in the RL scenarios. Please set VLLM_ASCEND_ENABLE_NZ=0."- )- allocator = CaMemAllocator.get_instance()- allocator.wake_up(tags=tags)+ return hidden_size = self.vllm_config.model_config.hf_text_config.hidden_size model = self.model_runner.model