Extract GPU Kernel Assembly & HIP Source

VerifiedCaution

Intercept HSA packets to extract kernel assembly and HIP source mapping. Debug GPU dispatch and code generation.

Sby Skills Guide Bot
DevelopmentAdvanced
7/30/2026
Claude CodeCursor
#gpu-kernels#rocm#hip#assembly#tracing

Recommended for

Automated summary

Intercepts HSA packets from an AMD ROCm process and extracts, per kernel, GPU assembly and HIP source with line mappings into a structured (JSON) trace.

Strengths

  • Per-kernel assembly and HIP source extraction through a simple Python API (`nexus.run`) or a drop-in `HSA_TOOLS_LIB` variable for processes that cannot be launched directly.
  • Exposes signature, files and line numbers, so each assembly instruction can be correlated back to the HIP source line it came from.
  • Traces serialize to JSON (`trace.save` / `Nexus.load`) and can be looked up by kernel name.
  • An MCP server path (`list_kernels`, `extract_kernel_code`) lets an agent drive the analysis conversationally.

Limitations

  • Requires an AMD ROCm/HSA stack plus the Nexus library; it does nothing on NVIDIA/CUDA or CPU-only targets.
  • It is a research/analysis tool: the output is a trace to inspect, not a profiler with timings or performance metrics.
  • Triton kernels need `TRITON_DISABLE_LINE_INFO=0` for line info, and source lookup may require `NEXUS_EXTRA_SEARCH_PREFIX`.
When to use it

Use it when you need to know exactly which GPU kernels ran in a HIP/ROCm workload and inspect their assembly or map it back to HIP source lines.

When not to use it

Avoid it on CUDA/NVIDIA systems, for timing or roofline performance analysis, or when a high-level run summary is all you need.

Security analysis

Caution
Quality score80/100

No destructive, obfuscated, or exfiltrating behavior: there is no curl|sh, no rm -rf, no credential/token transmission, no base64 payloads, and no attempt to disable safety controls. The skill does use powerful mechanisms—subprocess execution via nexus.run and HSA_TOOLS_LIB library injection into a GPU process—but only for the stated legitimate purpose of capturing kernel assembly/source traces locally. This warrants 'caution' (powerful tools used legitimately) rather than 'risky'.

Findings
  • •Instructs setting HSA_TOOLS_LIB to inject a shared library into an arbitrary process (runtime interposition/hooking), a powerful capability that is legitimate here but should be scoped to the user's own workloads
  • •nexus.run([...]) launches arbitrary commands (scripts/binaries) from within the skill; agent could be induced to run unintended programs
  • •Writes trace output files (trace.json / NEXUS_OUTPUT_FILE) whose paths are user-controlled; no restriction to a sandbox directory beyond 'use relative paths'
  • •References an internal path (nexus/nexus/mcp/server.py) for tool schemas, which may not exist in the user's environment
How this analysis is made

Examples

Extract kernels from a HIP app
Run ./my_hip_app under Nexus and dump every kernel's name, instruction count and HIP source into trace.json.
Map assembly back to source
In the trace I already saved as trace.json, show me the assembly for the kernel 'vector_add(float const*, float const*, float*, int)' and which HIP lines it maps to.
Trace without wrapping the launch
I can't wrap this Python script with nexus.run — give me the HSA_TOOLS_LIB and NEXUS_OUTPUT_FILE environment variables so it gets traced when I run it normally.

name: nexus-trace description: Extract GPU kernel assembly and HIP source from HSA packet traces. Use when analyzing what code ran on the GPU, debugging kernel dispatch, or inspecting assembly and source mapping.

Nexus: HSA Packet Source Code Extractor

Intercepts HSA packets from a running process and extracts, per kernel, assembly and HIP source into a structured trace (e.g. JSON). Use for kernel-level inspection and assembly/source correlation.

When to Use

  • User needs to see which kernels ran and their assembly or HIP source
  • Debugging or analyzing GPU dispatch and code generation
  • Inspecting assembly-to-source mapping for a HIP (or ROCm) application

Instructions

  1. Ensure the target runs on AMD ROCm and uses HSA (e.g. HIP application or ROCm runtime).
  2. Choose execution path:
    • If a Nexus MCP server is available, use its tools: list_kernels to enumerate kernels in a trace, and extract_kernel_code to get assembly and HIP/source mapping (signature, files, lines). See nexus/nexus/mcp/server.py for tool parameters and schemas.
    • Otherwise use the Python API from the environment where Nexus is installed.

Python API (recommended when no MCP)

from nexus import Nexus

nexus = Nexus(log_level=1)
trace = nexus.run(["python", "my_gpu_script.py"])

# Or run a binary:
# trace = nexus.run(["./my_hip_app"])

for kernel in trace:
    print(kernel.name, len(kernel.assembly), "instructions")
    for i, asm_line in enumerate(kernel.assembly, 1):
        print(f"  {i}. {asm_line}")
    for line_no, hip_line in zip(kernel.lines or range(1, len(kernel.hip)+1), kernel.hip):
        print(f"  {line_no}: {hip_line}")

# Access by kernel name
k = trace["vector_add(float const*, float const*, float*, int)"]
print(k.assembly, k.hip, k.signature, k.files, k.lines)

# Save/load trace
trace.save("trace.json")
loaded = Nexus.load("trace.json")

Set log_level (0–4) to control verbosity. Use relative paths for the run command and output file so the skill is portable.

Environment-based usage (no Python API)

When the process cannot be launched via nexus.run():

  1. Set HSA_TOOLS_LIB to the Nexus shared library path (e.g. build/lib/libnexus.so or the installed path).
  2. Set NEXUS_OUTPUT_FILE to the output JSON path.
  3. Set NEXUS_LOG_LEVEL (0–4) if needed.
  4. Run the application as usual; it will be traced and the output file will contain the kernel data.

Optional: NEXUS_EXTRA_SEARCH_PREFIX (colon-separated) for HIP source search; TRITON_DISABLE_LINE_INFO=0 for Triton kernel line info.

Workflow

  1. Identify the command that runs the GPU workload (e.g. python script.py or ./app).
  2. If using the Python API: create Nexus(log_level=...), call nexus.run([...]), then iterate trace and optionally trace.save(...).
  3. If using the env method: set HSA_TOOLS_LIB and NEXUS_OUTPUT_FILE, then run the app; open the JSON and parse the kernels structure.
  4. Use kernel signature, assembly, hip, files, and lines to analyze what ran and map assembly back to source.
  5. Use relative paths for commands and output files.

Notes

  • Nexus is intended for research/analysis; ensure the target environment has the Nexus library and compatible ROCm/HSA stack.
  • For Triton kernels, enable line info via TRITON_DISABLE_LINE_INFO=0 when using the Python API.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/extract-gpu-kernel-assembly-hip-source-ms71b3gm/download' --output '.skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm/SKILL.md.part' && mv '.skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm/SKILL.md.part' '.skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm/SKILL.md' && test -s '.skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/nexus-trace' && cp -R '.skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm' '.claude/skills/nexus-trace'

Cursor
test -f '.skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm/SKILL.md' && test -s '.skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/nexus-trace' && cp -R '.skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm' '.cursor/skills/nexus-trace'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm'

openskills read 'extract-gpu-kernel-assembly-hip-source-ms71b3gm'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/extract-gpu-kernel-assembly-hip-source-ms71b3gm/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills