Skip to content

Commit 57e8c22

Browse files
authored
feat: Exclude Top Choices (XTC) (#553)
* feat: Exclude Top Choices (XTC) support * feat: DRY (Don't Repeat Yourself) repeat penalty support * feat: Tiny Aya support * fix: adjust the default VRAM padding config to reserve enough memory for compute buffers * fix: adapt to breaking `llama.cpp` changes * fix: support function call syntax with optional whitespace prefix * fix: find the provided cmake path * fix: change the default value of `useDirectIo` to `false` * fix: Vulkan device dedupe
1 parent 4baa480 commit 57e8c22

File tree

50 files changed

+4652
-3957
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+4652
-3957
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,30 @@ jobs:
168168
env:
169169
VULKAN_VERSION: 1.4.313.2
170170
run: |
171+
# $env:VULKAN_VERSION = & curl.exe -fsSL https://vulkan.lunarg.com/sdk/latest/linux.txt
172+
# Write-Host "Downloading Vulkan SDK version $env:VULKAN_VERSION"
173+
171174
curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/vulkansdk-windows-X64-${env:VULKAN_VERSION}.exe"
172175
& "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
173176
Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
174177
Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
175178
176179
- name: Install Vulkan SDK on Ubuntu
177180
if: matrix.config.name == 'Ubuntu (1)'
181+
env:
182+
VULKAN_VERSION: 1.4.341.1
178183
run: |
179-
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
180-
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
181-
sudo apt update
182-
sudo apt install vulkan-sdk
184+
# export VULKAN_VERSION="$(curl -fsSL https://vulkan.lunarg.com/sdk/latest/linux.txt)"
185+
# echo "Downloading Vulkan SDK version ${VULKAN_VERSION}"
186+
187+
sudo apt-get update
188+
sudo apt-get install xz-utils
189+
curl --no-progress-meter "https://sdk.lunarg.com/sdk/download/${VULKAN_VERSION}/linux/vulkan_sdk.tar.xz" -o "/opt/vulkan-sdk.tar.xz"
190+
mkdir -p "/opt/vulkan-sdk"
191+
tar -Jxf "/opt/vulkan-sdk.tar.xz" --strip-components=1 -C "/opt/vulkan-sdk"
192+
rm -f "/opt/vulkan-sdk.tar.xz"
193+
echo "VULKAN_SDK=/opt/vulkan-sdk/x86_64" >> $GITHUB_ENV
194+
echo "/opt/vulkan-sdk/x86_64/bin" >> $GITHUB_PATH
183195
184196
- name: Install dependencies on macOS
185197
if: matrix.config.name == 'macOS x64' || matrix.config.name == 'macOS arm64'

.github/workflows/prLint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ on:
66

77
jobs:
88
lint:
9-
name: Lint
10-
runs-on: ubuntu-latest
9+
name: Validate PR title
10+
runs-on: ubuntu-slim
1111
permissions:
1212
pull-requests: read
1313
steps:
14-
- uses: amannn/action-semantic-pull-request@v5
14+
- uses: amannn/action-semantic-pull-request@v6
1515
env:
1616
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.vitepress/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ export default defineConfig({
387387
},
388388
codeTransformers: [
389389
transformerTwoslash({
390+
floatingVue: {
391+
classFloatingPanel: "twoslash-floating vp-code"
392+
},
390393
explicitTrigger: false,
391394
filter(lang, code, options) {
392395
return options.lang?.toLowerCase() === "typescript";

.vitepress/theme/style.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,19 @@ img.blog-coverImage {
256256
transform: scaleX(1);
257257
}
258258

259-
.v-popper--theme-dropdown .v-popper__inner {
259+
.v-popper--theme-dropdown .v-popper__wrapper {
260260
box-shadow: 0 6px 30px 0px rgb(0 0 0 / 32%);
261261
border-radius: 12px;
262+
background-color: var(--twoslash-popup-bg);
263+
}
264+
.v-popper--theme-dropdown .v-popper__inner {
265+
box-shadow: none;
266+
border-radius: 12px;
262267
}
263268

264-
.twoslash-floating {
269+
.twoslash-floating[class][class] {
265270
--twoslash-border-color: color-mix(in srgb, var(--vp-c-border), transparent 64%);
271+
content-visibility: initial;
266272
}
267273
.twoslash-floating .v-popper__inner {
268274
border: none;

docs/guide/Vulkan.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,25 @@ If you see `Vulkan used VRAM` in the output, it means that Vulkan support is wor
4141
#### Windows: [Vulkan SDK installer](https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe) {#vulkan-sdk-windows}
4242
>
4343
#### Ubuntu {#vulkan-sdk-ubuntu}
44-
::: code-group
45-
46-
```shell [Ubuntu 24.04]
47-
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
48-
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-noble.list https://packages.lunarg.com/vulkan/lunarg-vulkan-noble.list
44+
```shell
4945
sudo apt update
50-
sudo apt install vulkan-sdk
51-
```
46+
sudo apt install curl wget xz-utils
5247

53-
```shell [Ubuntu 22.04]
54-
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo tee /etc/apt/trusted.gpg.d/lunarg.asc
55-
sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
56-
sudo apt update
57-
sudo apt install vulkan-sdk
58-
```
48+
export VULKAN_VERSION="$(curl -fsSL https://vulkan.lunarg.com/sdk/latest/linux.txt)"
5949

60-
:::
50+
echo "Downloading Vulkan SDK version ${VULKAN_VERSION}"
51+
curl --progress-bar "https://sdk.lunarg.com/sdk/download/${VULKAN_VERSION}/linux/vulkan_sdk.tar.xz" -o "/opt/vulkan-sdk.tar.xz"
52+
53+
echo "Installing Vulkan SDK to /opt/vulkan-sdk"
54+
rm -rf "/opt/vulkan-sdk" && mkdir -p "/opt/vulkan-sdk"
55+
tar -Jxf "/opt/vulkan-sdk.tar.xz" --strip-components=1 -C "/opt/vulkan-sdk"
56+
rm -f "/opt/vulkan-sdk.tar.xz"
57+
58+
echo "Adding Vulkan SDK environment variables to shell profiles"
59+
([ ! -f "$HOME/.bashrc" ] || grep -qxF "source /opt/vulkan-sdk/setup-env.sh" "$HOME/.bashrc") || (echo "source /opt/vulkan-sdk/setup-env.sh" >> "$HOME/.bashrc")
60+
([ ! -f "$HOME/.zshrc" ] || grep -qxF "source /opt/vulkan-sdk/setup-env.sh" "$HOME/.zshrc") || (echo "source /opt/vulkan-sdk/setup-env.sh" >> "$HOME/.zshrc")
61+
source /opt/vulkan-sdk/setup-env.sh
62+
```
6163

6264
* :::details Windows only: enable long paths support
6365
Open cmd as Administrator and run this command:

eslint.config.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import n from "eslint-plugin-n";
88
import tseslint from "typescript-eslint";
99
import stylistic from "@stylistic/eslint-plugin";
1010
import {includeIgnoreFile} from "@eslint/compat";
11+
import {defineConfig} from "eslint/config";
1112

1213
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1314
const gitignorePath = path.join(__dirname, ".gitignore");
1415

1516

16-
export default tseslint.config({
17+
export default defineConfig({
1718
ignores: [
1819
"dist/",
1920
"**/dist/",
@@ -25,12 +26,12 @@ export default tseslint.config({
2526
"packages/create-node-llama-cpp/dist/",
2627
"packages/@node-llama-cpp/*/dist/",
2728
".releaserc.ts",
28-
...includeIgnoreFile(gitignorePath).ignores
29+
...(includeIgnoreFile(gitignorePath).ignores ?? [])
2930
]
3031
}, {
3132
files: ["**/**.{,c,m}{js,ts}"],
3233
extends: [
33-
stylistic.configs["recommended-flat"],
34+
stylistic.configs["recommended"],
3435
jsdoc.configs["flat/recommended"],
3536
importPlugin.flatConfigs.recommended
3637
],
@@ -61,7 +62,7 @@ export default tseslint.config({
6162
}
6263
},
6364
rules: {
64-
"@stylistic/indent": ["off"],
65+
"@stylistic/indent": ["warn", 4],
6566
"indent": ["warn", 4, {
6667
SwitchCase: 1,
6768
FunctionDeclaration: {
@@ -80,7 +81,8 @@ export default tseslint.config({
8081
args: "none",
8182
ignoreRestSiblings: true,
8283
varsIgnorePattern: "^set",
83-
caughtErrors: "none"
84+
caughtErrors: "none",
85+
ignoreUsingDeclarations: true
8486
}],
8587
"@stylistic/no-prototype-builtins": ["off"],
8688
"@stylistic/object-curly-spacing": ["warn", "never"],
@@ -174,7 +176,8 @@ export default tseslint.config({
174176
args: "none",
175177
ignoreRestSiblings: true,
176178
varsIgnorePattern: "^set",
177-
caughtErrors: "none"
179+
caughtErrors: "none",
180+
ignoreUsingDeclarations: true
178181
}],
179182
"@typescript-eslint/no-empty-object-type": ["off"],
180183
"@typescript-eslint/member-ordering": ["warn", {

llama/addon/AddonContext.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -942,11 +942,25 @@ Napi::Value AddonContext::EnsureDraftContextIsCompatibleForSpeculative(const Nap
942942
return info.Env().Undefined();
943943
}
944944

945-
Napi::Value AddonContext::SetLora(const Napi::CallbackInfo& info) {
946-
AddonModelLora* lora = Napi::ObjectWrap<AddonModelLora>::Unwrap(info[0].As<Napi::Object>());
947-
float scale = info[1].As<Napi::Number>().FloatValue();
945+
Napi::Value AddonContext::SetLoras(const Napi::CallbackInfo& info) {
946+
Napi::Array loraArray = info[0].As<Napi::Array>();
947+
Napi::Array scaleArray = info[1].As<Napi::Array>();
948948

949-
llama_set_adapter_lora(ctx, lora->lora_adapter, scale);
949+
std::vector<llama_adapter_lora *> loras;
950+
std::vector<float> scales;
951+
952+
loras.reserve(loraArray.Length());
953+
scales.reserve(scaleArray.Length());
954+
955+
for (size_t i = 0; i < loraArray.Length() && i < scaleArray.Length(); i++) {
956+
AddonModelLora* lora = Napi::ObjectWrap<AddonModelLora>::Unwrap(loraArray.Get(i).As<Napi::Object>());
957+
float scale = scaleArray.Get(i).As<Napi::Number>().FloatValue();
958+
959+
loras.push_back(lora->lora_adapter);
960+
scales.push_back(scale);
961+
}
962+
963+
llama_set_adapters_lora(ctx, loras.data(), loras.size(), scales.data());
950964

951965
return info.Env().Undefined();
952966
}
@@ -977,7 +991,7 @@ void AddonContext::init(Napi::Object exports) {
977991
InstanceMethod("ensureDraftContextIsCompatibleForSpeculative", &AddonContext::EnsureDraftContextIsCompatibleForSpeculative),
978992
InstanceMethod("saveSequenceStateToFile", &AddonContext::SaveSequenceStateToFile),
979993
InstanceMethod("loadSequenceStateFromFile", &AddonContext::LoadSequenceStateFromFile),
980-
InstanceMethod("setLora", &AddonContext::SetLora),
994+
InstanceMethod("setLoras", &AddonContext::SetLoras),
981995
InstanceMethod("dispose", &AddonContext::Dispose),
982996
}
983997
)

llama/addon/AddonContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class AddonContext : public Napi::ObjectWrap<AddonContext> {
5252
Napi::Value PrintTimings(const Napi::CallbackInfo& info);
5353
Napi::Value EnsureDraftContextIsCompatibleForSpeculative(const Napi::CallbackInfo& info);
5454

55-
Napi::Value SetLora(const Napi::CallbackInfo& info);
55+
Napi::Value SetLoras(const Napi::CallbackInfo& info);
5656

5757
static void init(Napi::Object exports);
5858
};

0 commit comments

Comments
 (0)