Skip to content

Commit 4b54d2c

Browse files
committed
Remove llama.cpp server fork and build upstream
This change removes the custom server fork at llamacpp/native/src/server and instead builds the upstream llama.cpp server directly. The CMake build is updated to copy the upstream llama-server binary to the expected com.docker.llama-server name. The README is updated to reflect that no custom patches are applied. Signed-off-by: Eric Curtin <eric.curtin@docker.com>
1 parent e93a023 commit 4b54d2c

24 files changed

+189
-10832
lines changed

cmd/cli/commands/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func appendRow(table *tablewriter.Table, tag string, model dmrm.Model) {
261261
contextSize := ""
262262
if model.Config.GetContextSize() != nil {
263263
contextSize = fmt.Sprintf("%d", *model.Config.GetContextSize())
264-
} else if dockerConfig, ok := model.Config.(*types.Config); ok && dockerConfig.GGUF != nil {
264+
} else if dockerConfig, ok := model.Config.ModelConfig.(*types.Config); ok && dockerConfig.GGUF != nil {
265265
if v, ok := dockerConfig.GGUF["llama.context_length"]; ok {
266266
if parsed, err := strconv.ParseUint(v, 10, 64); err == nil {
267267
contextSize = fmt.Sprintf("%d", parsed)

cmd/cli/commands/list_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ func testModel(id string, tags []string, created int64) dmrm.Model {
1515
ID: id,
1616
Tags: tags,
1717
Created: created,
18-
Config: &types.Config{
18+
Config: &dmrm.ModelConfigWrapper{ModelConfig: &types.Config{
1919
Parameters: "7B",
2020
Quantization: "Q4_0",
2121
Architecture: "llama",
2222
Size: "4.0GB",
23-
},
23+
}},
2424
}
2525
}
2626

@@ -177,12 +177,12 @@ func TestListModelsSingleModel(t *testing.T) {
177177
ID: "sha256:123456789012345678901234567890123456789012345678901234567890abcd",
178178
Tags: []string{"single:latest"},
179179
Created: 1000,
180-
Config: &types.Config{
180+
Config: &dmrm.ModelConfigWrapper{ModelConfig: &types.Config{
181181
Parameters: "7B",
182182
Quantization: "Q4_0",
183183
Architecture: "llama",
184184
Size: "4.0GB",
185-
},
185+
}},
186186
},
187187
}
188188
output := prettyPrintModels(models)
@@ -234,23 +234,23 @@ func TestPrettyPrintModelsWithSortedInput(t *testing.T) {
234234
ID: "sha256:123456789012345678901234567890123456789012345678901234567890abcd",
235235
Tags: []string{"ai/apple:latest"},
236236
Created: 1000,
237-
Config: &types.Config{
237+
Config: &dmrm.ModelConfigWrapper{ModelConfig: &types.Config{
238238
Parameters: "7B",
239239
Quantization: "Q4_0",
240240
Architecture: "llama",
241241
Size: "4.0GB",
242-
},
242+
}},
243243
},
244244
{
245245
ID: "sha256:223456789012345678901234567890123456789012345678901234567890abcd",
246246
Tags: []string{"ai/banana:v1"},
247247
Created: 2000,
248-
Config: &types.Config{
248+
Config: &dmrm.ModelConfigWrapper{ModelConfig: &types.Config{
249249
Parameters: "13B",
250250
Quantization: "Q4_K_M",
251251
Architecture: "llama",
252252
Size: "8.0GB",
253-
},
253+
}},
254254
},
255255
}
256256

@@ -282,12 +282,12 @@ func TestPrettyPrintModelsWithMultipleTags(t *testing.T) {
282282
ID: "sha256:123456789012345678901234567890123456789012345678901234567890abcd",
283283
Tags: []string{"qwen3:8B-Q4_K_M", "qwen3:latest", "qwen3:0.6B-F16"},
284284
Created: 1000,
285-
Config: &types.Config{
285+
Config: &dmrm.ModelConfigWrapper{ModelConfig: &types.Config{
286286
Parameters: "8B",
287287
Quantization: "Q4_K_M",
288288
Architecture: "qwen3",
289289
Size: "4.68GB",
290-
},
290+
}},
291291
},
292292
}
293293

