fix(模型): 修正本地 guard 模型设备加载
将示例配置的 guard 模型设备改为 CPU,匹配当前 CPU 版 PyTorch 环境。使用 Transformers 的 dtype 参数替代已弃用的 torch_dtype,消除启动警告并保持模型加载流程正常。
This commit is contained in:
1 parent
e880d5cd62
commit
7652641333
2 files changed
+3
-3
No files matched your search
+1
-1
@@ -18,7 +18,7 @@ llm:
|
|||||||
- id: guard_model
|
- id: guard_model
|
||||||
type: guard
|
type: guard
|
||||||
file: models/guard_model
|
file: models/guard_model
|
||||||
load: {device: cuda}
|
load: {device: cpu}
|
||||||
limits:
|
limits:
|
||||||
max_input_tokens: 4096
|
max_input_tokens: 4096
|
||||||
max_new_tokens: 32
|
max_new_tokens: 32
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ def guard_worker_main(
|
|||||||
)
|
)
|
||||||
stage = "load_model"
|
stage = "load_model"
|
||||||
dtype_name = load.get("dtype", "auto")
|
dtype_name = load.get("dtype", "auto")
|
||||||
torch_dtype = "auto" if dtype_name == "auto" else getattr(torch, dtype_name)
|
dtype = "auto" if dtype_name == "auto" else getattr(torch, dtype_name)
|
||||||
device = load.get("device", "cpu")
|
device = load.get("device", "cpu")
|
||||||
model = AutoModelForCausalLM.from_pretrained(
|
model = AutoModelForCausalLM.from_pretrained(
|
||||||
model_path,
|
model_path,
|
||||||
torch_dtype=torch_dtype,
|
dtype=dtype,
|
||||||
**hub_options,
|
**hub_options,
|
||||||
)
|
)
|
||||||
stage = "move_to_device"
|
stage = "move_to_device"
|
||||||
|
|||||||
Reference in new issue
Block a user