Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

RecursionError when initializing KumoTabular with pretrained=True after #1153

未关闭 适合新手
#1,156 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python, pytorch

调研方向

从 sdm/models/kumo/tabular/model.py 开始,查看 KumoTabular 构造函数约第 139 行,其中 pretrained 分支将 _load_from_pretrained() 的返回值赋给 self.models[task]。阅读该方法,确认它返回 self 并且是原地加载权重。删除这一赋值,使调用只加载权重,然后使用 pretrained=True 构造模型,确认 self.eval() 能够完成。当该构造成功且没有 RecursionError 时即完成;现有的表格模型测试也应通过。

由索引模型根据 Issue 内容生成。

描述

Description

Initializing KumoTabular with pretrained=True raises a
RecursionError during the constructor's self.eval() call.

This appears to be a regression introduced by #1153.

Reproduction

model = sdm.models.KumoTabular(
    task="classification",
    size="large",
    pretrained=True,
    device=device,
)

Actual behavior

Initialization fails with:

File sdm/models/kumo/tabular/model.py:139, in KumoTabular.__init__
    self.eval()

File torch/nn/modules/module.py, in Module.eval
    return self.train(False)

RecursionError: maximum recursion depth exceeded

Expected behavior

The pretrained model should initialize successfully in evaluation mode.

Suspected cause

#1153 changed _load_from_pretrained() to return self rather than
an individual task model, but the constructor still assigns its return
value to a child module:

self.models[task] = self._load_from_pretrained(size, device=device)

This effectively executes self.models[task] = self, creating a circular
module reference:

KumoTabular -> models -> KumoTabular

The subsequent self.eval() recursively traverses this cycle.

Suggested fix

Remove the assignment in the constructor:

 if pretrained:
-    self.models[task] = self._load_from_pretrained(size, device=device)
+    self._load_from_pretrained(size, device=device)

The loader already loads the weights into each task model in place via
model.load_state_dict(ckpt, assign=True).

Environment

  • Python: 3.12
  • Installation: local source checkout
  • Related PR: #1153
主要语言
Python
星标
358
派生
33
平均合并
1 天 7 小时
30 天内合并 PR
182

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA/structured-data-models 的其他 Issue

查看 NVIDIA/structured-data-models 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。