Skip to main content

Data Format, Clocks & Scripting

Every xprobe command prints one JSON document to stdout when stdout is not a terminal (schema_version "3.0" or "2.0"). Use this page to parse results and write one-off Python/jq scripts on the first try.

Stdout & artifact paths by mode​

ModeArtifact file path in stdout JSONMain inline data in stdout JSON
Single-edge measureevidence.artifact.path (Event JSONL)measurement.{latency_ns, samples}, quality, evidence.exemplars, evidence.pairs (with --evidence full)
Graph measure --specartifact.path (also on each edges[].evidence.artifact.path)edges[].{name, measurement, quality, evidence}
--python-sampleartifact.path (Python sample JSONL)inventory.{gil_hotspots, gil_released_proportion, gil_stack_groups, thread_stack_groups, native_waits}, collection
--trigger-*windows[].artifact.path (one Event JSONL per window)trigger, observed, windows[].{fired, start_ns, end_ns, truncated, longest}, collection
--aggregatenone (inline only)inventory.groups[], collection.{cuda_devices, dropped_activities, table_utilization}
--cpu-samplenone (inline only)inventory.{hotspots, stack_groups}, symbolization.python_status, collection
--syscall-aggregatenone (inline only)inventory.groups[], collection
--triageper-source paths in sources[]sources[], not_covered, threads, cgroup, cpu_hotspots, python_hotspots, syscalls, gpu_activity, gpu_devices, findings

Errors exit non-zero and print JSON (ok: false, error.{code, message, details, hints}), preserving any written artifact path in details.


Event JSONL (*.jsonl)​

One JSON object per line (schema_version: "2.0"). Concrete shapes for the main event kinds:

{"schema_version":"2.0","session_id":"s1","event_id":"e1","sequence":1,"source":"cupti_activity","event_type":"gpu_kernel_start","pid":4242,"tid":0,"timestamp_raw":1000,"timestamp_ns":1000,"clock_domain":"cupti_normalized_to_host_monotonic","cuda":{"device_id":0,"context_id":1,"stream_id":7,"correlation_id":99,"kernel_name":"flash_fwd","grid":{"x":64,"y":1,"z":1},"block":{"x":128,"y":1,"z":1}},"host":null,"nvtx":null,"attributes":{}}
{"schema_version":"2.0","session_id":"s1","event_id":"e2","sequence":2,"source":"cupti_callback","event_type":"cuda_api_exit","pid":4242,"tid":4242,"timestamp_raw":950,"timestamp_ns":950,"clock_domain":"host_monotonic","cuda":{"correlation_id":99,"callback_domain":2,"callback_id":211},"host":null,"nvtx":null,"attributes":{"cuda_api_name":"cudaLaunchKernel","cuda_api_domain":"runtime_api"}}
{"schema_version":"2.0","session_id":"s1","event_id":"e3","sequence":3,"source":"ebpf","event_type":"syscall_exit","pid":4242,"tid":4242,"timestamp_raw":900,"timestamp_ns":900,"clock_domain":"host_monotonic","cuda":null,"host":{"probe_kind":"syscall","symbol":"futex","return_value":0,"arguments":[]},"nvtx":null,"attributes":{}}

Key details that trip up scripts:

  • event_type values: gpu_kernel_start|end, gpu_memcpy_start|end, gpu_memset_start|end, cuda_api_entry|exit, nvtx_range_start|end, host_function_entry|exit, kernel_function_entry|exit, syscall_entry|exit, tracepoint, python_gc_start|end, marker.
  • Where names live: cuda.kernel_name, cuda.memcpy_kind (HtoD|DtoH|DtoD|HtoH|PtoP|unknown), cuda.bytes, attributes.cuda_api_name (not inside cuda), nvtx.name (plus nvtx.range_kind, nvtx.range_id, nvtx.start_tid), host.symbol_demangled / host.symbol / host.binary_path / host.return_value.
  • GPU activity is two lines: a *_start and *_end paired by (kind, pid, cuda.device_id, cuda.context_id, cuda.stream_id, cuda.correlation_id, name). Records with attributes.get("start_unknown") were still running at STOP: their time is their stream's previous end, they mark the stream busy, and they never give a duration, gap, or latency.
  • Clocks: host_monotonic and cupti_normalized_to_host_monotonic both use CLOCK_MONOTONIC and compare directly with each other, with --python-sample timestamps, and across processes on the same host. Raw cupti timestamps only compare with raw cupti from the same capture. Within identical timestamps, order by sequence.

Capture manifest (<artifact>.manifest.json)​

Written beside every Event JSONL (schema_version: "1.0"). Keep it beside the trace so measure --input and analyze_trace.py can verify completeness and map devices/clocks:

