Skip to content

Commit bc4bdf9

Browse files
committed
sync fork
2 parents 4421364 + 240f06c commit bc4bdf9

30 files changed

+410
-173
lines changed

.github/workflows/compile.yml

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,72 @@ jobs:
7676
name: llava-bin-linux-${{ matrix.build }}-x64.so
7777
if-no-files-found: error
7878

79+
compile-musl:
80+
name: Compile (musl)
81+
strategy:
82+
fail-fast: true
83+
matrix:
84+
include:
85+
- build: 'noavx'
86+
defines: '-DGGML_AVX=OFF -DGGML_AVX2=OFF -DGGML_FMA=OFF'
87+
- build: 'avx2'
88+
defines: ''
89+
- build: 'avx'
90+
defines: '-DGGML_AVX2=OFF'
91+
- build: 'avx512'
92+
defines: '-DGGML_AVX512=ON'
93+
runs-on: ubuntu-20.04
94+
container:
95+
image: alpine:latest
96+
steps:
97+
- name: Install dependencies
98+
run: |
99+
apk update && apk add --no-cache \
100+
build-base \
101+
cmake \
102+
git \
103+
linux-headers \
104+
g++
105+
- uses: actions/checkout@v4
106+
with:
107+
repository: ggerganov/llama.cpp
108+
fetch-depth: 0
109+
ref: '${{ github.event.inputs.llama_cpp_commit }}'
110+
- name: Build
111+
id: cmake_build_musl
112+
run: |
113+
mkdir build
114+
cd build
115+
cmake .. ${{ env.COMMON_DEFINE }} ${{ matrix.defines }}
116+
cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
117+
ls -R
118+
- uses: actions/upload-artifact@v4
119+
with:
120+
path: ./build/bin/libllama.so
121+
name: llama-bin-musl-${{ matrix.build }}-x64.so
122+
if-no-files-found: error
123+
- uses: actions/upload-artifact@v4
124+
with:
125+
path: ./build/bin/libggml.so
126+
name: ggml-bin-musl-${{ matrix.build }}-x64.so
127+
if-no-files-found: error
128+
- uses: actions/upload-artifact@v4
129+
with:
130+
path: ./build/bin/libggml-base.so
131+
name: ggml-base-bin-musl-${{ matrix.build }}-x64.so
132+
if-no-files-found: error
133+
- uses: actions/upload-artifact@v4
134+
with:
135+
path: ./build/bin/libggml-cpu.so
136+
name: ggml-cpu-bin-musl-${{ matrix.build }}-x64.so
137+
if-no-files-found: error
138+
- name: Upload Llava
139+
uses: actions/upload-artifact@v4
140+
with:
141+
path: ./build/bin/libllava_shared.so
142+
name: llava-bin-musl-${{ matrix.build }}-x64.so
143+
if-no-files-found: error
144+
79145
compile-windows:
80146
name: Compile (Windows)
81147
strategy:
@@ -528,6 +594,7 @@ jobs:
528594
if: ${{ always() }}
529595
needs: [
530596
"compile-linux",
597+
"compile-musl",
531598
"compile-windows",
532599
"compile-vulkan",
533600
"compile-cublas",
@@ -543,7 +610,7 @@ jobs:
543610
- name: Rearrange Files
544611
run: |
545612
# Make all directories at once
546-
mkdir --parents deps/{noavx,avx,avx2,avx512,osx-arm64,osx-x64,osx-x64-rosetta2,cu11.7.1,cu12.2.0,vulkan,android-arm64-v8a,android-x86,android-x86_64}
613+
mkdir --parents deps/{noavx,avx,avx2,avx512,musl-noavx,musl-avx,musl-avx2,musl-avx512,osx-arm64,osx-x64,osx-x64-rosetta2,cu11.7.1,cu12.2.0,vulkan,android-arm64-v8a,android-x86,android-x86_64}
547614
548615
# Linux
549616
cp artifacts/ggml-bin-linux-noavx-x64.so/libggml.so deps/noavx/libggml.so
@@ -570,6 +637,31 @@ jobs:
570637
cp artifacts/llama-bin-linux-avx512-x64.so/libllama.so deps/avx512/libllama.so
571638
cp artifacts/llava-bin-linux-avx512-x64.so/libllava_shared.so deps/avx512/libllava_shared.so
572639
640+
# Musl
641+
cp artifacts/ggml-bin-musl-noavx-x64.so/libggml.so deps/musl-noavx/libggml.so
642+
cp artifacts/ggml-base-bin-musl-noavx-x64.so/libggml-base.so deps/musl-noavx/libggml-base.so
643+
cp artifacts/ggml-cpu-bin-musl-noavx-x64.so/libggml-cpu.so deps/musl-noavx/libggml-cpu.so
644+
cp artifacts/llama-bin-musl-noavx-x64.so/libllama.so deps/musl-noavx/libllama.so
645+
cp artifacts/llava-bin-musl-noavx-x64.so/libllava_shared.so deps/musl-noavx/libllava_shared.so
646+
647+
cp artifacts/ggml-bin-musl-avx-x64.so/libggml.so deps/musl-avx/libggml.so
648+
cp artifacts/ggml-base-bin-musl-avx-x64.so/libggml-base.so deps/musl-avx/libggml-base.so
649+
cp artifacts/ggml-cpu-bin-musl-avx-x64.so/libggml-cpu.so deps/musl-avx/libggml-cpu.so
650+
cp artifacts/llama-bin-musl-avx-x64.so/libllama.so deps/musl-avx/libllama.so
651+
cp artifacts/llava-bin-musl-avx-x64.so/libllava_shared.so deps/musl-avx/libllava_shared.so
652+
653+
cp artifacts/ggml-bin-musl-avx2-x64.so/libggml.so deps/musl-avx2/libggml.so
654+
cp artifacts/ggml-base-bin-musl-avx2-x64.so/libggml-base.so deps/musl-avx2/libggml-base.so
655+
cp artifacts/ggml-cpu-bin-musl-avx2-x64.so/libggml-cpu.so deps/musl-avx2/libggml-cpu.so
656+
cp artifacts/llama-bin-musl-avx2-x64.so/libllama.so deps/musl-avx2/libllama.so
657+
cp artifacts/llava-bin-musl-avx2-x64.so/libllava_shared.so deps/musl-avx2/libllava_shared.so
658+
659+
cp artifacts/ggml-bin-musl-avx512-x64.so/libggml.so deps/musl-avx512/libggml.so
660+
cp artifacts/ggml-base-bin-musl-avx512-x64.so/libggml-base.so deps/musl-avx512/libggml-base.so
661+
cp artifacts/ggml-cpu-bin-musl-avx512-x64.so/libggml-cpu.so deps/musl-avx512/libggml-cpu.so
662+
cp artifacts/llama-bin-musl-avx512-x64.so/libllama.so deps/musl-avx512/libllama.so
663+
cp artifacts/llava-bin-musl-avx512-x64.so/libllava_shared.so deps/musl-avx512/libllava_shared.so
664+
573665
# Windows
574666
cp artifacts/ggml-bin-win-noavx-x64.dll/ggml.dll deps/noavx/ggml.dll
575667
cp artifacts/ggml-base-bin-win-noavx-x64.dll/ggml-base.dll deps/noavx/ggml-base.dll

LLama.Examples/LLama.Examples.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" />
17+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.3" />
1818
<PackageReference Include="Microsoft.KernelMemory.Core" Version="0.97.250211.1" />
19-
<PackageReference Include="Microsoft.SemanticKernel" Version="1.29.0" />
19+
<PackageReference Include="Microsoft.SemanticKernel" Version="1.44.0" />
2020
<PackageReference Include="Microsoft.SemanticKernel.Plugins.Memory" Version="1.6.2-alpha" />
2121
<PackageReference Include="NAudio" Version="2.2.1" />
22-
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.5" />
22+
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.7" />
2323
<PackageReference Include="Spectre.Console" Version="0.49.1" />
2424
<PackageReference Include="Spectre.Console.ImageSharp" Version="0.49.1" />
2525
<PackageReference Include="Whisper.net" Version="1.7.4" />
26-
<PackageReference Include="Whisper.net.Runtime" Version="1.7.2" />
26+
<PackageReference Include="Whisper.net.Runtime" Version="1.7.4" />
2727
<PackageReference Include="Whisper.net.Runtime.Clblast" Version="1.5.0" />
2828
<PackageReference Include="Whisper.net.Runtime.CoreML" Version="1.7.4" />
2929
<PackageReference Include="Whisper.net.Runtime.Cublas" Version="1.5.0" />

LLama.KernelMemory/LLamaSharp.KernelMemory.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFrameworks>net8.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
<Version>0.21.0</Version>
7+
<Version>0.22.0</Version>
88
<Authors>Xbotter</Authors>
99
<Company>SciSharp STACK</Company>
1010
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -27,7 +27,7 @@
2727
</PropertyGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="Microsoft.KernelMemory.Abstractions" Version="0.96.250120.1" />
30+
<PackageReference Include="Microsoft.KernelMemory.Abstractions" Version="0.98.250323.1" />
3131
</ItemGroup>
3232

3333
<ItemGroup>

LLama.KernelMemory/LLamaSharpTextEmbeddingGenerator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ public LLamaSharpTextEmbeddingGenerator(LLamaSharpConfig config)
3333
{
3434
ContextSize = config.ContextSize,
3535
GpuLayerCount = config.GpuLayerCount ?? 20,
36-
Embeddings = true,
36+
3737
PoolingType = LLamaPoolingType.Mean,
3838
};
39+
3940
_weights = LLamaWeights.LoadFromFile(@params);
4041
_embedder = new LLamaEmbedder(_weights, @params);
4142
_ownsWeights = true;

LLama.SemanticKernel/LLamaSharp.SemanticKernel.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<ImplicitUsings>enable</ImplicitUsings>
1111
<Nullable>enable</Nullable>
1212

13-
<Version>0.21.0</Version>
13+
<Version>0.22.0</Version>
1414
<Authors>Tim Miller, Xbotter</Authors>
1515
<Company>SciSharp STACK</Company>
1616
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -34,11 +34,11 @@
3434
</PropertyGroup>
3535

3636
<ItemGroup>
37-
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.39.0" />
37+
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.44.0" />
3838
</ItemGroup>
3939

4040
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
41-
<PackageReference Include="System.Memory" Version="4.6.0" PrivateAssets="all" />
41+
<PackageReference Include="System.Memory" Version="4.6.2" PrivateAssets="all" />
4242
</ItemGroup>
4343

4444
<ItemGroup>

LLama.Unittest/KernelMemory/ITextTokenizerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public ITextTokenizerTests(ITestOutputHelper testOutputHelper)
2222
_testOutputHelper = testOutputHelper;
2323

2424
_infParams = new() { AntiPrompts = ["\n\n"] };
25-
_lsConfig = new(Constants.GenerativeModelPath) { DefaultInferenceParams = _infParams };
25+
_lsConfig = new(Constants.GenerativeModelPath) { DefaultInferenceParams = _infParams, ContextSize = 512 };
2626

2727
testOutputHelper.WriteLine($"Using model {Path.GetFileName(_lsConfig.ModelPath)}");
2828
}

