[Bug] BaseModelAgent.update_weights_from_distributed returns locally on exception without signaling peers, hanging healthy ranks in dist.broadcast
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- distributed-systems
Direzione di ricerca
Read lmdeploy/pytorch/engine/model_agent/agent.py around BaseModelAgent.update_weights_from_distributed (lines 2103-2147) and trace its process-group setup and broadcast call paths. Focus on how ranks handle local allocation errors before entering collectives and failures between buckets. Done means a rank-local failure is reported consistently so peer ranks do not hang; the multi-GPU CUDA/NCCL trigger has not been run.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
In lmdeploy/pytorch/engine/model_agent/agent.py (commit 3d6f0bbfceda3095d7959c72d534f9bb385f15ae, present at HEAD), BaseModelAgent.update_weights_from_distributed wraps local tensor allocation and torch.distributed.broadcast inside a try ... except Exception: block that catches the exception locally and returns (False, msg) without aborting or notifying peer ranks in pg:
# lmdeploy/pytorch/engine/model_agent/agent.py:2103-2147
@torch.inference_mode()
def update_weights_from_distributed(self, request: UpdateWeightsFromDistributedRequest):
...
device = torch.cuda.current_device()
try:
if request.names:
named_tensors = []
for name, dtype_str, shape in zip(request.names, request.dtypes, request.shapes):
target_dtype = getattr(torch, dtype_str) if isinstance(dtype_str, str) else dtype_str
named_tensors.append((name, torch.empty(shape, dtype=target_dtype, device=device)))
if request.load_format == 'flattened_bucket':
bucket = FlattenedTensorBucket(named_tensors=named_tensors)
flattened_tensor = bucket.get_flattened_tensor()
dist.broadcast(flattened_tensor, src=0, group=pg)
weights = list(bucket.reconstruct_tensors())
else:
handles = []
for _, tensor in named_tensors:
handles.append(dist.broadcast(tensor, src=0, group=pg, async_op=True))
for handle in handles:
handle.wait()
weights = named_tensors
...
return True, 'Succeeded to update parameter online.'
except Exception as e:
msg = (f'Failed to update parameter online: {e}. The model weights are partially updated; '
'please discard them and reload.')
logger.exception(msg)
return False, msg
Source-Verified Scope & Trigger Condition
(Source-verified on HEAD 3d6f0bbfceda3095d7959c72d534f9bb385f15ae; multi-GPU CUDA/NCCL runtime trigger described below has not been executed locally.)
If a single rank encounters an exception before entering the collective dist.broadcast calls—for example:
- rank-local CUDA OOM in
torch.empty(shape, dtype=target_dtype, device=device)(line 2119) orFlattenedTensorBucket(...)(line 2122), or - an invalid
dtype_str/ metadata error on one worker—
that rank catches the exception at line 2143 and returns (False, msg) immediately, while all other ranks in pg enter dist.broadcast(..., group=pg) (lines 2124 or 2129) and hang until the distributed communicator timeout expires. Similarly, if an earlier async dist.broadcast or _load_updated_weight_bucket fails on one rank in a multi-bucket update, the failing rank returns early while peers wait indefinitely in the next bucket's collective.
Affected Location
- Repository:
InternLM/lmdeploy(3d6f0bbfceda3095d7959c72d534f9bb385f15ae, present atHEAD) - File & lines:
lmdeploy/pytorch/engine/model_agent/agent.py:2103-2147(BaseModelAgent.update_weights_from_distributed)
Minimal Standalone Reproduction
Multi-rank CUDA/NCCL trigger pattern (source-verified):
- Initialize a 2+ rank weights-update process group
pg(init_weights_update_group). - Trigger a rank-local failure on rank 1 before line 2124/2129 (e.g., rank 1 hits
torch.cuda.OutOfMemoryErrorinsidetorch.empty(shape, ...)at line 2119 while rank 0 has sufficient free GPU memory). - Observe rank 1 catching the exception at line 2143 and returning
(False, ...), while rank 0 blocks insidedist.broadcast(..., group=pg)until NCCL timeout (or indefinitely ifasync_op=True/ subsequent collectives are awaited).
Suggested Fix
- Collective preflight agreement before broadcasting: Perform tensor allocation /
FlattenedTensorBucketconstruction first, and synchronize per-rank readiness (e.g., anall_reduce/all_gathererror-flag check on a lightweight control group) before enteringdist.broadcastso if any rank fails allocation, all ranks abort together and return(False, msg)cleanly without hanging peers. - On collective failure or partial bucket failure, mark the weight-update group unhealthy / tear down
self._model_update_group[group_name](or propagate failure across ranks) rather than leaving peers blocked inside NCCL.
- Lingua principale
- Python
- Stelle
- 8.2k
- Fork
- 797
- Merge medio
- 3g 15h
- PR unite (30g)
- 52
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di InternLM/lmdeploy
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 2 giorni
-
[Bug] apply_rotary_pos_emb: leaves output tails unwritten with partial rotationForse già presa @shotsan l’ha presa 15 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
[Bug] PyTorch engine ignores use_rslora, so rsLoRA adapters run sqrt(r) times too weakForse già presa @Andreas-Hum l’ha presa 25 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
[Feature] Expose `max_model_len` (session_len) in `/v1/models` model cardForse già presa @FOWEPJF255 l’ha presa 37 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di InternLM/lmdeploy
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
Techiebutler/freeframe#687 ·
I maintainer di solito rispondono entro 1 giorno
-
bug verbose GC
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
IBM/javacore-analyser#677 ·
I maintainer di solito rispondono entro 1 giorno
-
area/config comp/plugins P1 platform/qqbot tool/file type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
NousResearch/hermes-agent#163932 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
plugins/dsh: todayStr() computes UTC but is documented as local — journal entries written 00:00–08:00 local land in the previous day's fileForse già presa @Beehtrix l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
zilliztech/memsearch#907 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[integration]: SynapCoresApertaexternal
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
langchain-ai/docs#8386 ·
I maintainer di solito rispondono entro 1 giorno