Skip to content

models : move build_arch_graph() after graph() template specialization - #28934

Merged
ggerganov merged 1 commit into
ggml-org:masterfrom
cpeterso:cpeterso_cxx23
Sep 15, 2026
Merged

ggerganov merged 1 commit into
ggml-org:masterfrom
cpeterso:cpeterso_cxx23

Conversation

@cpeterso

Copy link
Copy Markdown
Contributor

Overview

Move build_arch_graph()'s function definitions after the graph<true> and graph<false> template specializations have been explicitly defined.

Additional information

I get the following build errors when compiling llama.cpp as C++23 in my application. C++23 makes std::unique_ptr constexpr, which causes clang to eagerly instantiate std::unique_ptr's body when the explicit specialization of the graph template hasn't been defined yet. This std::unique_ptr change came from C++23 proposal P2273R3:

https://open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2273r3.pdf

In dflash.cpp, eagle3.cpp, and t5.cpp, build_arch_graph() calls std::make_unique, which implicitly instantiates the specializations of the nested graph templates before the explicit specializations are defined. To fix the errors, move build_arch_graph() to the end of each file, after all explicit specializations.

llama.cpp/src/models/dflash.cpp:276:34: error: explicit specialization of 'graph' after
      instantiation
  276 | llama_model_dflash::graph<true>::graph(const llama_model & model, const llm_graph_params & params) : llm_graph_context(params) {
      |                                  ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:759:30: note: 
      implicit instantiation first required here
  759 |   return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...));
      |                              ^
llama.cpp/src/models/eagle3.cpp:137:34: error: explicit specialization of 'graph' after
      instantiation
  137 | llama_model_eagle3::graph<true>::graph(const llama_model & model, const llm_graph_params & params) : llm_graph_context(params) {
      |                                  ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:759:30: note: 
      implicit instantiation first required here
  759 |   return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...));
      |                              ^
llama.cpp/src/models/t5.cpp:122:31: error: explicit specialization of 'graph' after
      instantiation
  122 | llama_model_t5::graph<false>::graph(const llama_model & model, const llm_graph_params & params) : llm_graph_context(params) {
      |                               ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/unique_ptr.h:759:30: note: 
      implicit instantiation first required here
  759 |   return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...));
      |                              ^

Requirements

  • I have read and agree with the contributing guidelines: YES
  • AI usage disclosure: YES. I used Codex to decipher the C++ error and learn why it wasn't a problem until C++23. I wrote the commit message and this PR myself.

Move build_arch_graph()'s function definitions after the graph<true>
and graph<false> template specializations have been explicitly defined.
@cpeterso
cpeterso requested a review from CISC as a code owner September 15, 2026 06:42
@github-actions github-actions Bot added the model Model specific label Sep 15, 2026
@CISC CISC added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Sep 15, 2026
@ggerganov
ggerganov merged commit 9e71716 into ggml-org:master Sep 15, 2026
23 of 28 checks passed
@cpeterso
cpeterso deleted the cpeterso_cxx23 branch September 15, 2026 16:34
dzannotti added a commit to halo-box/llama.cpp that referenced this pull request Sep 15, 2026
* upstream/master: (72 commits)
  HIP: Enable AllReduce for ROCm (ggml-org#27825)
  opencl: choose the MoE expert matmul by batch size for speculative decoding/MTP (ggml-org#27637)
  ci: build MUSA for only 1 arch (ggml-org#28944)
  docs: Rule of thumb for AI review time [no ci] (ggml-org#28945)
  rpc : hash-cache only weights (ggml-org#28789)
  cuda: support row-contiguous SUM_ROWS (ggml-org#26308)
  models : move build_arch_graph() after graph() template specialization (ggml-org#28934)
  vulkan: support sparse Flash Attention (ggml-org#28105)
  OpenVINO: optimize stateful decode and GPU MoE inference (ggml-org#28638)
  opencl: add generic ssm_scan (ggml-org#28881)
  ci: bump kleidiai runners from 22.04 to 24.04 (ggml-org#28885)
  metal : add FA kernels for HSK=96, HSV=64 (MiniCPM3) (ggml-org#28599)
  ci: Bump CUDA Windows x64 builds to 13.4.1 (ggml-org#28930)
  ci : fix android release (ggml-org#28936)
  cuda : enable i16 and i32 for DUP (ggml-org#28897)
  cmake : use PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR (ggml-org#28771)
  webui: stop re-probing disabled /tools endpoint on every message (ggml-org#28646)
  ci : reuse build tag name when used instead of safe one (ggml-org#28911)
  CI: hip-quality-check: ignore spill added in bfdc321 (ggml-org#28909)
  HIP: fattn-mma: use fp32 accumulation on MFMA devices (ggml-org#28576)
  ...
quimmedes pushed a commit to quimmedes/cafe-llama.cpp that referenced this pull request Sep 16, 2026
ggml-org#28934)

Move build_arch_graph()'s function definitions after the graph<true>
and graph<false> template specializations have been explicitly defined.
zsogitbe pushed a commit to zsogitbe/llama.cpp that referenced this pull request Sep 17, 2026
ggml-org#28934)

Move build_arch_graph()'s function definitions after the graph<true>
and graph<false> template specializations have been explicitly defined.
Te-eMster pushed a commit to Te-eMster/mx-llama.cpp that referenced this pull request Sep 18, 2026
ggml-org#28934)

Move build_arch_graph()'s function definitions after the graph<true>
and graph<false> template specializations have been explicitly defined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. model Model specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants