Skip to content

Commit 258e80f

Browse files
authored
Merge pull request #6 from arthw/cherry-1220
Cherry 1220
2 parents 8dcc98f + bcfe978 commit 258e80f

File tree

399 files changed

+40269
-40004
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

399 files changed

+40269
-40004
lines changed

.clang-format

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
Language: Cpp
3+
AlignAfterOpenBracket: Align
4+
AlignArrayOfStructures: Left
5+
AlignConsecutiveAssignments: AcrossComments
6+
AlignConsecutiveBitFields: AcrossComments
7+
AlignConsecutiveDeclarations: AcrossComments
8+
AlignConsecutiveMacros: AcrossComments
9+
# AlignConsecutiveShortCaseStatements: AcrossComments
10+
AlignEscapedNewlines: Left # LeftWithLastLine
11+
AlignOperands: Align
12+
AlignTrailingComments:
13+
Kind: Always
14+
OverEmptyLines: 1
15+
AllowAllArgumentsOnNextLine: true
16+
AllowAllParametersOfDeclarationOnNextLine: false
17+
# AllowBreakBeforeNoexceptSpecifier: OnlyWithParen
18+
AllowShortBlocksOnASingleLine: Never
19+
AllowShortCaseLabelsOnASingleLine: false
20+
AllowShortFunctionsOnASingleLine: Inline
21+
AllowShortIfStatementsOnASingleLine: Never
22+
AllowShortLambdasOnASingleLine: Inline
23+
AllowShortLoopsOnASingleLine: false
24+
AlwaysBreakBeforeMultilineStrings: true
25+
BinPackArguments: true
26+
BinPackParameters: true # OnePerLine
27+
BitFieldColonSpacing: Both
28+
BreakBeforeBraces: Custom # Attach
29+
BraceWrapping:
30+
AfterCaseLabel: true
31+
AfterClass: false
32+
AfterControlStatement: false
33+
AfterEnum: false
34+
AfterFunction: false
35+
AfterNamespace: false
36+
AfterObjCDeclaration: false
37+
AfterStruct: false
38+
AfterUnion: false
39+
AfterExternBlock: false
40+
BeforeCatch: false
41+
BeforeElse: false
42+
BeforeLambdaBody: false
43+
BeforeWhile: false
44+
IndentBraces: false
45+
SplitEmptyFunction: false
46+
SplitEmptyRecord: false
47+
SplitEmptyNamespace: false
48+
# BreakAdjacentStringLiterals: true
49+
BreakAfterAttributes: Never
50+
BreakBeforeBinaryOperators: None
51+
BreakBeforeInlineASMColon: OnlyMultiline
52+
BreakBeforeTernaryOperators: false
53+
# BreakBinaryOperations: Never
54+
BreakConstructorInitializers: AfterColon
55+
# BreakFunctionDefinitionParameters: false
56+
BreakInheritanceList: AfterComma
57+
BreakStringLiterals: true
58+
# BreakTemplateDeclarations: Yes
59+
ColumnLimit: 120
60+
CommentPragmas: '^ IWYU pragma:'
61+
CompactNamespaces: false
62+
ConstructorInitializerIndentWidth: 4
63+
ContinuationIndentWidth: 4
64+
Cpp11BracedListStyle: false
65+
DerivePointerAlignment: false
66+
DisableFormat: false
67+
EmptyLineBeforeAccessModifier: Leave
68+
EmptyLineAfterAccessModifier: Never
69+
ExperimentalAutoDetectBinPacking: false
70+
FixNamespaceComments: true
71+
IncludeBlocks: Regroup
72+
IncludeCategories:
73+
- Regex: '^<.*\.h>'
74+
Priority: 1
75+
SortPriority: 0
76+
- Regex: '^<.*'
77+
Priority: 2
78+
SortPriority: 0
79+
- Regex: '.*'
80+
Priority: 3
81+
SortPriority: 0
82+
IncludeIsMainRegex: '([-_](test|unittest))?$'
83+
IncludeIsMainSourceRegex: ''
84+
IndentAccessModifiers: false
85+
IndentCaseBlocks: true
86+
IndentCaseLabels: true
87+
IndentExternBlock: NoIndent
88+
IndentGotoLabels: false
89+
IndentPPDirectives: AfterHash
90+
IndentWidth: 4
91+
IndentWrappedFunctionNames: false
92+
InsertBraces: true # NOTE: may lead to incorrect formatting
93+
InsertNewlineAtEOF: true
94+
JavaScriptQuotes: Leave
95+
JavaScriptWrapImports: true
96+
KeepEmptyLinesAtTheStartOfBlocks: false
97+
LambdaBodyIndentation: Signature
98+
LineEnding: LF
99+
MacroBlockBegin: ''
100+
MacroBlockEnd: ''
101+
MaxEmptyLinesToKeep: 1
102+
NamespaceIndentation: None
103+
ObjCBinPackProtocolList: Auto
104+
ObjCBlockIndentWidth: 4
105+
ObjCSpaceAfterProperty: true
106+
ObjCSpaceBeforeProtocolList: true
107+
PPIndentWidth: -1
108+
PackConstructorInitializers: CurrentLine
109+
PenaltyBreakAssignment: 2
110+
PenaltyBreakBeforeFirstCallParameter: 1
111+
PenaltyBreakComment: 300
112+
PenaltyBreakFirstLessLess: 120
113+
PenaltyBreakString: 1000
114+
PenaltyBreakTemplateDeclaration: 10
115+
PenaltyExcessCharacter: 1000000
116+
PenaltyReturnTypeOnItsOwnLine: 200
117+
PointerAlignment: Middle
118+
QualifierAlignment: Left
119+
#QualifierOrder: ['static', 'inline', 'friend', 'constexpr', 'const', 'volatile', 'type', 'restrict']
120+
RawStringFormats:
121+
- Language: Cpp
122+
Delimiters:
123+
- cc
124+
- CC
125+
- cpp
126+
- Cpp
127+
- CPP
128+
- 'c++'
129+
- 'C++'
130+
CanonicalDelimiter: ''
131+
ReferenceAlignment: Middle
132+
ReflowComments: false # IndentOnly
133+
SeparateDefinitionBlocks: Always
134+
SortIncludes: CaseInsensitive
135+
SortUsingDeclarations: LexicographicNumeric
136+
SpaceAfterCStyleCast: true
137+
SpaceAfterLogicalNot: false
138+
SpaceAfterTemplateKeyword: true
139+
SpaceBeforeAssignmentOperators: true
140+
SpaceBeforeCpp11BracedList: false
141+
SpaceBeforeCtorInitializerColon: true
142+
SpaceBeforeInheritanceColon: true
143+
SpaceBeforeParens: ControlStatements
144+
SpaceBeforeRangeBasedForLoopColon: true
145+
SpaceInEmptyBlock: false
146+
SpaceInEmptyParentheses: false
147+
SpacesBeforeTrailingComments: 2
148+
SpacesInAngles: Never
149+
SpacesInContainerLiterals: true
150+
SpacesInLineCommentPrefix:
151+
Minimum: 1
152+
Maximum: -1
153+
SpacesInParentheses: false
154+
SpacesInSquareBrackets: false
155+
SpaceBeforeSquareBrackets: false
156+
Standard: c++17
157+
TabWidth: 4
158+
UseTab: Never
159+
WhitespaceSensitiveMacros: ['STRINGIZE']
160+
...
161+

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ Checks: >
1717
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
1818
performance-*,
1919
portability-*,
20+
-portability-simd-intrinsics,
2021
misc-*,
2122
-misc-const-correctness,
2223
-misc-non-private-member-variables-in-classes,
2324
-misc-no-recursion,
25+
-misc-use-anonymous-namespace,
2426
FormatStyle: none

