Simple examples demonstrating how to use Nexus to trace GPU kernels.
Traces a simple HIP vector addition kernel.
Run:
python3 examples/simple_hip.pyWhat it does:
- Creates a simple HIP add kernel in a temp file
- Compiles and runs it with Nexus tracing
- Shows captured assembly and HIP source
Traces a Triton kernel.
Run:
python3 examples/simple_triton.pyWhat it does:
- Creates a Triton add kernel in a temp file
- Runs it with Nexus tracing
- Shows captured assembly and source
Traces multiple HIP kernels in a single execution.
Run:
python3 examples/multiple_hip.pyWhat it does:
- Creates two HIP kernels (add and multiply)
- Compiles and runs them with Nexus tracing
- Shows assembly and source for both kernels
Traces multiple Triton kernels in a single execution.
Run:
python3 examples/multiple_triton.pyWhat it does:
- Creates two Triton kernels (add and multiply)
- Runs both with Nexus tracing
- Shows assembly and source for both kernels
Both examples follow the same simple pattern:
from nexus import Nexus
# Create tracer
nexus = Nexus(log_level=1)
# Run and get trace
trace = nexus.run(["python", "my_script.py"])
# Analyze kernels
for kernel in trace:
print(f"{kernel.name}: {len(kernel.assembly)} instructions")
print(kernel.hip)- ROCm installed
- For HIP example:
hipccin PATH - For Triton example:
tritoninstalled (pip install triton) - Nexus installed:
pip install git+https://github.com/AMDResearch/nexus.git