Skip to content

Commit 482ed81

Browse files
authored
Merge pull request #42 from ROCm/rogarcia.llamacpp-roofline-for-vlm
mtmd-cli: reset roofline profiler after warmup prefill
2 parents f366597 + b9a5d2a commit 482ed81

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

tools/mtmd/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ if (LLAMA_BUILD_TOOLS)
134134
target_link_libraries (${TARGET} PRIVATE llama-common mtmd Threads::Threads)
135135
target_compile_features(${TARGET} PRIVATE cxx_std_17)
136136

137+
# Compile in the post-warmup roofline reset only when the HIP profiler is built
138+
# (ggml-cuda-roofline.cpp, linked via ggml-hip). No-op in every other build.
139+
if (GGML_HIP_ROOFLINE)
140+
target_compile_definitions(${TARGET} PRIVATE GGML_HIP_ROOFLINE)
141+
target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../ggml/src/ggml-cuda)
142+
endif()
143+
137144
# mtmd-debug tool
138145
add_executable(llama-mtmd-debug debug/mtmd-debug.cpp)
139146
set_target_properties(llama-mtmd-debug PROPERTIES OUTPUT_NAME llama-mtmd-debug)

tools/mtmd/mtmd-cli.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
#include "mtmd.h"
1111
#include "mtmd-helper.h"
1212

13+
// Optional per-op roofline profiler (HIP build with GGML_HIP_ROOFLINE). Used to
14+
// discard warmup so the report covers only the measured prefill. Compiled out
15+
// otherwise. See ggml/src/ggml-cuda/ggml-cuda-roofline.cpp.
16+
#ifdef GGML_HIP_ROOFLINE
17+
#include "ggml-cuda-roofline.h"
18+
#endif
19+
1320
#include <vector>
1421
#include <limits.h>
1522
#include <cinttypes>
@@ -453,6 +460,11 @@ int main(int argc, char ** argv) {
453460
return 1; // error is already printed by libmtmd
454461
}
455462
}
463+
// Discard warmup from the per-op roofline profiler so the report covers
464+
// only the measured prefill below. Compiled out unless GGML_HIP_ROOFLINE.
465+
#ifdef GGML_HIP_ROOFLINE
466+
ggml_cuda_roofline_reset();
467+
#endif
456468
if (eval_message(ctx, msg)) {
457469
return 1;
458470
}

0 commit comments

Comments
 (0)