Skip to content

Commit d33cc31

Browse files
authored
fix(Vulkan): read external memory usage (#500)
* fix(Vulkan): read external memory usage * fix(Electron template): minor performance improvement
1 parent 76b505e commit d33cc31

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ jobs:
133133
- name: Install Cuda 13.0 on Windows (1)
134134
if: matrix.config.name == 'Windows (1)'
135135
shell: bash
136-
timeout-minutes: 30
136+
timeout-minutes: 60
137137
run: |
138138
curl -Lo cuda_13.0.0_windows_network.exe https://developer.download.nvidia.com/compute/cuda/13.0.0/network_installers/cuda_13.0.0_windows_network.exe
139139

llama/addon/globals/addonLog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "llama.h"
33
#include "napi.h"
44

5+
56
struct addon_logger_log {
67
public:
78
const int logLevelNumber;

llama/gpuInfo/vulkan-gpu-info.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,17 @@ static bool enumerateVulkanDevices(size_t* total, size_t* used, size_t* unifiedM
4242
physicalDevice.getMemoryProperties2(&memProps2);
4343

4444
for (uint32_t i = 0; i < memProps.memoryHeapCount; ++i) {
45-
const auto flags = memProps.memoryHeaps[i].flags;
45+
const auto heap = memProps2.memoryProperties.memoryHeaps[i];
4646

47-
if (flags & vk::MemoryHeapFlagBits::eDeviceLocal) {
48-
const auto size = memProps.memoryHeaps[i].size;
49-
totalMem += size;
50-
usedMem += memoryBudgetProperties.heapUsage[i];
47+
if (heap.flags & vk::MemoryHeapFlagBits::eDeviceLocal) {
48+
totalMem += heap.size;
49+
usedMem += memoryBudgetProperties.heapUsage[i] + (heap.size - memoryBudgetProperties.heapBudget[i]);
5150

52-
if (flags & vk::MemoryHeapFlagBits::eMultiInstance) {
53-
totalUnifiedMemorySize += size;
51+
if (heap.flags & vk::MemoryHeapFlagBits::eMultiInstance) {
52+
totalUnifiedMemorySize += heap.size;
5453
}
5554

56-
if (size > 0 && addDeviceNames) {
55+
if (heap.size > 0 && addDeviceNames) {
5756
(*deviceNames).push_back(std::string(deviceProps.deviceName.data()));
5857
}
5958

templates/electron-typescript-react/electron/state/llmState.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ export const llmFunctions = {
307307

308308
try {
309309
await chatSession?.preloadPrompt("", {
310+
functions: modelFunctions, // these won't be called, but are used to avoid redundant context shifts
310311
signal: promptAbortController?.signal
311312
});
312313
} catch (err) {

0 commit comments

Comments
 (0)