llamacpp/native/CMakeLists.txt

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,43 @@ project(
88

99
option(DDLLAMA_BUILD_SERVER "Build the DD llama.cpp server executable" ON)
1010
option(DDLLAMA_BUILD_UTILS "Build utilities, e.g. nv-gpu-info" OFF)
11-
set(DDLLAMA_PATCH_COMMAND "patch" CACHE STRING "patch command")
1211

1312
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
1413
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
1514

1615
if (DDLLAMA_BUILD_SERVER)
17-
set(LLAMA_BUILD_COMMON ON)
16+
# Build upstream llama.cpp with server enabled
17+
# Only set these options if they're not already defined to allow consumers to override
18+
if(NOT DEFINED LLAMA_BUILD_COMMON)
19+
set(LLAMA_BUILD_COMMON ON CACHE BOOL "Build common utils library")
20+
endif()
21+
if(NOT DEFINED LLAMA_BUILD_TOOLS)
22+
set(LLAMA_BUILD_TOOLS ON CACHE BOOL "Build tools")
23+
endif()
24+
if(NOT DEFINED LLAMA_BUILD_SERVER)
25+
set(LLAMA_BUILD_SERVER ON CACHE BOOL "Build server")
26+
endif()
1827
add_subdirectory(vendor/llama.cpp)
19-
# Get build info and set version for mtmd just like it's done in llama.cpp/CMakeLists.txt
20-
include(vendor/llama.cpp/cmake/build-info.cmake)
21-
if (NOT DEFINED LLAMA_BUILD_NUMBER)
22-
set(LLAMA_BUILD_NUMBER ${BUILD_NUMBER})
28+
29+
# Create custom target to copy llama-server to com.docker.llama-server
30+
if (WIN32)
31+
set(LLAMA_SERVER_DST "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/com.docker.llama-server.exe")
32+
else()
33+
set(LLAMA_SERVER_DST "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/com.docker.llama-server")
2334
endif()
24-
set(LLAMA_INSTALL_VERSION 0.0.${LLAMA_BUILD_NUMBER})
25-
add_subdirectory(vendor/llama.cpp/tools/mtmd)
26-
add_subdirectory(src/server)
35+
36+
add_custom_command(OUTPUT "${LLAMA_SERVER_DST}"
37+
COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:llama-server>" "${LLAMA_SERVER_DST}"
38+
DEPENDS llama-server
39+
COMMENT "Creating com.docker.llama-server from llama-server"
40+
)
41+
42+
add_custom_target(com.docker.llama-server ALL DEPENDS "${LLAMA_SERVER_DST}")
43+
44+
# Install the renamed binary using TARGETS instead of PROGRAMS for better cross-platform support
45+
install(TARGETS llama-server
46+
RUNTIME DESTINATION bin
47+
RENAME "com.docker.llama-server${CMAKE_EXECUTABLE_SUFFIX}")
2748
endif()
2849

2950
if (WIN32 AND DDLLAMA_BUILD_UTILS)

llamacpp/native/README.md

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Native llama-server
22

3+
This project builds the upstream llama.cpp server (`llama-server`) directly from the llama.cpp submodule and renames it to `com.docker.llama-server`.
4+
35
## Building
46

57
cmake -B build
@@ -15,7 +17,7 @@
1517

1618
This project uses llama.cpp as a git submodule located at `vendor/llama.cpp`, which points to the official llama.cpp repository at https://github.com/ggml-org/llama.cpp.git.
1719

18-
The project applies custom patches to llama.cpp's server implementation (`server.cpp` and `utils.hpp`) to integrate with the Docker model-runner architecture. These patches are maintained in `src/server/server.patch`.
20+
We build the upstream `llama-server` binary directly without any modifications.
1921

2022
### Prerequisites
2123

@@ -45,32 +47,20 @@ If the submodule is already initialized, this command is safe to run and will en
4547
popd
4648
```
4749

48-
3. **Apply the custom llama-server patch:**
50+
3. **Build and test:**
4951

5052
```bash
51-
make -C src/server clean
52-
make -C src/server
53-
```
54-
55-
This will:
56-
- Clean the previous patched files
57-
- Copy the new `server.cpp` and `utils.hpp` from the updated llama.cpp
58-
- Apply our custom patches from `src/server/server.patch`
59-
60-
4. **Build and test:**
53+
# Build from the native directory
54+
cmake -B build
55+
cmake --build build --parallel 8 --config Release
6156

62-
```bash
63-
# Build from the native directory
64-
cmake -B build
65-
cmake --build build --parallel 8 --config Release
66-
6757
# Test the build
6858
./build/bin/com.docker.llama-server --model <path to model>
6959
```
7060

7161
Make sure everything builds cleanly without errors.
7262

73-
5. **Commit the submodule update:**
63+
4. **Commit the submodule update:**
7464

7565
```bash
7666
git add vendor/llama.cpp

llamacpp/native/src/server/CMakeLists.txt

Lines changed: 0 additions & 31 deletions
This file was deleted.

llamacpp/native/src/server/Makefile

Lines changed: 0 additions & 18 deletions
This file was deleted.

llamacpp/native/src/server/README.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)