Nexus
Nexus intercepts Heterogeneous System Architecture (HSA) packets, extracts the source code from them, and outputs assembly and HIP code in a structured format.
Installation
# From Gitpip install "git+https://github.com/AMDResearch/intellikit.git#subdirectory=nexus"
# Editable install for developmentgit clone https://github.com/AMDResearch/intellikit.gitcd intellikitpip install -e ./nexusManual C++ build (optional)
cmake -B build \ -DCMAKE_PREFIX_PATH=${ROCM_PATH} \ -DLLVM_INSTALL_DIR=/opt/rocm/llvm \ -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel 16Python API
from nexus import Nexus
# Create tracernexus = Nexus(log_level=1)
# Run and get tracetrace = nexus.run(["python", "my_gpu_script.py"])
# Iterate over kernelsfor kernel in trace: print(f"{kernel.name}: {len(kernel.assembly)} instructions")
# Assembly instructions for i, asm_line in enumerate(kernel.assembly, 1): print(f" {i:3d}. {asm_line}")
# HIP source with line numbers if kernel.lines and len(kernel.lines) == len(kernel.hip): for line_no, hip_line in zip(kernel.lines, kernel.hip): print(f" {line_no:3d}. {hip_line}")
# Access specific kernel by namekernel = trace["vector_add(float*, float*, float*, int)"]print(kernel.assembly) # Array of assembly stringsprint(kernel.hip) # Array of HIP source linesprint(kernel.signature) # Kernel signatureprint(kernel.files) # Source filesprint(kernel.lines) # Line numbers
# Save and load tracestrace.save("my_trace.json")old_trace = Nexus.load("my_trace.json")Command line
Environment variables
| Variable | Description |
|---|---|
NEXUS_LOG_LEVEL | Verbosity level (0 = none, 1 = info, 2 = warning, 3 = error, 4 = detail) |
NEXUS_OUTPUT_FILE | Path to the JSON output file |
NEXUS_EXTRA_SEARCH_PREFIX | Additional search directories for HIP files. Supports wildcards, colon-separated. |
TRITON_DISABLE_LINE_INFO | Set to 0 to enable line info in Triton kernels (auto-set by Python API) |
Example
export HSA_TOOLS_LIB=build/lib/libnexus.soexport NEXUS_LOG_LEVEL=3export NEXUS_OUTPUT_FILE=result.json
hipcc vector_add.hip -g -o vector_add # -g needed for source line mapping./vector_addWithout -g you still get assembly and HIP source in the trace; only the mapping to original source line numbers may be missing.
Output format
Nexus produces a JSON file with kernel data:
{ "kernels": { "vector_add(float const*, float const*, float*, int)": { "assembly": [ "global_load_dword v6, v[4:5], off", "global_load_dword v7, v[2:3], off", "global_store_dword v[0:1], v2, off" ], "hip": [ " c[idx] = a[idx] + b[idx];", " c[idx] = a[idx] + b[idx];", " c[idx] = a[idx] + b[idx];" ], "files": ["vector_add.hip", ...], "lines": [11, 11, 11], "signature": "vector_add(float const*, float const*, float*, int)" } }}Each kernel entry contains:
- assembly — ISA instructions extracted from the code object
- hip — corresponding HIP source lines (when available)
- files — source file paths for each instruction
- lines — source line numbers for each instruction
- signature — the full kernel signature