[server] unpickle-time recursion in starlette State / pydantic MockValSer; tinker request types fail pydantic validation (NameError LossFnInputs)

Đang mở
#411 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
22/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
api, backend

Hướng nghiên cứu

Start by tracing the server’s /api/v1/forward_backward request validation and the pickle deserialization path described in the report. Review the proposed server/_compat_pickle.py changes and verify how the Tinker dataclasses, LossFnInputs, and TensorData reach Pydantic; the issue reports no file or test path. Done means both reported failures are handled and the ForwardBackwardRequest protocol flow validates through optim_step.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Checklist / 检查清单
  • I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。
Bug Description / Bug 描述

Tinker 兼容网关(server)在本环境两类必现故障:

  1. cloudpickle 反序列化过程中,starlette State.getattr 与 pydantic
    MockValSer.getattr 访问未填充的 slot(_state / _attempt_rebuild)→ 无限递归
    / "AttributeError: MockValSer unavailable (item='validate_python')"。

  2. 训练请求体校验 ForwardBackwardRequest 失败:"NameError: name 'LossFnInputs' is
    not defined"。根因:tinker SDK 的请求类型是 stdlib dataclass 且 module 被改写
    为 'tinker',pydantic 按 tinker 包 namespace 解析字符串注解,而该 namespace 缺
    LossFnInputs / Optional / np 等名字;且 TensorData 含 np.ndarray 字段,pydantic
    无法生成 core schema。

How to Reproduce / 如何复现
  1. 启动 twinkle server(qwen3.5 模型,lora train_mode),healthz 正常。
  2. POST /api/v1/forward_backward(Tinker 协议,ForwardBackwardRequest):
    网关侧 pydantic 校验抛 NameError: name 'LossFnInputs' is not defined。
  3. 反序列化路径触发 State/MockValSer 自递归(AttributeError: MockValSer unavailable)。

期望:server 在 FastAPI body 校验前应用防护;或 tinker SDK 类型可被 pydantic 校验
(若认为属 tinker SDK 责任,建议 twinkle 侧文档说明需要的最小兼容层)。

Additional Information / 补充信息
  • twinkle: dev-swift-v5 @ dd3d68f;pydantic 2.11.7, starlette(当前 release), tinker SDK
  • Hardware: Ascend910 x2, torch_npu 2.10.0.post7
  • 我们提交了 server/_compat_pickle.py 补丁(import 时生效,_LazyModule 替换之前挂载):
    ① State/MockValSer getattr 防护 ② tinker namespace 注入 ③ TensorData
    get_pydantic_core_schema。验证:TypeAdapter(ForwardBackwardRequest) 校验通过,
    create_model → forward_backward → optim_step 协议闭环。
Ngôn ngữ chính
Python
Star
270
Fork
68
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
38

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelscope/twinkle

Tất cả issue của modelscope/twinkle

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.