Skip to content

跨边界重复工具模块需明确唯一属主(nan_guard/tensor/seed/device) #1586

Description

@TATP-233

背景

上下游代码精简后(UniLab 侧 + unilab-rl 1.2.1 侧),以下模块在边界两侧各存一份:

  • src/unilab/utils/nan_guard.py 与 uni_rl/utils/nan_guard.py 逐字节相同;uni_rl 1.2.1 的 worker 在 offpolicy/worker.py:234-240、appo/worker.py:154-158 构造 uni_rl 侧的 NanGuard,UniLab 在 src/unilab/training/run.py:96-104 构造自己的副本。当前靠鸭子类型工作,任何跨边界 isinstance 检查都会静默失败。
  • src/unilab/utils/tensor.py 与 uni_rl/utils/tensor.py 逐字节相同。
  • seed.py / device.py 近似重复(TrainingSeedInfo、resolve_training_seed、get_default_device 等)。
  • uni_rl/utils/device.py 的 resolve_backend_process_device/configure_backend_process_device 注明 "Ported from UniLab's unilab.base.process_device, issue [uni-rl] env 契约解耦:uni_rl 对 unilab 的 import 清零 #1479",两侧语义可独立漂移。

现有边界守卫 tests/test_library_import_boundary.py 只禁止重定义 5 个观测相关符号,以上重复完全无防护。AGENTS.md 声明 src/unilab/utils/ 是 transition shim,与现状不符。

建议

为每个模块明确唯一属主(uni_rl 不能 import UniLab,方向需要决策),删除另一侧副本,并扩展边界守卫测试覆盖新的属主清单。

证据

审计于 unisim-core 1.4.2 / unilab-rl 1.2.1 升级后进行;重复清单与调用点见上文 file:line。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions