Skip to content

πŸ”– chore: release 0.7.2 - #66

Merged
itdevwu merged 20 commits into
masterfrom
feat/v0.7.2
Dec 3, 2026
Merged

itdevwu merged 20 commits into
masterfrom
feat/v0.7.2

Conversation

@itdevwu

@itdevwu itdevwu commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

xprobe 0.7.2. Rebase-merge, then tag the merged commit v0.7.2.

This release lowers the glibc floor, adds a PyTorch reference to the Skill, and fixes a set of CUPTI Agent bugs found while capturing real PyTorch workloads. The worst of them could hang or crash the target. Closes #57 and #61.

Releases run on glibc 2.28 (#57)

  • scripts/build-release.sh builds both CUPTI Agents in NVIDIA's Rocky Linux 8 CUDA images and the CLI in manylinux_2_28, then packages them. CI, the release workflow, and just package all use it, so release jobs no longer install toolchains on the runner.
  • The CLI needs at most GLIBC_2.28, the Agents GLIBC_2.17. The archive, install.sh, and the wheel (now tagged manylinux_2_28) accept glibc 2.28, so RHEL 8, Rocky 8, and Ubuntu 20.04 hosts work.
  • Injection into targets on glibc before 2.34 works: those targets map libc-2.28.so and libdl-2.28.so, and injection looked only for libc.so* / libdl.so*, failing with target runtime symbol malloc was not found.
  • The Agent links libdl explicitly and the build rejects undefined symbols, so a missing dependency fails at build time instead of at dlopen in the target.

PyTorch reference in the Skill (#61)

  • skills/xprobe-perf-profiling/references/pytorch.md covers eager, torch.compile (Triton), CUDA Graph replay, NVTX, a training step (autograd thread, pageable HtoD copies, .item() sync), and a two-process prefill/decode server.
  • Every recipe runs against real captures from the pinned PyTorch 2.8 / CUDA 12.9 image, kept under tests/agent-contract/fixtures/pytorch/. test-agent-contract runs them; just capture-pytorch-fixtures records them again.
  • SKILL.md gained first-run pitfalls: the CUDA Graph launch selector, short stream-order windows, the multi-process PID split, torch.profiler and TEARDOWN_CUPTI, and calling analyze_trace.py from the Skill directory.

CUDA Graph captures no longer hang the target

CUPTI before 13.0 Update 1 (all of CUDA 12, and 13.0.0) deadlocks in cuptiActivityDisable(CUPTI_ACTIVITY_KIND_CONCURRENT_KERNEL) while another thread is inside cuGraphLaunch (NVIDIA bug 5350647). A tight CUDA Graph replay loop, as in LLM decode, hung the target on the first or second STOP. Eager cuLaunchKernel does not trigger it.

Leaving kernel activity on is no way out on CUDA 12: with it on, a forced flush crashed the target with an illegal memory access after about 25 million traced graph-node kernels (reproduced at the same count every run on 12.9; 13.3 passed 31M+).

On those CUPTI versions the Agent now:

  1. counts cuGraphLaunch / cuGraphLaunch_ptsz calls inside the driver during a kernel capture;
  2. at STOP, holds new graph launches at their API entry, waits until none is inside, disables kernel activity, and lets them go;
  3. flushes after that.

Graph launches wait 15 ms at most under a tight replay loop. A standalone test ran 300 rounds (38.6M kernels) with the gate and no hang or crash. Without it, rounds 1, 2, and 5 hung.

If a launch stays inside the driver for 1 s, kernel activity stays on until the next capture turns it off. The Agent prints why on the target's stderr, measure warns CUPTI_KERNEL_ACTIVITY_LEFT_ON, and the header sets a new feature flag. Measured cost while it stays on (CUDA 12.9, empty kernels, the worst case):

Workload Off On
24-node graph replay 33 Β΅s 54 Β΅s
256-node graph replay 209 Β΅s 295 Β΅s
24 separate launches 229 Β΅s 241 Β΅s

CUDA 13.0.1 and later disable kernel activity directly.

test-cupti-graph-stress-live (CUDA 13.3, 50 rounds) and -cuda12 (12.9, 100 rounds) arm and stop kernel captures while the target replays a 24-node graph without pause. They fail if a capture fails, the target stops beating, or a STOP leaves kernel activity on. A round now waits up to 10 s for the target's next heartbeat before calling it hung and reports any wait over 1 s, so a busy host no longer fails it. Both run in test-release-live.

Captures under sustained GPU load end on time

Under sustained kernel traffic a 100 ms capture could run for 15–48 s and fill --max-events:

  • A --duration-ms capture without --samples took back-to-back snapshots, each flushing CUPTI and re-evaluating every event. It now waits for the duration and stops once.
  • STOP flushed twice while API callbacks and activity were still recording, and each flush waited up to 5 s for quiet buffers that never came. STOP now stops API and NVTX recording and disables activity first, then delivers what was recorded. Activity that started after STOP is dropped.
  • A snapshot waited for 100 ms without a new buffer. It now asks CUPTI for completed buffers and replies at once; later buffers go to the next snapshot or the final flush.
  • A live --duration-ms capture kept collecting while any edge had no pair, until the timeout. An edge that never matched turned a 300 ms capture into 16 s and EVENT_RATE_TOO_HIGH, or CLEANUP_FAILED on longer runs. The duration now ends the capture, and the edge reports NO_MATCHED_SAMPLES.
  • Each control connection's recv/send times out after 30 s, so a stuck client cannot hold the Agent's flush lock.

Exact pairing and kernel names

  • A CUDA Graph launch pairs exactly with every kernel, copy, or memset it replays. All nodes share the launch's correlation ID, and exact matching used to drop that one-to-many case as ambiguous.
  • Kernel names longer than the record's 127 bytes (common for ATen templates) were cut silently and then failed to demangle. A cut name now carries attributes.name_complete: false in Event JSONL.

Agent fixes from an audit against Kineto and XLA

  • Forked children. A child forked from the target inherited the Agent's atexit handler. On exit it shut down the shared snapshot listener, joined a thread that does not exist in the child, unlinked the parent's control socket, and called CUPTI. The parent's snapshot thread then spun on accept errors, and later measure calls could not connect. The handler now does nothing outside the process that registered it. The graph stress fixture forks and exits a child before its first capture.
  • Taking turns with torch.profiler. The Agent registered its activity buffer callbacks once. After torch.profiler ran with TEARDOWN_CUPTI=1 in the same target, every later xprobe capture failed with EVENTS_DROPPED. Each ARM now registers the callbacks and enables its activity kinds again. Both calls were verified to be idempotent on CUDA 12.9 and 13.3: enabling twice and disabling once turns the kind off, and re-registering while activity is on hands pending buffers to the new callbacks.
  • Subscriber conflicts. Without TEARDOWN_CUPTI, torch.profiler keeps the CUPTI subscriber after its first run, so the conflict hint no longer suggests stopping it. cuptiSubscribe returning CUPTI_ERROR_MAX_LIMIT_REACHED is also reported as a subscriber conflict (stop reason 7, CUPTI_NOT_AVAILABLE with the hint) instead of a generic CUPTI error.
  • just test-pytorch-profiler-live alternates xprobe and torch.profiler on one target. After torch.profiler releases CUPTI, captures must receive kernels; while it holds the subscriber, they must fail with CUPTI_NOT_AVAILABLE. It runs in test-release-live.

Checked and left unchanged: CUPTI 13.1 release notes mention zero kernel timestamps with cuptiActivityRegisterTimestampCallback since 12.6 Update 2. On the 13.0.0 and 13.0.1 runtimes, 48,100 kernels (eager plus graph replay) all had timestamps, and the CUPTI live test with the release-built Agent passed with aligned clocks.

Verification

On the NVIDIA dev machine (RTX 3060 Laptop, WSL2), on the code of ea11554 (the release commit); the two docs commits before it change only README, docs, the Skill, and its fixture tests:

  • fmt-check, lint, test, test-agent-contract, test-cupti, and test-install;
  • the full test-release-live: BPF and CPU; CUPTI, burst, graph stress, NVTX, injection, and multisource on CUDA 12.9 and 13.3; the CUDA 12 minimum; trigger and Python-sample; PyTorch, PyTorch CUDA, the new torch.profiler handoff, and triage; and every benchmark it runs.

All passed, and neither graph stress run recorded a heartbeat stall. The Agent builds with -Werror in the pinned CUDA 12.9 and 13.3 images. After the docs commits, test-agent-contract and lint-commits passed again.

Before glibc 2.34 the target maps libc-2.28.so and libdl-2.28.so, so
injection looked only for libc.so* and libdl.so* and failed with "target
runtime symbol malloc was not found" on RHEL 8 and Ubuntu 20.04.
scripts/build-release.sh builds both CUPTI Agents in NVIDIA's Rocky Linux
8 CUDA images and the CLI in manylinux_2_28, then packages them. CI, the
release workflow, and `just package` all run it, so release jobs no longer
install packages on the runner. The CLI needs at most GLIBC_2.28 and the
Agents GLIBC_2.17; the archive, installer, and wheel (manylinux_2_28) now
accept glibc 2.28.

Closes #57
A live --duration-ms capture kept collecting while any edge had no pair,
until the timeout or --max-events. A graph edge that never matched ran a
300 ms capture for 16 s into EVENT_RATE_TOO_HIGH, and on a longer run the
stop timed out as CLEANUP_FAILED. The duration now ends the capture and
the final evaluation reports NO_MATCHED_SAMPLES for the edge.
Every node a cudaGraphLaunch replays carries the launch's correlation ID,
and exact matching dropped one API call with several activities as
ambiguous, so a graph launch never paired. A CUDA API call now pairs with
each kernel, copy, or memset it issued.
Kernel names longer than 127 bytes, as many ATen template names are, were
cut without a mark and then failed to demangle. A cut name now carries
attributes.name_complete: false, like --aggregate's name_complete.
references/pytorch.md states what eager, torch.compile, CUDA Graph replay,
and emit_nvtx leave in Event JSONL and --python-sample JSONL, how the
records join and how exactly, and recipes for GPU time per kernel, Triton
kinds, kernels per graph replay, the ATen op behind a kernel, and the
Python frame behind a launch. The facts and recipes come from PyTorch 2.8
captures kept as fixtures; test_pytorch_reference.py runs every recipe on
them, and just capture-pytorch-fixtures records them again.

Closes #61
Without --samples only --duration-ms ends a capture, yet the loop took
back-to-back snapshots, each flushing CUPTI in the target and re-evaluating
every event. Under sustained GPU work a 100 ms capture ran for 15-48 s and
filled --max-events. It now waits for the duration and stops once.
STOP flushed twice with activity and callbacks still recording. Under
sustained GPU work the buffers never went quiet, each flush waited its 5 s
limit, and the capture kept filling until --max-events or a failed state.
STOP now stops API and NVTX recording and disables activity first, then
delivers what was recorded. The buffer callback stops walking a buffer once
the capture is no longer active.
The Agent served each control connection under flush_mutex with blocking
recv and send, so a client that stopped reading or writing held it
indefinitely. Each recv and send now times out after 30 s.
A snapshot flushed CUPTI and then waited until no buffer arrived for
100 ms, which never happens under sustained GPU work, so --samples
captures stalled for up to 5 s per snapshot and kept filling. A snapshot
now asks CUPTI to deliver completed buffers and replies at once; the
next snapshot or STOP's final flush reads what arrives later.
CUPTI before 13.0 Update 1 deadlocks in
cuptiActivityDisable(CUPTI_ACTIVITY_KIND_CONCURRENT_KERNEL) while another
thread is inside cuGraphLaunch (NVIDIA bug 5350647): a tight CUDA Graph
replay loop hung the target on the first or second STOP. Leaving kernel
activity on is no way out: a forced flush with it on crashed the target
once about 25 million graph-node kernels had been traced.

On those versions the Agent counts cuGraphLaunch calls inside the driver
during a kernel capture. STOP holds new graph launches at their API entry,
waits until none is inside, disables kernel activity, lets them go, and
then flushes; launches wait 15 ms at most under a tight replay loop. If a
launch stays inside for 1 s, kernel activity stays on until the next
capture, the Agent prints why on the target's stderr, and measure warns
CUPTI_KERNEL_ACTIVITY_LEFT_ON. STOP now also stops API and NVTX recording
first and drops activity that started after it.
test-cupti-graph-stress-live and its CUDA 12 variant arm and stop kernel
captures 50 and 100 times while the target replays a 24-node graph without
pause. They fail if a capture fails, the target stops advancing, or a STOP
leaves kernel activity on. Both run in test-release-live.
A child forked from the target inherited the Agent's atexit handler. On
exit it shut down the shared snapshot listener, joined a thread that does
not exist in the child, unlinked the parent's control socket, and called
CUPTI. The parent's snapshot thread then spun on accept errors and later
measures could not connect. The handler now returns in any process other
than the one that registered it.

The CUDA Graph stress fixture forks and exits a child before its first
capture, and the test rejects accept errors on the target's stderr.
The Agent registered its activity buffer callbacks once and skipped
enabling kernel activity it believed was still on. After torch.profiler
ran with TEARDOWN_CUPTI=1 in the same target, every later capture failed
with EVENTS_DROPPED because CUPTI no longer delivered to the Agent. Each
ARM now registers the callbacks and enables its activity kinds again;
both calls are idempotent on CUDA 12.9 and 13.3.

torch.profiler without TEARDOWN_CUPTI keeps the CUPTI subscriber after
its first run, so the conflict hint no longer suggests stopping it.

test-pytorch-profiler-live alternates xprobe and torch.profiler on one
target and checks both outcomes.
cuptiSubscribe can return MAX_LIMIT_REACHED instead of
MULTIPLE_SUBSCRIBERS_NOT_SUPPORTED when another profiler holds the
subscriber. Map both to stop reason 7 so measure names the tools holding
it instead of reporting a generic CUPTI error.
The stress test failed a round when the target's heartbeat had not moved
0.2 s after a capture, which a busy host can cause. Wait up to 10 s for
the next beat, since a deadlocked target never beats again, and report
waits over 1 s.
@itdevwu itdevwu added this to the v0.7.2 milestone Dec 3, 2026
- Add Combining captures examples and first-run pitfall notes to SKILL.md
  (CUDA Graph launch selector, short stream-order windows, multi-process PID
  split, torch.profiler TEARDOWN_CUPTI, and skill-dir analyze_trace.py path).
- Extend capture_pytorch_fixtures.py, references/pytorch.md, and
  test_pytorch_reference.py with real training-step (autograd thread,
  pageable HtoD, .item() DtoH sync) and two-process prefill/decode serving
  fixtures and recipes.
@itdevwu
itdevwu merged commit 71338a0 into master Dec 3, 2026
14 checks passed
@itdevwu
itdevwu deleted the feat/v0.7.2 branch December 5, 2026 11:20
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.

Lower the release glibc floor from 2.34 to 2.28

1 participant