Skip to content

Commit abb710f

Browse files
committed
qwen working with smoke tests
1 parent 5f84f15 commit abb710f

3 files changed

Lines changed: 41 additions & 14 deletions

File tree

llm-inference/qwen/src/commonMain/kotlin/sk/ainet/models/qwen/QwenNetworkLoader.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ import kotlin.jvm.JvmName
3838
* val model = QwenNetworkLoader.fromWeights(llamaWeights)
3939
* ```
4040
*/
41+
@PublishedApi
42+
internal val QWEN_ARCHITECTURES: Set<String> = setOf("qwen2", "qwen3")
43+
4144
public class QwenNetworkLoader @PublishedApi internal constructor(
4245
@PublishedApi internal val weightsProvider: WeightsProvider,
4346
@PublishedApi internal val debug: Boolean = false
@@ -115,11 +118,19 @@ public class QwenNetworkLoader @PublishedApi internal constructor(
115118
): Module<T, V> {
116119
val weights: LlamaWeights<T, V> = when (val wp = weightsProvider) {
117120
is WeightsProvider.GgufSource -> {
118-
val loader = LlamaWeightLoader(wp.sourceProvider, quantPolicy = wp.quantPolicy)
121+
val loader = LlamaWeightLoader(
122+
wp.sourceProvider,
123+
quantPolicy = wp.quantPolicy,
124+
acceptedArchitectures = QWEN_ARCHITECTURES
125+
)
119126
loader.loadToMap<T, V>(ctx)
120127
}
121128
is WeightsProvider.GgufRandomAccess -> {
122-
val loader = LlamaWeightLoader(wp.randomAccessProvider, quantPolicy = wp.quantPolicy)
129+
val loader = LlamaWeightLoader(
130+
wp.randomAccessProvider,
131+
quantPolicy = wp.quantPolicy,
132+
acceptedArchitectures = QWEN_ARCHITECTURES
133+
)
123134
loader.loadToMapStreaming<T, V>(ctx)
124135
}
125136
is WeightsProvider.SafeTensors -> {

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ include("llm-inference:bert")
2525
include("llm-inference:voxtral")
2626
include("llm-runtime:kllama")
2727
include("llm-runtime:kgemma")
28+
include("llm-runtime:kqwen")
2829
include("llm-runtime:kapertus")
2930
include("llm-performance")
3031
include("llm-apps:kllama-cli")

tests/smoke/smoke-test.sh

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
set -euo pipefail
2121

2222
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
23+
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
24+
MODELS_ROOT="${MODELS_ROOT:-$REPO_ROOT}"
2325
GRADLE="./gradlew --no-configuration-cache"
2426

2527
RED='\033[0;31m'
@@ -37,30 +39,42 @@ separator() {
3739
# Maps runner name → Gradle task
3840
runner_task() {
3941
case "$1" in
40-
kllama) echo ":llm-apps:kllama-cli:run" ;;
41-
kgemma) echo ":llm-runtime:kgemma:jvmRun" ;;
42-
kbert) echo ":llm-apps:kbert-cli:run" ;;
43-
*) echo "UNKNOWN"; return 1 ;;
42+
kllama) echo ":llm-apps:kllama-cli:run" ;;
43+
kgemma) echo ":llm-runtime:kgemma:jvmRun" ;;
44+
kqwen) echo ":llm-runtime:kqwen:jvmRun" ;;
45+
kbert) echo ":llm-apps:kbert-cli:run" ;;
46+
kapertus) echo ":llm-apps:kapertus-cli:run" ;;
47+
kvoxtral) echo ":llm-apps:kvoxtral-cli:run" ;;
48+
*) echo "UNKNOWN"; return 1 ;;
4449
esac
4550
}
4651

4752
# Maps runner name → compile task
4853
runner_compile_task() {
4954
case "$1" in
50-
kllama) echo ":llm-apps:kllama-cli:classes" ;;
51-
kgemma) echo ":llm-runtime:kgemma:jvmMainClasses" ;;
52-
kbert) echo ":llm-apps:kbert-cli:mainClasses" ;;
53-
*) echo "UNKNOWN"; return 1 ;;
55+
kllama) echo ":llm-apps:kllama-cli:classes" ;;
56+
kgemma) echo ":llm-runtime:kgemma:jvmMainClasses" ;;
57+
kqwen) echo ":llm-runtime:kqwen:jvmMainClasses" ;;
58+
kbert) echo ":llm-apps:kbert-cli:mainClasses" ;;
59+
kapertus) echo ":llm-apps:kapertus-cli:classes" ;;
60+
kvoxtral) echo ":llm-apps:kvoxtral-cli:classes" ;;
61+
*) echo "UNKNOWN"; return 1 ;;
5462
esac
5563
}
5664

5765
# Builds Gradle args string based on the runner type
5866
runner_args() {
59-
local runner="$1" model="$2" prompt="$3" steps="$4" temp="$5" doc="${6:-}"
67+
local runner="$1" model="$2" prompt="$3" steps="$4" temp="$5" doc="${6:-}" output="${7:-}"
6068

6169
case "$runner" in
62-
kllama) echo "-m ${model} -s ${steps} -k ${temp} \"${prompt}\"" ;;
63-
kgemma) echo "${model} \"${prompt}\" ${steps} ${temp}" ;;
70+
kllama) echo "-m ${model} -s ${steps} -k ${temp} \"${prompt}\"" ;;
71+
kgemma) echo "${model} \"${prompt}\" ${steps} ${temp}" ;;
72+
kqwen) echo "${model} \"${prompt}\" ${steps} ${temp}" ;;
73+
kapertus) echo "-m ${model} -s ${steps} -k ${temp} \"${prompt}\"" ;;
74+
kvoxtral)
75+
local out="${output:-smoke-test-output.wav}"
76+
echo "--model ${model} --output ${out} \"${prompt}\""
77+
;;
6478
kbert)
6579
if [[ -n "$doc" ]]; then
6680
echo "${model} \"${prompt}\" \"${doc}\""
@@ -182,6 +196,7 @@ print(f'M_PROMPT={repr(m.get(\"prompt\", d.get(\"prompt\", \"The capital of Fran
182196
print(f'M_STEPS={m.get(\"steps\", d.get(\"steps\", 32))}')
183197
print(f'M_TEMP={m.get(\"temperature\", d.get(\"temperature\", 0.0))}')
184198
print(f'M_DOC={repr(m.get(\"doc\", \"\"))}')
199+
print(f'M_OUTPUT={repr(m.get(\"output\", \"\"))}')
185200
")"
186201

187202
M_MODEL=$(expand_path "$M_MODEL")
@@ -207,7 +222,7 @@ print(f'M_DOC={repr(m.get(\"doc\", \"\"))}')
207222
fi
208223

209224
task=$(runner_task "$M_RUNNER")
210-
args=$(runner_args "$M_RUNNER" "$M_MODEL" "$M_PROMPT" "$M_STEPS" "$M_TEMP" "$M_DOC")
225+
args=$(runner_args "$M_RUNNER" "$M_MODEL" "$M_PROMPT" "$M_STEPS" "$M_TEMP" "$M_DOC" "$M_OUTPUT")
211226

212227
start_ts=$(python3 -c 'import time; print(time.time())')
213228
output_file=$(mktemp)

0 commit comments

Comments
 (0)