Skip to content

[llamacpp] Fix CMake config and EnVar setup - #2573

Merged
mhalk merged 11 commits into
ROCm:aomp-devfrom
mhalk:amd/dev/mhalkenh/fix/ci-llamacpp-run-exports-and-cmake
Sep 24, 2026
Merged

mhalk merged 11 commits into
ROCm:aomp-devfrom
mhalk:amd/dev/mhalkenh/fix/ci-llamacpp-run-exports-and-cmake

Conversation

@mhalk

@mhalk mhalk commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Observed fails in the CI, missing CTest instances and missing performance results.

Technical Details

Expanded common function toolbox by:

  • merge_variable_with_inputs
  • get_cmake_module_path
  • add_cmake_rocm_header_priority_args
  • check_cmake_rocm_header_priority

These are being used to handle:

  • A) PATH and LD_LIBRARY_PATH expansions, needed to run llamacpp
  • B) CMake config fix: pulling in the necessary prefix paths (e.g. hipblas module)
  • C) CMake config fix: Achieve precedence over -isystem pulled in by system ROCm
    • Using e.g. CMAKE_HIP_COMPILER_ARG1

A could cause wrong libraries being discovered first. (warning)
B could cause missing CMake configuration file. (error)
C could cause system header taking precedence over targeted / tested compiler toolchain. (error)

Also expanded CTest timeout to accommodate test-backend-ops instance.

Test Plan

Run llamacpp via CI scripts.

Test Result

Full, expected suite of CTests shows up in addition to performance results.

Submission Checklist

@mhalk
mhalk requested review from Kewen12, Lynd98 and jplehr September 22, 2026 16:47
@mhalk
mhalk force-pushed the amd/dev/mhalkenh/fix/ci-llamacpp-run-exports-and-cmake branch 2 times, most recently from a99f5f8 to f3383cf Compare September 22, 2026 17:04
@jplehr

jplehr commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

I think we should split out the change to make aomp_common_vars shellcheck compliant.

Record once that the file defines variables for the scripts that source it,
so their uses are invisible to static analysis, and quote the two expansions
flagged for word splitting. Neither has an effect.

Quoting the array element in shquot also stops an argument holding a tab or
a newline from being split into several quoted words. That output is meant
to be pasted back into a shell, where the split silently alters the command.

AI-assisted.
@mhalk

mhalk commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator Author

I think we should split out the change to make aomp_common_vars shellcheck compliant.

Sounds reasonable, see: #2578
Once that lands I'll rebase and force-push.

edit: TBH I'm interested to see how clever GH is and have rebased onto that new PRs commit.

Merge a delimited variable with a list of inputs, skipping empty ones and
avoiding dangling delimiters. Prepends by default so new inputs take priority.

AI-assisted.
Fix directory determination used during the aomp_common_vars sourcing.
Derive ROCM_PATH from AOMP.
Export PATH and LD_LIBRARY_PATH such that AOMP and ROCM_PATH take precedence.
Refactor CMake configuration to allow easy printing and add corresponding print.
Log the CMake configure step.

AI-assisted.
Search a list of prefixes for lib/cmake/<Module> and return the cmake
directory holding it. Defaults to AOMP, then ROCM_PATH, then /opt/rocm, so a
package missing from the ROCm under test resolves to the system ROCm.

AI-assisted.
ggml needs hip, hipblas and rocblas. Look each of them up separately so the
ROCm under test is preferred and another installation is only added to
CMAKE_PREFIX_PATH for what it does not ship itself, with a warning naming it.

AI-assisted.
A ROCm package borrowed from another installation exports its whole include
directory, HIP headers included, which CMake emits as -isystem. Since clang
searches its own ROCm last, those headers win over the ROCm under test.

Emit the include directory of the ROCm under test through
CMAKE_<LANG>_COMPILER_ARG1, the only slot ahead of the includes CMake
generates; every *_FLAGS variable lands behind them.

AI-assisted.
Without this the HIP headers of whichever ROCm provides hipblas and rocblas
are used, which fails to compile whenever they predate the compiler under
test.

AI-assisted.
Confirm the include directory survived into the CMake cache. A lost entry
only breaks the build while the two ROCm header sets are incompatible;
otherwise it silently builds against the wrong ones.

AI-assisted.
test-backend-ops alone runs for about 2500s on MI350X and is killed by the
1500s ctest applies by default, which reports as a test failure rather than
as an unfinished test.

AI-assisted.
@mhalk
mhalk force-pushed the amd/dev/mhalkenh/fix/ci-llamacpp-run-exports-and-cmake branch from f3383cf to 4b6743a Compare September 23, 2026 13:55
Comment thread bin/aomp_common_vars
Comment thread bin/aomp_common_vars
Comment thread bin/aomp_common_vars
# CMAKE_<LANG>_COMPILER_ARG1 is the only slot in front of those includes; every
# *_FLAGS variable lands behind them. Keep CMAKE_<LANG>_COMPILER a plain path,
# CMake reassigns ARG1 when the compiler itself carries arguments.
function add_cmake_rocm_header_priority_args() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using a compiler-only "AOMP", e.g. hipblas will be discovered within the system's ROCm installation which adds an particular include path: -isystem /path/to/rocm/include.
Primarily some incompatible ggml header files provided by the llama repo itself are picked up.
This has the effect that these potentially incompatible headers take precedence over our desired header files / the header files provided by our tested compiler toolchain.

Hence, this _ARG1 is the "hammer" which brings our include directory in front and lets our compiler's header files take precedence.
This avoids e.g. error: use of undeclared identifier '__ocml_log2_f32'.

If you happen to know a better approach, please let me know.

Also I am slightly unsure what's going on exactly.
AFAICT -isystem seems intended as third-party header include, so one would lean towards using -I.
But switching this added include from -isystem to -I fails with the same errors.

@mhalk
mhalk merged commit 22e67f4 into ROCm:aomp-dev Sep 24, 2026
1 check passed
@mhalk
mhalk deleted the amd/dev/mhalkenh/fix/ci-llamacpp-run-exports-and-cmake branch September 24, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants