Skip to content

Multi-GPU vllm serve captures: per-worker reports, pipeline steps, collectives - #3

Merged
0Chencc merged 1 commit into
VirtualGPU:mainfrom
0Chencc:fix/vllm-serve-multi-gpu
Dec 2, 2026
Merged

0Chencc merged 1 commit into
VirtualGPU:mainfrom
0Chencc:fix/vllm-serve-multi-gpu

Conversation

@0Chencc

@0Chencc 0Chencc commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Why

Running Ledger on a multi-GPU vllm serve (tensor parallel 2 × pipeline parallel 3, vLLM 0.32, six RTX 5090, official vLLM image) hit several things in a row. None of them shows on a single GPU.

  1. ledger build failed in the image: CUPTI only exists as a pip wheel (site-packages/nvidia/cu13/{include,lib}, libcupti.so.13 with no libcupti.so), and a container gets libcuda.so.1 without libcuda.so.
  2. The memory-map export raised in warm-up: ReplicatedLinear has no input_size_per_partition, so the server never came up.
  3. With the default fork start method the workers recorded nothing at all.
  4. The capture directory then held six sets of files, and ledger report merged them: pointers of one process were resolved against another's memory map, and kernels of six GPUs counted as overlapping on one.
  5. Per worker, the step books were off: 905 "steps" for a window of 300 graph launches, a negative "idle between kernels in the step", and the top finding was an NCCL kernel "running on 1 block for 170 SMs".

What changes

  • Per-worker reports. ledger report on a capture of several processes writes pid-<pid>/report.md for each (links to that process's files plus the shared run.json). analyze.load refuses a multi-process directory and points there, so analyze, steps, perfetto, transfers and diff cannot silently mix processes.
  • Pipeline steps. With pipeline parallelism a worker is stepped for every batch in flight, also when the batch is at another stage. Such a marker interval touches no weight (it launches a collective or nothing). split_steps folds it into the step before it, so a step is one forward pass. Without a memory map nothing is folded.
  • Collectives. NCCL kernels get a ## Collectives section (launches, median, ms/step, alone ms/step) and a waiting in collectives (part of busy) row in ## Step: the time in which only collectives ran. They are no longer listed as underfilled launches, and the effective bandwidth is taken over busy time without that wait.
  • busy_and_gaps took the span to end with the last launch to start. A kernel that outlasts it (a blocking collective, a second stream) made busy exceed the span.
  • vllm_regions: widths fall back to input_size / output_size for layers that are not split across ranks.
  • Fork. The capture library exports the pid where it started CUPTI (LEDGER_INIT_PID); the plugin compares it with its own and says on stderr that the worker will record nothing and to set VLLM_WORKER_MULTIPROC_METHOD=spawn.
  • Build. ledger build also looks for CUPTI in the nvidia wheels and passes what it found to make; the Makefile links libcupti.so.<N> and libcuda.so.1 (or the toolkit's stub) by file name.

Checked

  • pytest tests: 50 passed (42 before; new tests in tests/test_multi_gpu.py and tests/test_build.py).
  • ledger build from this branch inside the stock image, then a small capture with it: timed kernel records come back.
  • Fork vs spawn with a minimal multiprocessing script under LD_PRELOAD: the forked child leaves no kernel records, the spawned one does.
  • The real capture (batch 1 decode, LEDGER_GRAPH_WINDOW=1500:300), one worker of the middle pipeline stage, before and after:
before after
steps counted 905 (analyze), 595 (steps) 300, 300
wall time per step 3.98 ms 12.02 ms
GPU busy per step 2.75 ms 8.31 ms, of which 5.61 ms waiting in collectives
idle between kernels in the step (steps) -0.48 ms 2.87 ms
top finding ncclDevKernel_Broadcast_RING_LL runs on 1 block for 170 SMs the GPU waits 5.61 ms per step in collectives

The three stages now agree with each other: 300 or 301 steps and a 10.6 ms cycle on each.

Not done

  • No single set of books across the workers: a collective's wait is not charged to the rank it waited for. README "Next" says so.
  • LEDGER_INIT_IN_CHILD=1 did not make a forked Python child record anything in my test either; I did not look into why and left it alone.
  • The reports are named by pid; mapping a pid to its rank is left to the process list.
  • Only decode at batch 1 was captured on this setup.

…llectives

A capture of a tensor- and pipeline-parallel vllm serve holds one set of files per GPU
worker. Loading them as one mixed the address spaces of the processes and counted their
kernels as overlapping on one GPU.

- ledger report writes one report per process under pid-<pid>/; the other commands refuse
  a capture of several processes and take those directories.
- split_steps folds the step markers of pipeline ticks that run no forward pass into the
  step before them, so a step is one forward pass on that worker.
- NCCL collectives get a Collectives section and a 'waiting in collectives' row instead of
  being reported as underfilled launches; the effective bandwidth excludes that wait.
- busy_and_gaps took the span to end with the last launch to start; a kernel that outlasts
  it made the idle time negative.
- vllm_regions: ReplicatedLinear has no per-partition widths; the export raised on it.
- The plugin warns when a worker was forked from the process where CUPTI started and will
  record nothing.
- ledger build finds CUPTI in pip-installed nvidia wheels and links libcupti.so.<N> and
  libcuda.so.1 by file name, which the official vLLM images need.
@0Chencc
0Chencc merged commit f6488a3 into VirtualGPU:main Dec 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant