Repository navigation
[Roadmap#2583] 消费 unisim.utils.math 统一旋转原语 + 训练热路径 GPU-resident 同步消除 - #2586
Merged
Merged
Conversation
…uplicates Remove src/unilab/base/rotation.py and motion_tracking tensor_rotation.py; all rotation/quaternion call sites now consume unisim.math through the thin re-export package src/unilab/math (hard cut, no shims). Inline duplicates in envs/mdp (observations, events, ray_observation) and motion_loader converge on the shared primitives. Add host-rotation-sync architecture guard tests and ADR-0022 recording unisim as the sole owner of math primitives. Refs #2583
Replace the src/unilab/math package (rotation_numpy/rotation_tensor modules with identical names) with a single thin shim src/unilab/utils/math.py re-exporting unisim.utils.math: unprefixed names are Torch operators (mjlab-aligned), NumPy counterparts carry the np_ prefix. Update all call sites, docs, and ADR-0022 accordingly. Refs #2583
Audit-driven GPU-resident fixes (sync probe verified against HEAD baseline): - terminations: route _state_tensor finite checks through the env's deferred finite verdict instead of per-step blocking bool() - circular buffer: replace first-push bool(any()) probe with host-side row counting; steady-state append is sync-free - torch_env: drop redundant done-mask re-evaluation and timing float() - event manager: host lower-bound gating for interval triggers (no device read during quiet windows), RNG consumption unchanged - events.ApplyBodyImpulse: host mirrors for cooldown/sustain windows - entity wrench validation wired into the deferred verdict recorder - reset_selectors: fold resolve_reset_env_ids bounds checks into one device reduction - reset_state: verdict sink for payload finite checks; fix wrong torch.equal no-sync comment; propagate packed-reset validation mode (strict when eager, deferred when the env defers) - termination manager: drain reset metrics at the poll boundary - env poll_finite_validation now also drains the backend packed-reset verdict, closing the deferred-validation loop Refs #2583
…re to 2.7.0 Finite checks now accumulate device-side and publish at the fixed poll boundary by default (interval unchanged at 1; training owner YAMLs keep their explicit interval 32). Tests covering the eager fail-closed paths pin defer_finite_validation=False explicitly. Pin unisim-core==2.7.0 (unisim.utils.math + packed reset verdict API); ROCm track updated in sync (pyproject.rocm.toml + uv.rocm.lock). Refs #2583
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
实现 #2583 的 unilab 侧(Child 1+3+4 合并):删除全部本地四元数/旋转重复实现,统一经薄 shim 消费
unisim.utils.math;并按审计消除训练热路径的强制 host 同步点。依赖已就绪:
unisim-core==2.7.0已发布(unilabsim/unisim#525 合入),本分支 pin 已升至 2.7.0(含pyproject.rocm.toml+uv.rocm.lock同步),CI 可独立验证。改动
数学原语收敛
src/unilab/base/rotation.py(479 行)与tasks/motion_tracking/common/tensor_rotation.py(143 行)src/unilab/utils/math.py:from unisim.utils.math import ...纯转发 39 个名字,零逻辑;无前缀 = Torch,np_= NumPyenvs/mdp/{observations,events,ray_observation,rewards,terminations}、velocity_command、base/{entity,reset_state}、tasks/motion_tracking/common/{manager_terms,motion_loader}、scripts/motion、testsChild 4 防 latent 同步风险
tests/architecture/test_host_rotation_sync_boundary.py:热路径目录禁止_host_root_link_*引用、禁止.cpu()/.numpy()后 10 行内 quat 调用_host_root_link_lin/ang_vel_b训练热路径零调用热路径 GPU-resident 修复(审计驱动,同步探针实测对照基线)
_state_tensor有限性校验接入 deferred verdict(每步 2→0 次同步)torch.equal错误注释poll_finite_validation联动 packed-reset verdict(eager→strict / defer→deferred)并在 poll 边界 drain,闭环无静默锁存defer_finite_validation默认翻转为 True:有限性检查默认设备侧累积、固定 poll 边界发布(interval 默认仍为 1,四个训练 owner YAML 保持显式 32);eager 路径测试显式 pin False。CUDA profiler 实证:19 个 torch 原语 workload 零 memcpy/memset 事件,无新增 D2H/H2D。
验证
make test-all(对 PyPI 发行的 unisim-core 2.7.0):2930 passed / 0 failed,ruff / mypy / pyright(0 errors),benchmark smoke 35/35 + 36/36rg "def (quat_mul|quat_apply|quat_apply_inverse|quat_from_euler_xyz)" src/unilab零命中附带
Refs #2583