{
"schema_version": "1.0",
"target": {"pid": 4242, "process_start_time": 987654},
"window": {"start_ns": 1000000, "end_ns": 3000000},
"selectors": ["cuda:kernel_end", "cuda:kernel_start"],
"all_gpu_activity": true,
"peer_copies": true,
"dropped_records": 0,
"unknown_records": 0,
"record_limit_reached": null,
"capture_failed": false,
"cuda_devices": [{"device_id": 0, "uuid": "GPU-xxxx", "gpu_uuid": null}],
"wall_clock": {
"start": {"monotonic_ns": 1000000, "realtime_ns": 1730000000000000000, "uncertainty_ns": 500},
"end": {"monotonic_ns": 3000000, "realtime_ns": 1730000000002000000, "uncertainty_ns": 500}
},
"artifact": {"format": "jsonl", "events": 5000, "bytes": 1234567, "sha256": "..."}
}
  • all_gpu_activity: true is required for trustworthy GPU idle time (otherwise filtered-out kernels look like idle).
  • cuda_devices maps process-local device_id (affected by CUDA_VISIBLE_DEVICES) to physical uuid (or MIG uuid + gpu_uuid). Always group cross-process GPUs by UUID.

Python sample JSONL (--python-sample)​

One line per sample at result["artifact"]["path"]:

{"timestamp_ns":1001234,"pid":4242,"tid":4242,"gil":true,"truncated":false,"frames":[{"function":"step","file":"train.py","first_line":40},{"function":"main","file":"train.py","first_line":10}],"native":null}
{"timestamp_ns":1005000,"pid":4242,"tid":4248,"gil":false,"truncated":false,"frames":[{"function":"recv","file":"comm.py","first_line":12}],"native":{"syscall":"futex","module":"libc.so.6","symbol":"__futex_abstimed_wait_common"}}
  • timestamp_ns is CLOCK_MONOTONIC (joins directly with Event JSONL).
  • frames[0] is the innermost frame; first_line is where the function starts, not the executing line.
  • gil: true = high-rate GIL-holder ticks (default 2000 Hz); gil: false = all-thread sweep samples (default 100 Hz), with native populated when a swept thread was blocked in a syscall/native call.
  • Stdout collection reports gil_hz_achieved, inconsistent_reads, tid_source, and wall_clock.

Inventory, measurement, and trigger stdout fields​

  • Exact / Graph: measurement.latency_ns.{min, mean, p50, p90, p95, p99, max}, measurement.samples.{matched, unmatched_start, unmatched_end, ambiguous, dropped}, quality.{verdict, issues}, correlation.{method, confidence}, clock.{alignment, estimated_error_ns}, collection.{coverage, cupti, cuda_devices, wall_clock}. timed_out stats are partial.
  • GPU --aggregate: inventory.groups[] entries have activity (kernel|memcpy|memset), name, name_complete, memcpy_kind, src_memory, dst_memory (pageable = staged sync copy), device_id, count, total_bytes, duration_ns.{min, mean, max, total}, start_selector_hint, end_selector_hint.
  • CPU --cpu-sample: inventory.hotspots[] (frame.{symbol, module_path, language}, exclusive_proportion, inclusive_proportion, entry_selector_hint, return_selector_hint), inventory.stack_groups[], symbolization.python_status, collection.{lost_samples, truncated_stacks, threads_attached, threads_observed}.
  • Syscall --syscall-aggregate: inventory.groups[] (syscall_name, syscall_number, count, errors, duration_ns.{min, mean, max, total}, entry_selector_hint, exit_selector_hint). Blocked time includes idle waiting.
  • Trigger --trigger-*: trigger.{kind, threshold_ns}, observed.{spans, over_threshold, longest}, windows[] (fired, start_ns, end_ns, truncated, longest, artifact), collection.{overwritten_records, dropped_records, lost_windows, revoked_windows}.

Bundled analyzer (analyze_trace.py)​

Use it instead of rewriting interval-union math by hand:

# Single trace: per-GPU busy/idle/compute/comm/transfer, kernels, memcpy bandwidth, stream gaps
analyze_trace.py trace.jsonl --comm-kernel 'nccl|custom_allreduce'

# Vertical slice around the largest GPU idle gap + concurrent Python stacks
analyze_trace.py trace.jsonl --slice-gap 1 --window-ms 2 --python-samples py.jsonl

# Slice around slowest measured pair or explicit CLOCK_MONOTONIC timestamps
analyze_trace.py trace.jsonl --measurement res.json --slice-outlier 1
analyze_trace.py trace.jsonl --around 1000000:2000000 --python-samples py.jsonl

