debug-distributed-hang

debug-distributed-hang is a skill for Claude Code, Codex from sgl-project/sglang. It costs 85 tokens per session (2,427 once invoked), scanned A, original, Apache-2.0.

A troubleshooting workflow for inference that hangs when several GPUs or distributed workers run SGLang together. It uses stack traces, per-worker logs, and step-by-step comparison to find where workers first stop agreeing.

In plain words
What is it for?
Investigating hangs in tensor, pipeline, data, or expert parallel inference, including deadlocks, mismatched data sizes, divergent code paths, and worker crashes.
Why use it?
It helps distinguish the first cause of a freeze from later symptoms, such as workers waiting forever at a shared GPU operation. This avoids guessing through a large distributed codebase.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/sgl-project/sglang/debug-distributed-hang
Any agent
npx skills add sgl-project/sglang --skill debug-distributed-hang
Clone the repo
git clone --depth 1 https://github.com/sgl-project/sglang

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for debug-distributed-hang

README.md
[![agentmods](https://agentmods.dev/badge/skills/sgl-project/sglang/debug-distributed-hang.svg)](https://agentmods.dev/skills/sgl-project/sglang/debug-distributed-hang)
Your own site
<a href="https://agentmods.dev/skills/sgl-project/sglang/debug-distributed-hang"><img src="https://agentmods.dev/badge/skills/sgl-project/sglang/debug-distributed-hang.svg" alt="Measured on agentmods" height="20"></a>
Per session 85 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,427 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00085 $0.02427
Opus 5 $0.00043 $0.01213
Sonnet 5 $0.00017 $0.00485
Haiku 4.5 $0.00009 $0.00243

Measured 4d ago against content hash b2287588e589, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

debug-distributed-hang scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/debug-distributed-hang/SKILL.md · 249 lines

How it starts

The opening of the file, as written. The whole thing — 249 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Debugging Distributed Hangs in SGLang

Overview

Hangs in distributed inference happen when ranks diverge in state, causing collective operations (AllGather, AllReduce, Broadcast, Barrier) to deadlock. Common causes:

  • Size mismatch: ranks pass different tensor sizes to a collective
  • Branch divergence: one rank enters a collective, another skips it
  • Cascading state drift: a small non-determinism (e.g., floating-point) propagates into different batch structures
  • Resource exhaustion: one rank OOMs or crashes, others wait forever

Prerequisites

  • py-spy: pip install py-spy or system package. Requires root or CAP_SYS_PTRACE to attach to running processes.
  • cuda-gdb: Ships with the CUDA toolkit. Ensure it's on your PATH.

Step 1: Confirm and Locate the Hang

1a. Watchdog / py-spy

SGLang's watchdog automatically dumps py-spy traces on timeout. Look for:

Scheduler watchdog timeout (self.watchdog_timeout=300, self.soft=False)

The py-spy dump shows the stack trace of each thread. The hanging thread is typically blocked in a CUDA synchronize or NCCL collective:

Thread (active): "MainThread"
    cuStreamSynchronize (libcuda.so)
    ...
    forward_extend (model_runner.py)

SGLang has two watchdog modes (see python/sglang/srt/utils/watchdog.py):

  • Hard watchdog (soft=False, default): dumps py-spy traces then sends SIGQUIT to kill the parent process.
  • Soft watchdog (soft=True): only logs the timeout without killing the process, giving you more time to manually attach debuggers or collect coredumps.

If the watchdog doesn't trigger, manually dump:

py-spy dump --pid <scheduler_pid>

1b. NCCL Debug Logging

export NCCL_DEBUG=INFO
export NCCL_DEBUG_SUBSYS=COLL

Look for the last collective logged before the hang. Mismatched sizes show up as one rank waiting and another never entering.

1c. CUDA Coredump

When a process hangs, you can trigger a GPU coredump on demand to see which kernel is stuck. Set these env vars before launching:

Read the full file on GitHub · 249 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 249 lines · 85 tokens per session scan A b2287588e589

Subscribe to this mod's changes

debug-distributed-hang is a skill published in the GitHub repository sgl-project/sglang (34,054 stars, last pushed today), licensed Apache-2.0. It adds 85 tokens to every session and 2,427 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

perf-host-analysis

Analyze host/CPU overhead in TensorRT-LLM inference from nsys traces. Detect whether host overhead is the bottleneck using GPU idle ratio, host prep exposed ratio, and per-phase evidence. For regressions, isolate forward steps via allreduce/NVTX patterns, compare host operation breakdowns across versions, and identify…

NVIDIA/TensorRT-LLM · 171 tokens

perf-host-optimization

Profiles and optimizes TensorRT-LLM host/CPU overhead using lineprofiler (with nsys support planned). Runs iterative profile-analyze-optimize-validate rounds. Use when GPU utilization is low or optimizing PyExecutor throughput.

NVIDIA/TensorRT-LLM · 52 tokens

mooncake-api

Help users work with the Mooncake Python APIs for distributed storage and high-performance data transfer. Use when working with Mooncake Store (distributed KV cache), Transfer Engine (RDMA/TCP transfers), service setup (master, metadata server), PyTorch tensors in the Store, zero-copy/buffer management, batch…

kvcache-ai/Mooncake · 122 tokens

mooncake-troubleshoot

Automatically diagnose Mooncake deployment and runtime issues. Checks services (mooncakemaster, metadata server), RDMA devices, environment variables, connectivity, memory limits, object integrity, and analyzes logs for common error patterns. Use when Mooncake deployment fails, services won't start, connections fail…

kvcache-ai/Mooncake · 134 tokens

release-notes

Draft concise release notes.

ollama/ollama · 9 tokens

mooncake-ci-local

Run Mooncake pre-PR local validation through scripts/runcitest.sh. Use this skill whenever the user wants to validate a branch before opening or submitting a PR, run local CI, run ci test, check changes before PR, reproduce GitHub Actions locally, or force a full pre-submit verification. Trigger on phrases like "提交 PR…

kvcache-ai/Mooncake · 108 tokens