.devops/full-musa.Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ ARG BASE_MUSA_DEV_CONTAINER=mthreads/musa:${MUSA_VERSION}-devel-ubuntu${UBUNTU_V
66

77
FROM ${BASE_MUSA_DEV_CONTAINER} AS build
88

9+
# MUSA architecture to build for (defaults to all supported archs)
10+
ARG MUSA_DOCKER_ARCH=default
11+
912
RUN apt-get update && \
1013
apt-get install -y build-essential cmake python3 python3-pip git libcurl4-openssl-dev libgomp1
1114

@@ -19,7 +22,11 @@ WORKDIR /app
1922

2023
COPY . .
2124

22-
RUN cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON -DLLAMA_CURL=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \
25+
# Use the default MUSA archs if not specified
26+
RUN if [ "${MUSA_DOCKER_ARCH}" != "default" ]; then \
27+
export CMAKE_ARGS="-DMUSA_ARCHITECTURES=${MUSA_DOCKER_ARCH}"; \
28+
fi && \
29+
cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON -DLLAMA_CURL=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \
2330
cmake --build build --config Release -j$(nproc) && \
2431
cp build/bin/* .
2532

.devops/full.Dockerfile

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,36 @@ ARG UBUNTU_VERSION=22.04
33
FROM ubuntu:$UBUNTU_VERSION AS build
44

55
RUN apt-get update && \
6-
apt-get install -y build-essential python3 python3-pip git libcurl4-openssl-dev libgomp1
6+
apt-get install -y build-essential git cmake libcurl4-openssl-dev
7+
8+
WORKDIR /app
9+
10+
COPY . .
711

8-
COPY requirements.txt requirements.txt
9-
COPY requirements requirements
12+
RUN cmake -S . -B build -DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_CURL=ON -DCMAKE_BUILD_TYPE=Release && \
13+
cmake --build build -j $(nproc) && \
14+
mkdir -p /app/lib && \
15+
find build -name "*.so" -exec cp {} /app/lib/ \;
1016

11-
RUN pip install --upgrade pip setuptools wheel \
12-
&& pip install -r requirements.txt
17+
FROM ubuntu:$UBUNTU_VERSION as runtime
1318

1419
WORKDIR /app
1520

16-
COPY . .
21+
RUN apt-get update && \
22+
apt-get install -y build-essential python3 python3-pip git libcurl4-openssl-dev libgomp1
1723

18-
ENV LLAMA_CURL=1
24+
COPY requirements.txt /app/requirements.txt
25+
COPY requirements /app/requirements
26+
COPY .devops/tools.sh /app/tools.sh
1927

28+
RUN pip install --upgrade pip setuptools wheel && \
29+
pip install -r /app/requirements.txt
2030

21-
RUN make -j$(nproc)
31+
COPY --from=build /app/build/bin/ /app/
32+
COPY --from=build /app/lib/ /app/
33+
COPY --from=build /app/convert_hf_to_gguf.py /app/
34+
COPY --from=build /app/gguf-py /app/gguf-py
2235

2336
ENV LC_ALL=C.utf8
2437

25-
ENTRYPOINT ["/app/.devops/tools.sh"]
38+
ENTRYPOINT ["/app/tools.sh"]

.devops/llama-cli-musa.Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@ ARG BASE_MUSA_RUN_CONTAINER=mthreads/musa:${MUSA_VERSION}-runtime-ubuntu${UBUNTU
88

99
FROM ${BASE_MUSA_DEV_CONTAINER} AS build
1010

11+
# MUSA architecture to build for (defaults to all supported archs)
12+
ARG MUSA_DOCKER_ARCH=default
13+
1114
RUN apt-get update && \
1215
apt-get install -y build-essential git cmake
1316

1417
WORKDIR /app
1518

1619
COPY . .
1720

18-
RUN cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \
21+
# Use the default MUSA archs if not specified
22+
RUN if [ "${MUSA_DOCKER_ARCH}" != "default" ]; then \
23+
export CMAKE_ARGS="-DMUSA_ARCHITECTURES=${MUSA_DOCKER_ARCH}"; \
24+
fi && \
25+
cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \
1926
cmake --build build --config Release --target llama-cli -j$(nproc) && \
2027
mkdir -p /app/lib && \
2128
find build -name "*.so" -exec cp {} /app/lib \;

.devops/llama-cli.Dockerfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,27 @@ ARG UBUNTU_VERSION=22.04
33
FROM ubuntu:$UBUNTU_VERSION AS build
44

55
RUN apt-get update && \
6-
apt-get install -y build-essential git
6+
apt-get install -y build-essential git cmake libcurl4-openssl-dev
77

88
WORKDIR /app
99

1010
COPY . .
1111

12-
RUN make -j$(nproc) llama-cli
12+
RUN cmake -S . -B build -DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_CURL=ON -DCMAKE_BUILD_TYPE=Release && \
13+
cmake --build build -j $(nproc) && \
14+
mkdir -p /app/lib && \
15+
find build -name "*.so" -exec cp {} /app/lib/ \;
1316

1417
FROM ubuntu:$UBUNTU_VERSION AS runtime
1518

19+
WORKDIR /app
20+
1621
RUN apt-get update && \
17-
apt-get install -y libgomp1
22+
apt-get install -y libcurl4-openssl-dev libgomp1 curl
1823

19-
COPY --from=build /app/llama-cli /llama-cli
24+
COPY --from=build /app/build/bin/llama-cli /app/
25+
COPY --from=build /app/lib/ /app/
2026

2127
ENV LC_ALL=C.utf8
2228

23-
ENTRYPOINT [ "/llama-cli" ]
29+
ENTRYPOINT [ "/app/llama-cli" ]

.devops/llama-server-musa.Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@ ARG BASE_MUSA_RUN_CONTAINER=mthreads/musa:${MUSA_VERSION}-runtime-ubuntu${UBUNTU
88

99
FROM ${BASE_MUSA_DEV_CONTAINER} AS build
1010

11+
# MUSA architecture to build for (defaults to all supported archs)
12+
ARG MUSA_DOCKER_ARCH=default
13+
1114
RUN apt-get update && \
1215
apt-get install -y build-essential git cmake libcurl4-openssl-dev
1316

1417
WORKDIR /app
1518

1619
COPY . .
1720

18-
RUN cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON -DLLAMA_CURL=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \
21+
# Use the default MUSA archs if not specified
22+
RUN if [ "${MUSA_DOCKER_ARCH}" != "default" ]; then \
23+
export CMAKE_ARGS="-DMUSA_ARCHITECTURES=${MUSA_DOCKER_ARCH}"; \
24+
fi && \
25+
cmake -B build -DGGML_NATIVE=OFF -DGGML_MUSA=ON -DLLAMA_CURL=ON ${CMAKE_ARGS} -DCMAKE_EXE_LINKER_FLAGS=-Wl,--allow-shlib-undefined . && \
1926
cmake --build build --config Release --target llama-server -j$(nproc) && \
2027
mkdir -p /app/lib && \
2128
find build -name "*.so" -exec cp {} /app/lib \;

.devops/llama-server.Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,31 @@ ARG UBUNTU_VERSION=22.04
33
FROM ubuntu:$UBUNTU_VERSION AS build
44

55
RUN apt-get update && \
6-
apt-get install -y build-essential git libcurl4-openssl-dev
6+
apt-get install -y build-essential git cmake libcurl4-openssl-dev
77

88
WORKDIR /app
99

1010
COPY . .
1111

12-
ENV LLAMA_CURL=1
13-
14-
RUN make -j$(nproc) llama-server
12+
RUN cmake -S . -B build -DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=ON -DLLAMA_CURL=ON -DCMAKE_BUILD_TYPE=Release && \
13+
cmake --build build -j $(nproc) && \
14+
mkdir -p /app/lib && \
15+
find build -name "*.so" -exec cp {} /app/lib/ \;
1516

1617
FROM ubuntu:$UBUNTU_VERSION AS runtime
1718

19+
WORKDIR /app
20+
1821
RUN apt-get update && \
1922
apt-get install -y libcurl4-openssl-dev libgomp1 curl
2023

21-
COPY --from=build /app/llama-server /llama-server
24+
COPY --from=build /app/build/bin/llama-server /app/
25+
COPY --from=build /app/lib/ /app/
2226

2327
ENV LC_ALL=C.utf8
2428
# Must be set to 0.0.0.0 so it can listen to requests from host machine
2529
ENV LLAMA_ARG_HOST=0.0.0.0
2630

2731
HEALTHCHECK CMD [ "curl", "-f", "http://localhost:8080/health" ]
2832

29-
ENTRYPOINT [ "/llama-server" ]
33+
ENTRYPOINT [ "/app/llama-server" ]

.devops/nix/package.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# Increases the runtime closure size by ~700M
3232
useMpi ? false,
3333
useRocm ? config.rocmSupport,
34+
rocmGpuTargets ? builtins.concatStringsSep ";" rocmPackages.clr.gpuTargets,
3435
enableCurl ? true,
3536
useVulkan ? false,
3637
llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake
@@ -188,7 +189,7 @@ effectiveStdenv.mkDerivation (finalAttrs: {
188189
]
189190
++ optionals useRocm [
190191
(cmakeFeature "CMAKE_HIP_COMPILER" "${rocmPackages.llvm.clang}/bin/clang")
191-
(cmakeFeature "CMAKE_HIP_ARCHITECTURES" (builtins.concatStringsSep ";" rocmPackages.clr.gpuTargets))
192+
(cmakeFeature "CMAKE_HIP_ARCHITECTURES" rocmGpuTargets)
192193
]
193194
++ optionals useMetalKit [
194195
(lib.cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1")

.devops/nix/python-scripts.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let
3434

3535
# server tests
3636
openai
37-
behave
37+
pytest
3838
prometheus-client
3939
];
4040
in

0 commit comments

Comments
 (0)