feat(iOS): 更新MNN后端模型配置优化性能 将MNN主模型从Qwen3.5-4B(~2.64GiB)降级为Qwen3.5-2B(~1.1GiB),因为4B版本 实测运行过慢,影响用户体验。iPhone17+/SME2设备使用2B模型,保留MLX 兜底方案用于模拟器和备用场景,确保AI推理性能和存储效率的平衡。 ```
70 lines
2.3 KiB
Swift
70 lines
2.3 KiB
Swift
import Testing
|
|
import Foundation
|
|
@testable import 康康
|
|
|
|
struct ModelManifestTests {
|
|
|
|
@Test func llmHasTenFunctionalFiles() {
|
|
#expect(ModelManifest.files(for: .llm).count == 10)
|
|
}
|
|
|
|
@Test func vlHasFourteenFunctionalFiles() {
|
|
#expect(ModelManifest.files(for: .vl).count == 14)
|
|
}
|
|
|
|
@Test func llmTotalBytesMatchesManifest() {
|
|
#expect(ModelManifest.totalBytes(for: .llm) == 1_749_079_691)
|
|
}
|
|
|
|
@Test func vlTotalBytesMatchesManifest() {
|
|
#expect(ModelManifest.totalBytes(for: .vl) == 3_109_729_929)
|
|
}
|
|
|
|
@Test func mnnHasSixFunctionalFiles() {
|
|
#expect(ModelManifest.files(for: .mnnLLM).count == 6)
|
|
}
|
|
|
|
@Test func mnnTotalBytesMatchesManifest() {
|
|
#expect(ModelManifest.totalBytes(for: .mnnLLM) == 1_185_759_005)
|
|
}
|
|
|
|
@Test func mnnHasEssentialRuntimeFiles() {
|
|
let names = ModelManifest.files(for: .mnnLLM).map(\.path)
|
|
#expect(names.contains("config.json"))
|
|
#expect(names.contains("llm.mnn"))
|
|
#expect(names.contains("llm.mnn.weight"))
|
|
#expect(names.contains("tokenizer.txt"))
|
|
}
|
|
|
|
@Test func mnnFileURLUsesRepoPath() {
|
|
let file = ModelFile(path: "config.json", bytes: 652)
|
|
let url = ModelManifest.fileURL(for: .mnnLLM, file: file)
|
|
#expect(url.absoluteString == "https://file.myv0.com/Qwen3.5-2B-MNN/config.json")
|
|
}
|
|
|
|
@Test func excludesReadmeAndGitattributes() {
|
|
for kind in [ModelKind.llm, .vl] {
|
|
let names = ModelManifest.files(for: kind).map(\.path)
|
|
#expect(!names.contains("README.md"))
|
|
#expect(!names.contains(".gitattributes"))
|
|
}
|
|
}
|
|
|
|
@Test func includesEssentialFiles() {
|
|
let llm = ModelManifest.files(for: .llm).map(\.path)
|
|
#expect(llm.contains("config.json"))
|
|
#expect(llm.contains("model.safetensors"))
|
|
#expect(llm.contains("tokenizer.json"))
|
|
|
|
let vl = ModelManifest.files(for: .vl).map(\.path)
|
|
#expect(vl.contains("preprocessor_config.json")) // VL 拍照识别必需
|
|
#expect(vl.contains("model.safetensors"))
|
|
}
|
|
|
|
@Test func fileURLIsBaseSlashRepoSlashPath() {
|
|
let file = ModelFile(path: "config.json", bytes: 3_113)
|
|
let url = ModelManifest.fileURL(for: .llm, file: file)
|
|
#expect(url.absoluteString == "https://file.myv0.com/Qwen3.5-2B-4bit/config.json")
|
|
}
|
|
}
|