Skip to content

Commit 33865e2

Browse files
committed
Updated to llama.cpp ff4affb4c1aa7eb4f28a0d9de1b205bd719802f2
1 parent 2485693 commit 33865e2

17 files changed

Lines changed: 165 additions & 83 deletions

LLama.Unittest/MtmdWeightsTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
using System;
2-
using System.IO;
31
using LLama.Common;
42
using LLama.Native;
5-
using Xunit;
63

74
namespace LLama.Unittest
85
{

LLama.Unittest/NativeAbiTests.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
31
using System.Runtime.InteropServices;
42
using LLama.Native;
5-
using Xunit;
63

74
namespace LLama.Unittest
85
{
@@ -79,27 +76,6 @@ public void ContextParamsSizeMatchesNative()
7976
Assert.Equal(expectedSize, Marshal.SizeOf<LLamaContextParams>());
8077
}
8178

82-
[Fact]
83-
public void MtmdContextParamsSizeMatchesNative()
84-
{
85-
var pointerSize = IntPtr.Size;
86-
var fields = new List<(int size, int align)>
87-
{
88-
(sizeof(sbyte), 1), // use_gpu
89-
(sizeof(sbyte), 1), // print_timings
90-
(sizeof(int), 4), // n_threads
91-
(pointerSize, pointerSize), // image_marker
92-
(pointerSize, pointerSize), // media_marker
93-
(sizeof(int), 4), // flash_attn_type
94-
(sizeof(sbyte), 1), // warmup
95-
(sizeof(int), 4), // image_min_tokens
96-
(sizeof(int), 4), // image_max_tokens
97-
};
98-
99-
var expectedSize = ComputeSize(fields);
100-
Assert.Equal(expectedSize, Marshal.SizeOf<NativeApi.mtmd_context_params>());
101-
}
102-
10379
[Fact]
10480
public void ModelParamsBoolBlockMatchesNative()
10581
{

LLama.Web/Common/ModelOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class ModelOptions
4141
/// <inheritdoc />
4242
public bool UseMemorymap { get; set; } = true;
4343

44+
/// <inheritdoc />
45+
public bool UseDirectIO { get; }
46+
4447
/// <inheritdoc />
4548
public bool UseMemoryLock { get; set; } = false;
4649

LLama/Abstractions/IModelParams.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public interface IModelParams
5454
/// </summary>
5555
bool UseMemorymap { get; }
5656

57+
/// <summary>
58+
/// Use direct io, takes precedence over use_mmap when supported
59+
/// </summary>
60+
bool UseDirectIO { get; }
61+
5762
/// <summary>
5863
/// Use mlock to keep model in memory (use_mlock)
5964
/// </summary>

LLama/Common/ModelParams.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public record ModelParams
3434
/// <inheritdoc />
3535
public bool UseMemorymap { get; set; } = true;
3636

37+
/// <inheritdoc />
38+
public bool UseDirectIO { get; set; }
39+
3740
/// <inheritdoc />
3841
public bool UseMemoryLock { get; set; }
3942

LLama/Extensions/IModelParamsExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static IDisposable ToLlamaModelParams(this IModelParams @params, out LLam
3838

3939
result.use_mlock = @params.UseMemoryLock;
4040
result.use_mmap = @params.UseMemorymap;
41+
result.use_direct_io = @params.UseDirectIO;
4142
result.vocab_only = @params.VocabOnly;
4243
result.check_tensors = @params.CheckTensors;
4344

LLama/LLamaSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
</ItemGroup>
5858

5959
<PropertyGroup>
60-
<BinaryReleaseId>506bb6e01009058f355</BinaryReleaseId>
60+
<BinaryReleaseId>ff4affb4c1aa7eb4f28a0_v2</BinaryReleaseId>
6161
</PropertyGroup>
6262

6363
<PropertyGroup>

LLama/Native/LLamaModelParams.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public bool use_mmap
8282
private sbyte _use_mmap;
8383

8484
/// <summary>
85-
/// use direct io, takes precedence over use_mmap
85+
/// use direct io, takes precedence over use_mmap when supported
8686
/// </summary>
8787
public bool use_direct_io
8888
{
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace LLama.Native;
2+
3+
public enum LLamaParamsFitStatus
4+
{
5+
/// <summary>
6+
/// Found allocations that are projected to fit
7+
/// </summary>
8+
LLAMA_PARAMS_FIT_STATUS_SUCCESS = 0,
9+
10+
/// <summary>
11+
/// Could not find allocations that are projected to fit
12+
/// </summary>
13+
LLAMA_PARAMS_FIT_STATUS_FAILURE = 1,
14+
15+
/// <summary>
16+
/// A hard error occurred, e.g. because no model could be found at the specified path
17+
/// </summary>
18+
LLAMA_PARAMS_FIT_STATUS_ERROR = 2,
19+
}

LLama/Native/LoraAdapter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public void Unload()
4545

4646
// Manually free a LoRA adapter. loaded adapters will be free when the associated model is deleted
4747
[DllImport(NativeApi.libraryName, CallingConvention = CallingConvention.Cdecl)]
48+
[Obsolete("adapters are now freed together with the associated model")]
4849
static extern void llama_adapter_lora_free(IntPtr adapter);
4950
}
5051
}

0 commit comments

Comments
 (0)