Browse Source

Set GPULayerCount to execute the Test

Set GPULayerCount to default value (20) to execute UnitTest. In the case of Release Execution on MacOS set the value to ZERO to disable METAL on MacOS and be able to execute it in CI.
pull/672/head
SignalRT 2 years ago
parent
commit
53ae904875
10 changed files with 32 additions and 10 deletions
  1. +1
    -1
      LLama.Unittest/BasicTest.cs
  2. +1
    -1
      LLama.Unittest/BeamTests.cs
  3. +23
    -1
      LLama.Unittest/Constants.cs
  4. +1
    -1
      LLama.Unittest/GrammarTest.cs
  5. +1
    -1
      LLama.Unittest/LLamaContextTests.cs
  6. +1
    -1
      LLama.Unittest/LLamaEmbedderTests.cs
  7. +1
    -1
      LLama.Unittest/LLavaWeightsTests.cs
  8. +1
    -1
      LLama.Unittest/MemoryDisposalTests.cs
  9. +1
    -1
      LLama.Unittest/StatelessExecutorTest.cs
  10. +1
    -1
      LLama.Unittest/TokenTests.cs

+ 1
- 1
LLama.Unittest/BasicTest.cs View File

@@ -18,7 +18,7 @@ namespace LLama.Unittest
_params = new ModelParams(Constants.GenerativeModelPath)
{
ContextSize = 2048,
GpuLayerCount = 0
GpuLayerCount = Constants.CIGpuLayerCount
};
_model = LLamaWeights.LoadFromFile(_params);
}


+ 1
- 1
LLama.Unittest/BeamTests.cs View File

@@ -18,7 +18,7 @@ public sealed class BeamTests
_params = new ModelParams(Constants.GenerativeModelPath)
{
ContextSize = 2048,
GpuLayerCount = 0,
GpuLayerCount = Constants.CIGpuLayerCount,
};
_model = LLamaWeights.LoadFromFile(_params);
}


+ 23
- 1
LLama.Unittest/Constants.cs View File

@@ -1,4 +1,6 @@
namespace LLama.Unittest
using System.Runtime.InteropServices;

namespace LLama.Unittest
{
internal static class Constants
{
@@ -8,5 +10,25 @@
public static readonly string LLavaModelPath = "Models/llava-v1.6-mistral-7b.Q3_K_XS.gguf";
public static readonly string LLavaMmpPath = "Models/mmproj-model-f16.gguf";
public static readonly string LLavaImage = "Models/extreme-ironing-taxi-610x427.jpg";

/// <summary>
/// Calculate GpuLayer Count to use in UnitTest
/// </summary>
/// <returns> Defaults to 20 in all the cases, except IOS release (to disable METAL on github CI)</returns>
public static int CIGpuLayerCount
{
get
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
#if DEBUG
return 20;
#else
return 0;
#endif
}
else return 20;
}
}
}
}

+ 1
- 1
LLama.Unittest/GrammarTest.cs View File

@@ -16,7 +16,7 @@ namespace LLama.Unittest
{
ContextSize = 2048,
Seed = 92,
GpuLayerCount = 0,
GpuLayerCount = Constants.CIGpuLayerCount,
};
_model = LLamaWeights.LoadFromFile(_params);
}


+ 1
- 1
LLama.Unittest/LLamaContextTests.cs View File

@@ -14,7 +14,7 @@ namespace LLama.Unittest
var @params = new ModelParams(Constants.GenerativeModelPath)
{
ContextSize = 768,
GpuLayerCount = 0
GpuLayerCount = Constants.CIGpuLayerCount,
};
_weights = LLamaWeights.LoadFromFile(@params);
_context = _weights.CreateContext(@params);


+ 1
- 1
LLama.Unittest/LLamaEmbedderTests.cs View File

@@ -19,7 +19,7 @@ public sealed class LLamaEmbedderTests
ContextSize = 4096,
Threads = 5,
Embeddings = true,
GpuLayerCount = 0
GpuLayerCount = Constants.CIGpuLayerCount,
};
using var weights = LLamaWeights.LoadFromFile(@params);
_embedder = new(weights, @params);


+ 1
- 1
LLama.Unittest/LLavaWeightsTests.cs View File

@@ -18,7 +18,7 @@ namespace LLama.Unittest
{
// Llava models requires big context
ContextSize = 4096,
GpuLayerCount = 0
GpuLayerCount = Constants.CIGpuLayerCount,
};
_llamaWeights = LLamaWeights.LoadFromFile(@params);
_lLavaWeights = LLavaWeights.LoadFromFile(Constants.LLavaMmpPath);


+ 1
- 1
LLama.Unittest/MemoryDisposalTests.cs View File

@@ -25,7 +25,7 @@ public class MemoryDisposalTests
var @params = new ModelParams(Constants.GenerativeModelPath)
{
ContextSize = 2048,
GpuLayerCount = 0
GpuLayerCount = Constants.CIGpuLayerCount,
};
var model = LLamaWeights.LoadFromFile(@params);



+ 1
- 1
LLama.Unittest/StatelessExecutorTest.cs View File

@@ -20,7 +20,7 @@ namespace LLama.Unittest
ContextSize = 60,
Seed = 1754,
BatchSize = 2,
GpuLayerCount = 0,
GpuLayerCount = Constants.CIGpuLayerCount,
};
_weights = LLamaWeights.LoadFromFile(_params);
}


+ 1
- 1
LLama.Unittest/TokenTests.cs View File

@@ -15,7 +15,7 @@ public sealed class TokenTests
_params = new ModelParams(Constants.GenerativeModelPath)
{
ContextSize = 2048,
GpuLayerCount = 0,
GpuLayerCount = Constants.CIGpuLayerCount,
};
_model = LLamaWeights.LoadFromFile(_params);
}


Loading…
Cancel
Save