```
feat(debug): 添加模型导入功能并修复模拟器GPU初始化问题 - 在DebugAIRunner中添加文件导入器,支持用户选择并导入LLM模型文件夹 - 添加导入状态管理和错误提示功能 - 修复iOS模拟器环境下MLX GPU stream初始化崩溃问题,强制使用CPU模式 - 添加UniformTypeIdentifiers导入以支持文件选择功能 ```
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Foundation
|
||||
import MLX
|
||||
import MLXLLM
|
||||
import MLXLMCommon
|
||||
|
||||
@@ -13,6 +14,12 @@ actor LLMSession {
|
||||
|
||||
/// 从本地目录加载模型(包含 config.json + weights + tokenizer)。
|
||||
static func load(folderURL: URL) async throws -> LLMSession {
|
||||
#if targetEnvironment(simulator)
|
||||
// MLX 的 iOS Simulator GPU stream 初始化会在部分 Metal backend 路径中 abort。
|
||||
// 模拟器只用于功能调试,强制走 CPU;真机仍保留默认 GPU/ANE 相关路径。
|
||||
Device.setDefault(device: .cpu)
|
||||
#endif
|
||||
|
||||
let configuration = ModelConfiguration(directory: folderURL)
|
||||
let container = try await LLMModelFactory.shared.loadContainer(
|
||||
configuration: configuration
|
||||
|
||||
Reference in New Issue
Block a user