[server] unpickle-time recursion in starlette State / pydantic MockValSer; tinker request types fail pydantic validation (NameError LossFnInputs)
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
Checklist / 检查清单
- I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。
Bug Description / Bug 描述
Tinker 兼容网关(server)在本环境两类必现故障:
-
cloudpickle 反序列化过程中,starlette State.getattr 与 pydantic
MockValSer.getattr 访问未填充的 slot(_state / _attempt_rebuild)→ 无限递归
/ "AttributeError: MockValSer unavailable (item='validate_python')"。 -
训练请求体校验 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 / 如何复现
- 启动 twinkle server(qwen3.5 模型,lora train_mode),healthz 正常。
- POST /api/v1/forward_backward(Tinker 协议,ForwardBackwardRequest):
网关侧 pydantic 校验抛 NameError: name 'LossFnInputs' is not defined。 - 反序列化路径触发 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 协议闭环。
- 主要语言
- Python
- 星标
- 270
- 派生
- 68
- 平均合并
- 2 天 16 小时
- 30 天内合并 PR
- 38
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelscope/twinkle 的其他 Issue
-
难度 5/5 一周以上 新手友好度 25/100
modelscope/twinkle#429 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 55/100
modelscope/twinkle#410 ·
维护者通常 2 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 55/100
modelscope/twinkle#408 ·
维护者通常 2 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 66/100
modelscope/twinkle#407 ·
维护者通常 2 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 15/100
modelscope/twinkle#319 · 5 条评论 ·
维护者通常 2 天内回复
查看 modelscope/twinkle 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
AIR-Bench Foundation reads the first letter of the word after "answer" as the model's choice可能已有人在做 @beartester34 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
modelscope/evalscope#2330 ·
维护者通常 1 天内回复
-
Distribution plot crashes when a numeric feature is constant in the train or test set可能已有人在做 @adembilge 今天认领。 未关闭bug good first issue
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 10 天内回复
-
难度 1/5 1-3 小时 新手友好度 85/100
维护者通常 2 天内回复
-
namespace team:operations
难度 2/5 1-3 小时 新手友好度 60/100
EclipseFdn/open-vsx.org#16738 ·
维护者通常 1 天内回复