Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions Editor/LLMEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,23 @@ private void CopyToClipboard(string text)

public override void AddSetupExtras(SerializedObject llmScriptSO)
{
bool useCUBLAS = LLMUnitySetup.CUBLAS;
GUIContent content = new GUIContent("Light build for Nvidia GPUs", "Use tinyBLAS instead of cuBLAS that takes up less space and has similar performance for quants - doesn't work with i-quants and flash attention");
bool newUseCUBLAS = !EditorGUILayout.Toggle(content, !useCUBLAS);
if (newUseCUBLAS != useCUBLAS) LLMUnitySetup.SetCUBLAS(newUseCUBLAS);
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows ||
EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneWindows64 ||
EditorUserBuildSettings.activeBuildTarget == BuildTarget.StandaloneLinux64)
{
bool useCUBLAS = LLMUnitySetup.CUBLAS;
GUIContent contentCUBLAS = new GUIContent("Light build for Nvidia GPUs", "Use tinyBLAS instead of cuBLAS that takes up less space and has similar performance for quants - doesn't work with i-quants and flash attention");
bool newUseCUBLAS = !EditorGUILayout.Toggle(contentCUBLAS, !useCUBLAS);
if (newUseCUBLAS != useCUBLAS) LLMUnitySetup.SetCUBLAS(newUseCUBLAS);
}

if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
{
bool useAndroidVulkan = LLMUnitySetup.AndroidVulkan;
GUIContent contentAndroidVulkan = new GUIContent("Use Android GPU (Vulkan, API>=29)", "Use the Android Vulkan build that works with the Android GPU according to the number of GPU layers");
bool newUseAndroidVulkan = EditorGUILayout.Toggle(contentAndroidVulkan, useAndroidVulkan);
if (newUseAndroidVulkan != useAndroidVulkan) LLMUnitySetup.SetAndroidVulkan(newUseAndroidVulkan);
}
}

public override void OnInspectorGUI()
Expand Down
5 changes: 4 additions & 1 deletion Runtime/LLMBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ public static void BuildLibraryPlatforms(BuildTarget buildTarget)
{
foreach (string platform in platforms)
{
string source = Path.Combine(LLMUnitySetup.libraryPath, platform, "native", $"libllamalib_{platform}.{MobileSuffix(buildTarget)}");
string archFilename = $"libllamalib_{platform}.{MobileSuffix(buildTarget)}";
if (buildTarget == BuildTarget.Android && LLMUnitySetup.AndroidVulkan)
archFilename = $"libllamalib_{platform}-vulkan.{MobileSuffix(buildTarget)}";
string source = Path.Combine(LLMUnitySetup.libraryPath, platform, "native", archFilename);
string target = MobilePluginPath(buildTarget, platform.Split("-")[1].ToUpper());
string pluginDir = PluginDir(buildTarget.ToString());
MoveAction(source, target);
Expand Down
11 changes: 11 additions & 0 deletions Runtime/LLMUnitySetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ public class LLMUnitySetup
static string DebugModeKey = "DebugMode";
public static bool CUBLAS = false;
static string CUBLASKey = "CUBLAS";
public static bool AndroidVulkan = false;
static string AndroidVulkanKey = "AndroidVulkan";
static List<Action<string>> errorCallbacks = new List<Action<string>>();
static readonly object lockObject = new object();
static Dictionary<string, Task> androidExtractTasks = new Dictionary<string, Task>();
Expand Down Expand Up @@ -205,6 +207,7 @@ static void LoadPlayerPrefs()
{
DebugMode = (DebugModeType)PlayerPrefs.GetInt(DebugModeKey, (int)DebugModeType.All);
CUBLAS = PlayerPrefs.GetInt(CUBLASKey, 0) == 1;
AndroidVulkan = PlayerPrefs.GetInt(AndroidVulkanKey, 0) == 1;
}

public static void SetDebugMode(DebugModeType newDebugMode)
Expand All @@ -224,6 +227,14 @@ public static void SetCUBLAS(bool value)
PlayerPrefs.Save();
}

public static void SetAndroidVulkan(bool value)
{
if (AndroidVulkan == value) return;
AndroidVulkan = value;
PlayerPrefs.SetInt(AndroidVulkanKey, value ? 1 : 0);
PlayerPrefs.Save();
}

#endif

public static string GetAssetPath(string relPath = "")
Expand Down
Loading