Added perfetto support (CPU + Vulkan) backends #15848
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This uses perfetto in process profiling, and will produce a perfetto binary by the end of the inference. This is very useful to help visualise how the handles the inference.
Build:
cmake -S . -B build-vk -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGGML_VULKAN=ON cmake --build build-vk -j8
Run:
GGML_VK_PERF_SILENT=1 GGML_VK_PERF_LOGGER=1 LLAMA_PERFETTO_TRACE=./out.pftrace build-vk/bin/llama-cli -m model.gguf
Test:
Tested on M4 Mac
In detail this patch does the following:
LlamaPerfetto.hheader file, which contains the definitions for the Perfetto-related functions and variables used in this example.llama_perfetto_start()function to start tracing at the beginning of the conversation.llama_perfetto_stop_flush()function to stop tracing and flush the trace after each generation.llama_perfetto_trace_begin_with_text()function to begin an event in Perfetto with a text description of the current evaluation.llama_perfetto_trace_end()function to end the event after each evaluation.llama_perfetto_counter_tokens_per_s()function to update the Perfetto counter for tokens per second during idle periods.llama_perfetto_emit_gpu_timeline()function to emit GPU timeline slices into Perfetto.llama_perfetto_print_gpu_stats()function to print GPU statistics at idle periods.llama_perfetto_flush_dump_stats()function to flush and dump the Perfetto trace stats to a file at idle periods.Make sure to read the contributing guidelines before submitting a PR