From 0763ca3ec19c8fef32d01d04bbcf8fce1d6226ef Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Fri, 23 Aug 2024 02:52:58 +0100 Subject: [PATCH 1/2] - Updated binaries to llama.cpp https://github.com/ggerganov/llama.cpp/blob/11b84eb4578864827afcf956db5b571003f18180 - Built with https://github.com/SciSharp/LLamaSharp/actions/runs/10517369387 --- LLama/Batched/LLamaContextExtensions.cs | 25 ++++---- LLama/LLamaContext.cs | 73 +++++++++++------------- LLama/LLamaSharp.csproj | 2 +- LLama/Native/LLamaModelQuantizeParams.cs | 2 +- LLama/Native/LLamaRopeType.cs | 9 ++- LLama/Native/LLamaVocabPreType.cs | 3 + LLama/Native/NativeApi.LLava.cs | 2 +- LLama/Native/NativeApi.cs | 14 ++--- LLama/Native/SafeLLamaContextHandle.cs | 46 ++++++++------- LLama/Native/SafeLlamaModelHandle.cs | 28 +++++++++ llama.cpp | 2 +- 11 files changed, 117 insertions(+), 89 deletions(-) diff --git a/LLama/Batched/LLamaContextExtensions.cs b/LLama/Batched/LLamaContextExtensions.cs index 9355301a5..db25d499e 100644 --- a/LLama/Batched/LLamaContextExtensions.cs +++ b/LLama/Batched/LLamaContextExtensions.cs @@ -1,5 +1,6 @@ -using System; +using System; using System.Buffers.Binary; +using System.Diagnostics; using System.IO; using System.IO.MemoryMappedFiles; using LLama.Native; @@ -24,20 +25,20 @@ internal static void SaveState(this LLamaContext context, string filename, LLama if (File.Exists(filename)) File.Delete(filename); - // Estimate size of state to write to disk, this is always equal to or greater than the actual size - var estimatedStateSize = checked((long)context.NativeHandle.GetStateSize(sequence)); + // Get the exact size of the state + var stateSize = context.NativeHandle.GetStateSize(sequence); // Space for "extra" byte plus a 8 byte header var prefixSize = header.Length + 8; // Add enough space for the "extra" data and a 6 byte header - var totalFileSize = prefixSize + estimatedStateSize; + var totalFileSize = (nuint)prefixSize + stateSize; // Map the file and write the bytes directly to it. - long writtenBytes = 0; - using (var file = MemoryMappedFile.CreateFromFile(filename, FileMode.Create, null, totalFileSize)) + nuint writtenBytes = 0; + using (var file = MemoryMappedFile.CreateFromFile(filename, FileMode.Create, null, (long)totalFileSize)) { - using (var view = file.CreateViewAccessor(0, totalFileSize)) + using (var view = file.CreateViewAccessor(0, (long)totalFileSize)) { unsafe { @@ -51,10 +52,10 @@ internal static void SaveState(this LLamaContext context, string filename, LLama BinaryPrimitives.WriteUInt32BigEndian(new Span(ptr + writtenBytes, 4), (uint)header.Length); writtenBytes += 4; header.CopyTo(new Span(ptr + writtenBytes, header.Length)); - writtenBytes += header.Length; + writtenBytes += (nuint)header.Length; // Write state data - writtenBytes += (long)context.NativeHandle.GetState(ptr + writtenBytes, (ulong)estimatedStateSize, sequence); + writtenBytes += context.NativeHandle.GetState(ptr + writtenBytes, stateSize, sequence); } finally { @@ -64,9 +65,7 @@ internal static void SaveState(this LLamaContext context, string filename, LLama } } - // Truncate the file to the actual size of data that was written - using (var fileStream = new FileStream(filename, FileMode.Open)) - fileStream.SetLength(writtenBytes); + Debug.Assert(totalFileSize == writtenBytes, $"Expected to write {totalFileSize} bytes, but actally wrote {writtenBytes}"); } /// @@ -105,7 +104,7 @@ internal static void LoadState(this LLamaContext context, string filename, LLama new Span(ptr + readBytes, headerLength).CopyTo(header); readBytes += headerLength; - context.NativeHandle.SetState(ptr + readBytes, sequence); + context.NativeHandle.SetState(ptr + readBytes, (nuint)((long)view.SafeMemoryMappedViewHandle.ByteLength - readBytes), sequence); } finally { diff --git a/LLama/LLamaContext.cs b/LLama/LLamaContext.cs index 70341649b..36c6de7e5 100644 --- a/LLama/LLamaContext.cs +++ b/LLama/LLamaContext.cs @@ -1,7 +1,7 @@ -using LLama.Exceptions; using LLama.Native; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Text; using System.IO; using System.IO.MemoryMappedFiles; @@ -150,13 +150,13 @@ public void SaveState(string filename) if (File.Exists(filename)) File.Delete(filename); - // Estimate size of state to write to disk, this is always equal to or greater than the actual size - var estimatedStateSize = checked((long)NativeHandle.GetStateSize()); + // Get the exact size of the state + var stateSize = NativeHandle.GetStateSize(); // Map the file and write the bytes directly to it. This saves copying the bytes into a C# array - long writtenBytes; - using (var file = MemoryMappedFile.CreateFromFile(filename, FileMode.Create, null, estimatedStateSize)) - using (var view = file.CreateViewAccessor(0, estimatedStateSize)) + nuint writtenBytes; + using (var file = MemoryMappedFile.CreateFromFile(filename, FileMode.Create, null, checked((long)stateSize))) + using (var view = file.CreateViewAccessor(0, checked((long)stateSize))) { unsafe { @@ -164,7 +164,7 @@ public void SaveState(string filename) view.SafeMemoryMappedViewHandle.AcquirePointer(ref ptr); try { - writtenBytes = (long)NativeHandle.GetState(ptr, (ulong)estimatedStateSize); + writtenBytes = NativeHandle.GetState(ptr, stateSize); } finally { @@ -173,9 +173,7 @@ public void SaveState(string filename) } } - // Truncate the file to the actual size of data that was written - using (var fileStream = new FileStream(filename, FileMode.Open)) - fileStream.SetLength(writtenBytes); + Debug.Assert(stateSize == writtenBytes, $"Expected to write {stateSize} bytes, but actally wrote {writtenBytes}"); } /// @@ -189,13 +187,13 @@ public void SaveState(string filename, LLamaSeqId sequence) if (File.Exists(filename)) File.Delete(filename); - // Estimate size of state to write to disk, this is always equal to or greater than the actual size - var estimatedStateSize = checked((long)NativeHandle.GetStateSize(sequence)); + // Get the exact size of the state + var stateSize = NativeHandle.GetStateSize(sequence); // Map the file and write the bytes directly to it. This saves copying the bytes into a C# array - long writtenBytes; - using (var file = MemoryMappedFile.CreateFromFile(filename, FileMode.Create, null, estimatedStateSize)) - using (var view = file.CreateViewAccessor(0, estimatedStateSize)) + nuint writtenBytes; + using (var file = MemoryMappedFile.CreateFromFile(filename, FileMode.Create, null, checked((long)stateSize))) + using (var view = file.CreateViewAccessor(0, checked((long)stateSize))) { unsafe { @@ -203,7 +201,7 @@ public void SaveState(string filename, LLamaSeqId sequence) view.SafeMemoryMappedViewHandle.AcquirePointer(ref ptr); try { - writtenBytes = (long)NativeHandle.GetState(ptr, (ulong)estimatedStateSize, sequence); + writtenBytes = NativeHandle.GetState(ptr, stateSize, sequence); } finally { @@ -212,9 +210,7 @@ public void SaveState(string filename, LLamaSeqId sequence) } } - // Truncate the file to the actual size of data that was written - using (var fileStream = new FileStream(filename, FileMode.Open)) - fileStream.SetLength(writtenBytes); + Debug.Assert(stateSize == writtenBytes, $"Expected to write {stateSize} bytes, but actally wrote {writtenBytes}"); } /// @@ -230,15 +226,14 @@ public State GetState() var memory = Marshal.AllocHGlobal((nint)stateSize); try { - // Copy the state data into memory, discover the actual size required - ulong actualSize; + // Copy the state data into memory + nuint actualSize; unsafe { actualSize = NativeHandle.GetState((byte*)memory, stateSize); } - // Shrink to size - memory = Marshal.ReAllocHGlobal(memory, (nint)actualSize); + Debug.Assert(actualSize == stateSize); // Wrap memory in a "state" var state = new State(memory, actualSize); @@ -269,14 +264,13 @@ public SequenceState GetState(LLamaSeqId sequence) try { // Copy the state data into memory, discover the actual size required - ulong actualSize; + nuint actualSize; unsafe { actualSize = NativeHandle.GetState((byte*)memory, stateSize, sequence); } - // Shrink to size - memory = Marshal.ReAllocHGlobal(memory, (nint)actualSize); + Debug.Assert(actualSize == stateSize); // Wrap memory in a "state" var state = new SequenceState(memory, actualSize); @@ -309,7 +303,7 @@ public void LoadState(string filename) view.SafeMemoryMappedViewHandle.AcquirePointer(ref ptr); try { - NativeHandle.SetState(ptr); + NativeHandle.SetState(ptr, (nuint)view.SafeMemoryMappedViewHandle.ByteLength); } finally { @@ -336,7 +330,7 @@ public void LoadState(string filename, LLamaSeqId sequence) view.SafeMemoryMappedViewHandle.AcquirePointer(ref ptr); try { - NativeHandle.SetState(ptr, sequence); + NativeHandle.SetState(ptr, (nuint)view.SafeMemoryMappedViewHandle.ByteLength, sequence); } finally { @@ -354,7 +348,7 @@ public void LoadState(State state) { unsafe { - NativeHandle.SetState((byte*)state.DangerousGetHandle()); + NativeHandle.SetState((byte*)state.DangerousGetHandle(), state.Size); } } @@ -367,7 +361,7 @@ public void LoadState(SequenceState state, LLamaSeqId sequence) { unsafe { - NativeHandle.SetState((byte*)state.DangerousGetHandle(), sequence); + NativeHandle.SetState((byte*)state.DangerousGetHandle(), state.Size, sequence); } } #endregion @@ -380,7 +374,8 @@ public void LoadState(SequenceState state, LLamaSeqId sequence) public bool ShouldAddBosToken() { var addBos = NativeApi.llama_add_bos_token(NativeHandle.ModelHandle); - return addBos != -1 ? Convert.ToBoolean(addBos) : NativeHandle.LLamaVocabType == LLamaVocabType.SentencePiece; + //return addBos != -1 ? Convert.ToBoolean(addBos) : NativeHandle.LLamaVocabType == LLamaVocabType.SentencePiece; + return addBos; } #region eval overloads @@ -458,13 +453,13 @@ public void Dispose() public class State : SafeLLamaHandleBase { - private readonly ulong _size; + private readonly nuint _size; /// /// Get the size in bytes of this state object /// - public ulong Size => _size; + public nuint Size => _size; - internal State(IntPtr memory, ulong size) + internal State(IntPtr memory, nuint size) : base(memory, true) { _size = size; @@ -513,7 +508,7 @@ public void Save(Stream stream) public static async Task LoadAsync(Stream stream) { var memory = Marshal.AllocHGlobal((nint)stream.Length); - var state = new State(memory, checked((ulong)stream.Length)); + var state = new State(memory, (nuint)stream.Length); UnmanagedMemoryStream dest; unsafe @@ -533,7 +528,7 @@ public static async Task LoadAsync(Stream stream) public static State Load(Stream stream) { var memory = Marshal.AllocHGlobal((nint)stream.Length); - var state = new State(memory, checked((ulong)stream.Length)); + var state = new State(memory, (nuint)stream.Length); unsafe { @@ -551,13 +546,13 @@ public static State Load(Stream stream) public class SequenceState : SafeLLamaHandleBase { - private readonly ulong _size; + private readonly nuint _size; /// /// Get the size in bytes of this state object /// - public ulong Size => _size; + public nuint Size => _size; - internal SequenceState(IntPtr memory, ulong size) + internal SequenceState(IntPtr memory, nuint size) : base(memory, true) { _size = size; diff --git a/LLama/LLamaSharp.csproj b/LLama/LLamaSharp.csproj index bccf2b3f6..addda27f2 100644 --- a/LLama/LLamaSharp.csproj +++ b/LLama/LLamaSharp.csproj @@ -53,7 +53,7 @@ - 345c8c0c87a97c1595f9c8b + 11b84eb4578864827afcf diff --git a/LLama/Native/LLamaModelQuantizeParams.cs b/LLama/Native/LLamaModelQuantizeParams.cs index 8979d8724..d11f4882e 100644 --- a/LLama/Native/LLamaModelQuantizeParams.cs +++ b/LLama/Native/LLamaModelQuantizeParams.cs @@ -25,7 +25,7 @@ public struct LLamaModelQuantizeParams public GGMLType output_tensor_type; /// - /// itoken embeddings tensor type + /// token embeddings tensor type /// public GGMLType token_embedding_type; diff --git a/LLama/Native/LLamaRopeType.cs b/LLama/Native/LLamaRopeType.cs index 19e50e6b9..ebad9e77b 100644 --- a/LLama/Native/LLamaRopeType.cs +++ b/LLama/Native/LLamaRopeType.cs @@ -1,9 +1,12 @@ -namespace LLama.Native; +namespace LLama.Native; +/// +/// +/// +/// llama_rope_type public enum LLamaRopeType { None = -1, Norm = 0, - NEOX = 2, - GLM = 4, + NEOX = 2,//GGML_ROPE_TYPE_NEOX, } \ No newline at end of file diff --git a/LLama/Native/LLamaVocabPreType.cs b/LLama/Native/LLamaVocabPreType.cs index 3e5bc287c..35ed39c06 100644 --- a/LLama/Native/LLamaVocabPreType.cs +++ b/LLama/Native/LLamaVocabPreType.cs @@ -30,4 +30,7 @@ internal enum LLamaVocabPreType TEKKEN = 20, SMOLLM = 21, CODESHELL = 22, + BLOOM = 23, + GPT3_FINNISH = 24, + EXAONE = 25, } \ No newline at end of file diff --git a/LLama/Native/NativeApi.LLava.cs b/LLama/Native/NativeApi.LLava.cs index 246a9d1b2..bda796d4c 100644 --- a/LLama/Native/NativeApi.LLava.cs +++ b/LLama/Native/NativeApi.LLava.cs @@ -2,7 +2,7 @@ namespace LLama.Native; -public static unsafe partial class NativeApi +public static partial class NativeApi { /// /// Sanity check for clip <-> llava embed size match diff --git a/LLama/Native/NativeApi.cs b/LLama/Native/NativeApi.cs index f7b97bead..8d967e670 100644 --- a/LLama/Native/NativeApi.cs +++ b/LLama/Native/NativeApi.cs @@ -188,19 +188,13 @@ public static unsafe int llama_chat_apply_template(SafeLlamaModelHandle? model, static extern int internal_llama_chat_apply_template(IntPtr model, byte* tmpl, LLamaChatMessage* chat, nuint n_msg, [MarshalAs(UnmanagedType.U1)] bool add_ass, byte* buf, int length); } - /// - /// Returns -1 if unknown, 1 for true or 0 for false. - /// - /// [DllImport(libraryName, CallingConvention = CallingConvention.Cdecl)] - public static extern int llama_add_bos_token(SafeLlamaModelHandle model); + [return: MarshalAs(UnmanagedType.U1)] + public static extern bool llama_add_bos_token(SafeLlamaModelHandle model); - /// - /// Returns -1 if unknown, 1 for true or 0 for false. - /// - /// [DllImport(libraryName, CallingConvention = CallingConvention.Cdecl)] - public static extern int llama_add_eos_token(SafeLlamaModelHandle model); + [return: MarshalAs(UnmanagedType.U1)] + public static extern bool llama_add_eos_token(SafeLlamaModelHandle model); /// /// Print out timing information for this context diff --git a/LLama/Native/SafeLLamaContextHandle.cs b/LLama/Native/SafeLLamaContextHandle.cs index 628936352..b5932aa04 100644 --- a/LLama/Native/SafeLLamaContextHandle.cs +++ b/LLama/Native/SafeLLamaContextHandle.cs @@ -258,13 +258,13 @@ static SafeLLamaContextHandle() private static extern void llama_set_rng_seed(SafeLLamaContextHandle ctx, uint seed); /// - /// Returns the maximum size in bytes of the state (rng, logits, embedding - /// and kv_cache) - will often be smaller after compacting tokens + /// Returns the **actual** size in bytes of the state (rng, logits, embedding and kv_cache). + /// Only use when saving the state, not when restoring it, otherwise the size may be too small. /// /// /// [DllImport(NativeApi.libraryName, CallingConvention = CallingConvention.Cdecl)] - private static extern ulong llama_state_get_size(SafeLLamaContextHandle ctx); + private static extern nuint llama_state_get_size(SafeLLamaContextHandle ctx); /// /// Copies the state to the specified destination address. @@ -272,47 +272,51 @@ static SafeLLamaContextHandle() /// /// /// + /// /// the number of bytes copied [DllImport(NativeApi.libraryName, CallingConvention = CallingConvention.Cdecl)] - private static extern unsafe ulong llama_state_get_data(SafeLLamaContextHandle ctx, byte* dest); + private static extern unsafe nuint llama_state_get_data(SafeLLamaContextHandle ctx, byte* dest, nuint size); /// /// Set the state reading from the specified address /// /// /// + /// /// the number of bytes read [DllImport(NativeApi.libraryName, CallingConvention = CallingConvention.Cdecl)] - private static extern unsafe ulong llama_state_set_data(SafeLLamaContextHandle ctx, byte* src); + private static extern unsafe nuint llama_state_set_data(SafeLLamaContextHandle ctx, byte* src, nuint size); /// /// Get the exact size needed to copy the KV cache of a single sequence /// [DllImport(NativeApi.libraryName, CallingConvention = CallingConvention.Cdecl)] - private static extern nuint llama_state_seq_get_size(SafeLLamaContextHandle ctx, LLamaSeqId seq_id); + private static extern nuint llama_state_seq_get_size(SafeLLamaContextHandle ctx, LLamaSeqId seqId); /// /// Copy the KV cache of a single sequence into the specified buffer /// /// /// - /// + /// + /// /// [DllImport(NativeApi.libraryName, CallingConvention = CallingConvention.Cdecl)] - private static extern unsafe nuint llama_state_seq_get_data(SafeLLamaContextHandle ctx, byte* dst, LLamaSeqId seq_id); + private static extern unsafe nuint llama_state_seq_get_data(SafeLLamaContextHandle ctx, byte* dst, nuint size, LLamaSeqId seqId); /// /// Copy the sequence data (originally copied with `llama_state_seq_get_data`) into the specified sequence /// /// /// - /// + /// + /// /// /// - Positive: Ok /// - Zero: Failed to load /// [DllImport(NativeApi.libraryName, CallingConvention = CallingConvention.Cdecl)] - private static extern unsafe nuint llama_state_seq_set_data(SafeLLamaContextHandle ctx, byte* src, LLamaSeqId dest_seq_id); + private static extern unsafe nuint llama_state_seq_set_data(SafeLLamaContextHandle ctx, byte* src, nuint size, LLamaSeqId destSeqId); /// /// Defragment the KV cache. This will be applied: @@ -569,7 +573,7 @@ public DecodeResult Decode(LLamaBatchEmbeddings batch) /// /// Get the size of the state, when saved as bytes /// - public ulong GetStateSize() + public nuint GetStateSize() { return llama_state_get_size(this); } @@ -579,7 +583,7 @@ public ulong GetStateSize() /// /// /// - public ulong GetStateSize(LLamaSeqId sequence) + public nuint GetStateSize(LLamaSeqId sequence) { return llama_state_seq_get_size(this, sequence); } @@ -591,13 +595,13 @@ public ulong GetStateSize(LLamaSeqId sequence) /// Number of bytes available to write to in dest (check required size with `GetStateSize()`) /// The number of bytes written to dest /// Thrown if dest is too small - public unsafe ulong GetState(byte* dest, ulong size) + public unsafe nuint GetState(byte* dest, nuint size) { var required = GetStateSize(); if (size < required) throw new ArgumentOutOfRangeException(nameof(size), $"Allocated space is too small, {size} < {required}"); - return llama_state_get_data(this, dest); + return llama_state_get_data(this, dest, size); } /// @@ -607,23 +611,24 @@ public unsafe ulong GetState(byte* dest, ulong size) /// Number of bytes available to write to in dest (check required size with `GetStateSize()`) /// The sequence to get state data for /// The number of bytes written to dest - public unsafe ulong GetState(byte* dest, ulong size, LLamaSeqId sequence) + public unsafe nuint GetState(byte* dest, nuint size, LLamaSeqId sequence) { var required = GetStateSize(sequence); if (size < required) throw new ArgumentOutOfRangeException(nameof(size), $"Allocated space is too small, {size} < {required}"); - return llama_state_seq_get_data(this, dest, sequence); + return llama_state_seq_get_data(this, dest, size, sequence); } /// /// Set the raw state of this context /// /// The pointer to read the state from + /// Number of bytes that can be safely read from the pointer /// Number of bytes read from the src pointer - public unsafe ulong SetState(byte* src) + public unsafe nuint SetState(byte* src, nuint size) { - return llama_state_set_data(this, src); + return llama_state_set_data(this, src, size); } /// @@ -631,10 +636,11 @@ public unsafe ulong SetState(byte* src) /// /// The pointer to read the state from /// Sequence ID to set + /// Number of bytes that can be safely read from the pointer /// Number of bytes read from the src pointer - public unsafe ulong SetState(byte* src, LLamaSeqId sequence) + public unsafe nuint SetState(byte* src, nuint size, LLamaSeqId sequence) { - return llama_state_seq_set_data(this, src, sequence); + return llama_state_seq_set_data(this, src, size, sequence); } #endregion diff --git a/LLama/Native/SafeLlamaModelHandle.cs b/LLama/Native/SafeLlamaModelHandle.cs index eaf76421a..66f25bb36 100644 --- a/LLama/Native/SafeLlamaModelHandle.cs +++ b/LLama/Native/SafeLlamaModelHandle.cs @@ -65,6 +65,16 @@ public sealed class SafeLlamaModelHandle /// public bool HasEncoder => llama_model_has_encoder(this); + /// + /// Returns true if the model contains a decoder that requires llama_decode() call + /// + public bool HasDecoder => llama_model_has_decoder(this); + + /// + /// Returns true if the model is recurrent (like Mamba, RWKV, etc.) + /// + public bool IsRecurrent => llama_model_is_recurrent(this); + /// /// Get a description of this model /// @@ -434,8 +444,26 @@ private static int llama_model_meta_val_str(SafeLlamaModelHandle model, string k [return: MarshalAs(UnmanagedType.U1)] private static extern bool llama_model_has_encoder(SafeLlamaModelHandle model); + /// + /// Returns true if the model contains a decoder that requires llama_decode() call + /// + /// + /// + [DllImport(NativeApi.libraryName, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.U1)] + private static extern bool llama_model_has_decoder(SafeLlamaModelHandle model); + [DllImport(NativeApi.libraryName, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr llama_lora_adapter_init(SafeLlamaModelHandle model, string path); + + /// + /// Returns true if the model is recurrent (like Mamba, RWKV, etc.) + /// + /// + /// + [DllImport(NativeApi.libraryName, CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.U1)] + private static extern bool llama_model_is_recurrent(SafeLlamaModelHandle model); #endregion #region LoRA diff --git a/llama.cpp b/llama.cpp index 345c8c0c8..11b84eb45 160000 --- a/llama.cpp +++ b/llama.cpp @@ -1 +1 @@ -Subproject commit 345c8c0c87a97c1595f9c8b14833d531c8c7d8df +Subproject commit 11b84eb4578864827afcf956db5b571003f18180 From 39457059bcadac0fe0c64012fe4d0f54394fbe69 Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Fri, 23 Aug 2024 02:55:59 +0100 Subject: [PATCH 2/2] Spelling --- LLama/Batched/LLamaContextExtensions.cs | 2 +- LLama/LLamaContext.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LLama/Batched/LLamaContextExtensions.cs b/LLama/Batched/LLamaContextExtensions.cs index db25d499e..71fa24ea2 100644 --- a/LLama/Batched/LLamaContextExtensions.cs +++ b/LLama/Batched/LLamaContextExtensions.cs @@ -65,7 +65,7 @@ internal static void SaveState(this LLamaContext context, string filename, LLama } } - Debug.Assert(totalFileSize == writtenBytes, $"Expected to write {totalFileSize} bytes, but actally wrote {writtenBytes}"); + Debug.Assert(totalFileSize == writtenBytes, $"Expected to write {totalFileSize} bytes, but actually wrote {writtenBytes}"); } /// diff --git a/LLama/LLamaContext.cs b/LLama/LLamaContext.cs index 36c6de7e5..ca38d49e4 100644 --- a/LLama/LLamaContext.cs +++ b/LLama/LLamaContext.cs @@ -173,7 +173,7 @@ public void SaveState(string filename) } } - Debug.Assert(stateSize == writtenBytes, $"Expected to write {stateSize} bytes, but actally wrote {writtenBytes}"); + Debug.Assert(stateSize == writtenBytes, $"Expected to write {stateSize} bytes, but actually wrote {writtenBytes}"); } /// @@ -210,7 +210,7 @@ public void SaveState(string filename, LLamaSeqId sequence) } } - Debug.Assert(stateSize == writtenBytes, $"Expected to write {stateSize} bytes, but actally wrote {writtenBytes}"); + Debug.Assert(stateSize == writtenBytes, $"Expected to write {stateSize} bytes, but actually wrote {writtenBytes}"); } ///