refactor: 统一序列化层,消除分散的 I/O 路径
- Checkpoint 改为 @dataclass,内聚 save/load 方法 - 提取 save_safetensors/load_safetensors/save_json/load_json 共享工具 - 新增 save_model/load_model_config/load_model_weights 模块函数 - automodel 和 lora 统一委托到 serialization 模块
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import torch
|
||||
@@ -36,7 +37,6 @@ def test_single_process():
|
||||
|
||||
|
||||
def test_checkpoint_with_extra():
|
||||
"""Verify extra keys are saved as individual .pt files and loaded back."""
|
||||
model = torch.nn.Linear(10, 5)
|
||||
optimizer = AdamW(model.parameters(), lr=1e-3)
|
||||
optimizer.step()
|
||||
@@ -52,8 +52,6 @@ def test_checkpoint_with_extra():
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
checkpoint.save(tmpdir)
|
||||
|
||||
import os
|
||||
|
||||
assert os.path.exists(os.path.join(tmpdir, "optimizer.pt"))
|
||||
assert os.path.exists(os.path.join(tmpdir, "scheduler.pt"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user