# Multi-rank / multi-process comparison on one host (budgets over shared window)
analyze_trace.py rank0.jsonl rank1.jsonl rank2.jsonl rank3.jsonl

Key output fields: devices[] (uuid, span, busy_ns, idle_ns, compute_ns, communication_ns, communication_only_ns, transfer_ns, top_idle_gaps, top_compute_gaps), kernels.by_name[] (with selector_hint and launch_variants), memcpy (bandwidth_gbps), streams[].top_gaps, gpu.top_idle_gaps, slice (with python), warnings (WALL_CLOCK_DRIFT, GPU_ACTIVITY_COVERAGE_UNKNOWN, CAPTURE_INCOMPLETE). Multi-trace mode adds devices[].shares and spread (compute_share, most_compute, most_communication_only, most_idle). --comm-kernel defaults to nccl, unanchored so it matches mangled names such as _Z40ncclDevKernel_AllReduce...; extend it for custom collectives (vLLM, TRT-LLM, FlashInfer, NVSHMEM/DeepEP).


One-off script recipes & RSI loops​

1. Pair GPU intervals & compute true device busy/idle​

import collections, json

def load_gpu_intervals(jsonl_path):
starts, intervals = collections.defaultdict(collections.deque), []
for line in open(jsonl_path):
e = json.loads(line)
t = e["event_type"]
if not t.startswith("gpu_") or e.get("attributes", {}).get("start_unknown"):
continue
c = e["cuda"]
kind = t.split("_")[1] # kernel | memcpy | memset
name = c.get("kernel_name") or c.get("memcpy_kind") or "memset"
key = (kind, e["pid"], c["device_id"], c["context_id"], c["stream_id"], c["correlation_id"], name)
if t.endswith("_start"):
starts[key].append(e)
elif starts[key]:
s = starts[key].popleft()
intervals.append((s["timestamp_ns"], e["timestamp_ns"], kind, name, c["device_id"], c["stream_id"], s["clock_domain"]))
return intervals

def merge_union(spans): # [(start_ns, end_ns), ...] -> non-overlapping merged spans
merged = []
for s, e in sorted(spans):
if merged and s <= merged[-1][1]:
merged[-1] = (merged[-1][0], max(merged[-1][1], e))
else:
merged.append((s, e))
return merged

2. Cross-process / cross-source timeline join (same host)​

HOST_CLOCKS = {"host_monotonic", "cupti_normalized_to_host_monotonic"}
t0, t1 = gap_start_ns - 2_000_000, gap_end_ns + 2_000_000
py_in_gap = [json.loads(l) for l in open("api_py.jsonl") if t0 <= json.loads(l)["timestamp_ns"] <= t1]
gpu_in_gap = [
e for e in map(json.loads, open("worker_gpu.jsonl"))
if e["clock_domain"] in HOST_CLOCKS and t0 <= e["timestamp_ns"] <= t1
]

For traces from different hosts, clocks are unrelated: compare normalized shares (idle_ns / span_ns) or map each trace through its manifest wall_clock to UTC.

3. Convert CLOCK_MONOTONIC to UTC wall time (join with app logs)​

wc = json.load(open("trace.jsonl.manifest.json"))["wall_clock"]
def mono_to_utc_ns(t_ns):
a = min((wc["start"], wc["end"]), key=lambda x: abs(t_ns - x["monotonic_ns"]))
return a["realtime_ns"] + (t_ns - a["monotonic_ns"])

Check abs((wc["end"]["realtime_ns"] - wc["end"]["monotonic_ns"]) - (wc["start"]["realtime_ns"] - wc["start"]["monotonic_ns"])): a large diff means wall clock drifted or stepped during capture.

4. Quantitative before/after diff in an RSI loop​

Pin the exact same --spec (or CLI flags/bounds) before and after each optimization candidate:

  • Guard every comparison: require ok == True, no drops, and check quality.verdict (plus all_gpu_activity == True when comparing idle_ns).
  • Compare directly on machine-readable metrics:
    • Latency edge: measurement.latency_ns["p50"] and ["p95"]
    • GPU budget (analyze_trace.py): devices[0]["compute_ns"], devices[0]["idle_ns"], devices[0]["communication_only_ns"], or kernels["by_name"] totals
    • Python GIL (--python-sample): inventory["gil_released_proportion"] and top inventory["gil_hotspots"]
    • Copy overhead (--aggregate): inventory["groups"] grouped by (memcpy_kind, src_memory, dst_memory)

JSON Schemas Index​

For all 26 generated JSON Schemas, required/optional top-level fields, and shared enum values, see JSON Interfaces & Schemas.