Skip to main content

Agent Integration

xprobe exposes four CLI commands, versioned JSON/JSONL, 26 JSON Schemas, and one official Agent Skill. It does not call model APIs or run a daemon.

The canonical Skill lives at skills/xprobe-perf-profiling/SKILL.md. AGENTS.md, CLAUDE.md, and .cursor/rules/xprobe.mdc point to it without duplicating command lists or schema rules.

Install the Skill​

The Skill follows the open Agent Skills format and works with Codex, Claude Code, Cursor, and compatible clients:

npx skills add itdevwu/xprobe

To pin a release or install non-interactively, see Installation — AI Agent Skill. Keep the full directory intact so references/, examples/, and scripts/analyze_trace.py remain available.

Skill boundaries​

xprobe-perf-profiling intentionally avoids prescribing a fixed investigation procedure. It focuses on what agents need to get right on the first try:

  1. Command-to-evidence mapping: what each command and mode produces.
  2. Exact artifact shapes: stdout keys, real JSONL line shapes, pairing keys, and clock conversion math (references/data-format.md).
  3. Selector syntax & overhead limits: filter pushdown rules and high-rate bounds (references/selectors.md).
  4. Hard runtime constraints & accounting traps: namespace/ptrace/NVTX prerequisites, and keeping stream gaps distinct from device idle time.

Command-to-evidence lookup​

NeedCommand
Check eBPF, ptrace, NVIDIA, CUDA/CUPTIxprobe doctor
List CUDA context holders under a PIDxprobe discover --pid "$ROOT"
Dry-run selectors, symbols, or injectionxprobe validate --pid "$PID" --from A --to B --match exact
Python stacks & GIL holder (CPython 3.9–3.14)xprobe measure --pid "$PID" --python-sample --duration-ms 2000
Native CPU callchain hotspotsxprobe measure --pid "$PID" --cpu-sample --duration-ms 2000
Syscall count & duration totalsxprobe measure --pid "$PID" --syscall-aggregate --duration-ms 2000
GPU kernel / memcpy / memset totalsxprobe measure --pid "$PID" --from cuda:kernel_start --to cuda:kernel_end --match exact --aggregate --duration-ms 2000
Exact A → B latency (with Event JSONL)xprobe measure --pid "$PID" --from cuda:launch_api:exit --to cuda:kernel_start --match exact --samples 200
Full GPU timeline / stream gaps / idlexprobe measure --pid "$PID" --from cuda:kernel_end --to cuda:kernel_start --match stream-order --duration-ms 2000 --events-out trace.jsonl
Up to 8 edges in one capturexprobe measure --spec graph.json
Wait for rare GPU bubble / gap / spikexprobe measure --pid "$PID" --trigger-idle-ms 10 --pre-ms 50 --post-ms 50 --events-out spikes
Re-correlate a saved Event JSONL offlinexprobe measure --input trace.jsonl --from A --to B --match exact
Same-window cgroup / thread / NVML snapshotxprobe measure --pid "$PID" --triage --duration-ms 2000

With --triage, read the raw inline inventories (threads, cgroup, gpu_devices, cpu_hotspots, python_hotspots, syscalls, gpu_activity) rather than relying on its static findings ranking.

Hard constraints​

  • Containers & namespaces: a host process cannot inject CUPTI into a container with a different mount namespace; run xprobe inside the target's PID and mount namespaces.
  • CUDA injection & NVTX: live CUDA capture attaches via ptrace and leaves the CUPTI .so mapped (logically disabled after stop). NVTX ranges require NVTX_INJECTION64_PATH set before the target's first NVTX call.
  • Process discovery: discover lists NVML CUDA context holders only; locate pure CPU/Python/gateway PIDs with ps or workload metadata.
  • Flag bounds: live measure requires --samples or --duration-ms. Inventory modes (--aggregate, --cpu-sample, --python-sample, --syscall-aggregate, --triage) accept --duration-ms only.
  • Cross-process & clocks: run concurrent xprobe measure --pid ... commands to profile multiple processes or ranks. On one host, host_monotonic, cupti_normalized_to_host_monotonic, and Python sample timestamp_ns share CLOCK_MONOTONIC and join directly in Python or analyze_trace.py. Never pass mixed-PID artifacts to measure --input, and never subtract raw cupti timestamps from host timestamps.
  • Accounting: a single-stream gap is not GPU idle time, and summed concurrent kernel durations are not wall time. Always check quality.verdict, dropped, and all_gpu_activity before acting on numbers.

Automated checks​

just test-agent-contract
just test-skill-install

test-agent-contract verifies that the public CLI is exactly doctor, discover, validate, and measure, invokes them in JSON mode, checks all 26 JSON Schemas, runs the analyze_trace.py fixture suite, and validates the Skill (word budget, links, no orphaned references, documented xprobe flags against --help, cited artifact fields against schemas/, valid JSON blocks, and example specs). test-skill-install runs the skills CLI in isolated home directories and checks byte-for-byte copies for Codex, Claude Code, and Cursor.