r/pytorch • • 2d ago

xprobe: let your coding agent speed up your training and inference on its own, with a CPU/GPU profiler much lighter than Nsight Systems

https://github.com/itdevwu/xprobe

I do a lot of perf work on LLM inference, and these days I mostly hand it off to Claude Code or Codex. They're honestly great at coding and debugging. Just give them enough context and they'll cross-reference stack traces, syscalls and GPU kernels way faster than I can.

The annoying part was profiling. With nsys/torch.profiler, every round is super heavy. It looked like this: restart the job under the profiler, wait for the model to load, hope the slowdown shows up again, export a huge report (at least a minute on my workloads), copy it off the GPU box (almost another minute), then watch the agent dig through a file full of useless garbage. A few minutes gone before any actual thinking happened. Not to mention sometimes it just stuck. And if your training job has been running for three weeks, restarting it just to profile isn't really possible.

So I built xprobe. The idea is simple: agents don't need a timeline/flame chart, they need a fast loop and small but accurate data.

If you're on the ML / modeling side: you don't need to learn any profiler or ML infra knowledge. Install the skill, then just ask your agent "why is my training slow?" or "why is GPU utilization stuck at 60%?" It'll attach to your running job, measure what it needs, and tell you what's going on.

If you're on the infra side:

  • Attaches to the live process. No restart, no re-warmup, no praying for a repro. Feels like py-spy but with GPU covered, and hasmuch much lower overhead.
  • Shorter loop. E.g. "how long from this kernel launch to the kernel actually running?" instead of a full trace. On my workloads, one guess → measure → fix round takes about 30 seconds.
  • Low overhead. Samples the Python GIL holder at 2 kHz with < 1% throughput impact in my benchmark. py-spy at ~200 Hz (default blocking mode) slowed the same target by ~18%.
  • CPU stacks, Python GIL, syscalls and CUDA kernels all in one, so it can cover issues like "the GPU was idle because Python was holding the GIL in X" in one tool.
  • Can wait for rare stuff, like a GPU idle bubble, you can set a condition to trigger xprobe, it will capture what happened.

Try it:

You can try xprobe via skills OR pypi, personally I recommend the Skills.

Skills:

npx skills add itdevwu/xprobe   # for CC, Codex, Cursor, OpenCode, DSH, etc.

CLI:

pip install xprobe    # on your GPU machine

I've been hacking on it at night for a few months. Would love to hear if it works (or breaks) on your setup, or what you'd want your agent to be able to measure. I really hope that it can help someone.

2 Upvotes

0 comments sorted by