with one click
tracy
Set up and use Tracy profiler for MLX Vulkan backend profiling
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Set up and use Tracy profiler for MLX Vulkan backend profiling
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Run and compare MLX Vulkan inference benchmarks. Use when asked to benchmark this repository, measure a change, run bf16 or 8-bit MLX performance tests, or compare current results with the README baseline.
Review the MLX Vulkan backend for one major async-pipeline or inference-performance issue, obtain user approval, implement the scoped fix, then run full MLX validation, benchmarks, and model generation reporting. Use when the user wants an end-to-end Vulkan improvement workflow with an explicit review-before-fix approval boundary.
Commit changes solely within the MLX submodule in this Vulkan repository. Use when asked to inspect, stage, and commit work in `mlx/` without modifying or committing the `mlx-vulkan` parent repository.
Commit MLX submodule changes, run required Vulkan benchmarks, push a branch, and open a PR against `goniz/mlx`. Use when asked to create a pull request for MLX Vulkan work, especially when an issue number must be closed and bf16 plus 8-bit benchmark results are required.
Build MLX, reproduce one failing C++ test, and implement the smallest Vulkan-only fix. Use when asked to repair a C++ test failure in this repository while preserving test code and avoiding unrelated fixes.
Build MLX, reproduce one failing Python test, and implement the smallest Vulkan-only fix. Use when asked to repair a Python test failure in this repository while preserving test code and avoiding unrelated fixes.
| name | tracy |
| description | Set up and use Tracy profiler for MLX Vulkan backend profiling |
Use this skill when you need to add, enable, or analyze Tracy profiling in a native C++ project, especially an MLX backend or Vulkan-heavy codebase. The goal is to get from âno profilingâ to actionable traces with minimal nonsense and minimal hot-path damage.
This skill is grounded in the Tracy user manual quick-start and feature documentation. Tracy integration requires adding TracyClient.cpp, including tracy/Tracy.hpp, defining TRACY_ENABLE project-wide, and instrumenting code with macros such as ZoneScoped and FrameMark. Tracy also supports GPU profiling, memory profiling, plots, message logs, and call stacks. îfileciteîturn1file0î
Use this skill when the user asks to:
Do not use this skill when:
TracyClient.cpp, include tracy/Tracy.hpp, define TRACY_ENABLE, place ZoneScoped in functions of interest, and place FrameMark at frame boundaries. îfileciteîturn1file0îprofiler directory with CMake. îfileciteîturn1file7îTracyPlot, messages via TracyMessage, memory events via TracyAlloc / TracyFree, and GPU profiling including Vulkan. îfileciteîturn1file5îPreferred options:
third_party/tracyFetchContentMinimal source integration:
TracyClient.cpptracy/publictracy/Tracy.hpp where instrumentation is usedTRACY_ENABLE for the whole target or build configuration intended for profiling îfileciteîturn1file0îFor CMake-based native projects, do one of these:
option(TRACY_ENABLE "Enable Tracy profiler" ON)
add_subdirectory(third_party/tracy)
target_link_libraries(my_target PRIVATE Tracy::TracyClient)
target_compile_definitions(my_target PRIVATE TRACY_ENABLE)
include(FetchContent)
option(TRACY_ENABLE "Enable Tracy profiler" ON)
FetchContent_Declare(
tracy
GIT_REPOSITORY https://github.com/wolfpld/tracy.git
GIT_TAG master
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(tracy)
target_link_libraries(my_target PRIVATE Tracy::TracyClient)
target_compile_definitions(my_target PRIVATE TRACY_ENABLE)
Start embarrassingly small:
#include <tracy/Tracy.hpp>
void run_graph(Graph& g) {
ZoneScoped;
// work
}
For thread entry points:
void worker_thread_main() {
tracy::SetThreadName("mlx-vk-worker");
ZoneScoped;
// loop
}
For frame-like iterations or benchmark iterations:
void render_or_step() {
ZoneScoped;
// work
FrameMark;
}
ZoneScoped records scope timing plus source location metadata, while FrameMark establishes frame boundaries for the frame profiler. îfileciteîturn1file0î îfileciteîturn1file9î
Use these when the trace starts looking like spaghetti thrown into a server rack:
ZoneScopedN("encode_command_buffer");
ZoneText(cmd_name.c_str(), cmd_name.size());
ZoneValue(batch_size);
Useful macros include:
ZoneScopedN(name) for stable custom labelsZoneText(text, size) for dynamic contextZoneValue(uint64_t) for numeric contextZoneScopedC(color) / ZoneColor(color) for visual grouping îfileciteîturn1file9îFor queue depth, bytes uploaded, command buffers submitted, descriptor set pressure, split-k count, and similar bread-and-butter signals:
TracyPlot("vk.pending_submissions", pending_submissions);
TracyPlot("vk.bytes_uploaded", static_cast<int64_t>(bytes_uploaded));
TracyMessageL("transfer queue stalled");
You can configure plot presentation with TracyPlotConfig(name, format, step, fill, color). Tracy supports number, memory, and percentage plot formats. îfileciteîturn1file5î
Wrap custom allocators or strategic allocation sites:
void* p = allocate(sz);
TracyAlloc(p, sz);
TracyFree(p);
free(p);
This enables memory graphs, leak visibility, active-allocation rewind, and memory hot-spot analysis. îfileciteîturn1file5î
Tracy supports Vulkan GPU profiling. Use it for command-buffer spans, dispatch batches, copy/upload passes, and queue submission analysis. The exact Vulkan API wrappers/macros are documented in the Tracy manualâs GPU profiling section. îfileciteîturn1file1î
Recommended pattern for an MLX Vulkan backend:
Suggested first-pass zone map for MLX Vulkan:
compile_pipelineallocate_descriptor_setsrecord_compute_dispatchrecord_buffer_uploadqueue_submit_computequeue_submit_transferwait_for_fencesync_buffersgraph_executekernel::<op_name>The manual states the profiler/analyzer is built separately with CMake, for example:
cmake -B profiler/build -S profiler -DCMAKE_BUILD_TYPE=Release
cmake --build profiler/build --config Release --parallel
The analyzer can connect to localhost or remote clients. Tracy recommends using matching client/server versions because protocol changes between releases can break connections. îfileciteîturn1file7î
Basic loop:
Tracy can also be used in interactive or command-line capture flows, and the manual has dedicated sections for capture and later analysis. îfileciteîturn1file1î
TRACY_ENABLE is defined and the analyzer version matches the client version. îfileciteîturn1file7î#include <tracy/Tracy.hpp> is present and ZoneScoped is actually executed. îfileciteîturn1file0îTracyClient.cpp is compiled exactly once in the target graph. The manual covers initial setup and CMake integration. îfileciteîturn1file0îFrameMark for logical iterations such as benchmark steps or inference requests. îfileciteîturn1file0îWhen using this skill, produce:
Use this structure when helping the user:
Primary source: Tracy Profiler user manual, including quick-start, build, instrumentation, plots, memory profiling, and GPU profiling sections. îfileciteîturn1file0î