LLama.Unittest/LLama.Unittest.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
</PropertyGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
16+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
1717
<PackageReference Include="Moq" Version="4.20.72" />
1818
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
19-
<PackageReference Include="xunit" Version="2.9.2" />
20-
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
19+
<PackageReference Include="xunit" Version="2.9.3" />
20+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
2121
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2222
<PrivateAssets>all</PrivateAssets>
2323
</PackageReference>

LLama.Unittest/LLamaContextTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ public LLamaContextTests()
1414
var @params = new ModelParams(Constants.GenerativeModelPath2)
1515
{
1616
ContextSize = 128,
17+
BatchSize = 8,
18+
UBatchSize = 8,
19+
SeqMax = 1,
20+
VocabOnly = false,
1721
GpuLayerCount = Constants.CIGpuLayerCount,
1822
};
1923
_weights = LLamaWeights.LoadFromFile(@params);
@@ -84,6 +88,11 @@ public void TokenizeEmpty()
8488
[Fact]
8589
public void SaveLoadState()
8690
{
91+
// Make sure there's something in the context worth saving
92+
var batch = new LLamaBatch();
93+
batch.Add(17, 0, LLamaSeqId.Zero, true);
94+
_context.Decode(batch);
95+
8796
using var state1 = _context.GetState();
8897

8998
var stream = new MemoryStream();
@@ -99,6 +108,11 @@ public void SaveLoadState()
99108
[Fact]
100109
public async Task SaveLoadStateAsync()
101110
{
111+
// Make sure there's something in the context worth saving
112+
var batch = new LLamaBatch();
113+
batch.Add(17, 0, LLamaSeqId.Zero, true);
114+
_context.Decode(batch);
115+
102116
using var state1 = _context.GetState();
103117

104118
var stream = new MemoryStream();

LLama.Unittest/LLamaEmbedderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ private async Task CompareEmbeddings(string modelPath)
4545
var generator = (IEmbeddingGenerator<string, Embedding<float>>)embedder;
4646
Assert.NotNull(generator.GetService<EmbeddingGeneratorMetadata>());
4747
Assert.Equal(nameof(LLamaEmbedder), generator.GetService<EmbeddingGeneratorMetadata>()?.ProviderName);
48-
Assert.NotNull(generator.GetService<EmbeddingGeneratorMetadata>()?.ModelId);
49-
Assert.NotEmpty(generator.GetService<EmbeddingGeneratorMetadata>()?.ModelId!);
48+
Assert.NotNull(generator.GetService<EmbeddingGeneratorMetadata>()?.DefaultModelId);
49+
Assert.NotEmpty(generator.GetService<EmbeddingGeneratorMetadata>()?.DefaultModelId!);
5050
Assert.Same(embedder, generator.GetService<LLamaEmbedder>());
5151
Assert.Same(generator, generator.GetService<IEmbeddingGenerator<string, Embedding<float>>>());
5252
Assert.Null(generator.GetService<string>());

LLama.Web/Common/InferenceOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public class InferenceOptions
2020
public IReadOnlyList<string> AntiPrompts { get; set; } = Array.Empty<string>();
2121

2222
/// <inheritdoc />
23-
public required ISamplingPipeline SamplingPipeline { get; set; }
23+
public ISamplingPipeline SamplingPipeline { get; set; } = new DefaultSamplingPipeline();
2424
}
2525
}

0 commit comments

Comments
 (0)