-
Notifications
You must be signed in to change notification settings - Fork 27
PERF: G1Flat training throughput — contact sensor pooled reset + event sync elimination #685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
51c07e1
9cdba4d
a95a655
c37e98d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| """interval_step==1 快路径:functor 收到显式全量 ID 张量(非 None)。""" | ||
| import torch | ||
|
|
||
| from embodichain.lab.gym.envs.managers.event_manager import EventManager | ||
|
|
||
|
|
||
| class _RecordingFunctor: | ||
| """记录 env_ids 的哑 functor。""" | ||
|
|
||
| def __init__(self): | ||
| self.calls = [] | ||
|
|
||
| def __call__(self, env, env_ids, **kwargs): | ||
| self.calls.append( | ||
| None if env_ids is None else env_ids.clone() | ||
| ) | ||
|
|
||
|
|
||
| def test_interval_one_fastpath_passes_explicit_all_row_ids(monkeypatch): | ||
| """interval_step==1 且非 global:functor 收到全量 ID 张量(非 None)。""" | ||
| manager = EventManager.__new__(EventManager) | ||
| manager._env = object() | ||
| manager._seed = None | ||
|
|
||
| num_envs = 4096 | ||
| counter = torch.zeros(num_envs, dtype=torch.long, device="cpu") | ||
| manager._interval_functor_step_count = [counter] | ||
|
|
||
| class _Cfg: | ||
| is_global = False | ||
| interval_step = 1 | ||
|
|
||
| manager._mode_functor_names = {"interval": ["push_robot"]} | ||
| manager._mode_functor_cfgs = {"interval": [_Cfg()]} | ||
|
|
||
| # 拦截 _call_event_functor,记录传入的 env_ids | ||
| received = [] | ||
| monkeypatch.setattr( | ||
| manager, "_call_event_functor", | ||
| lambda mode, name, cfg, env, ids: received.append(ids), | ||
| ) | ||
|
|
||
| manager.apply(mode="interval") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test calls Context Used: CLAUDE.md (source) Prompt To Fix With AIThis is a comment left during a code review.
Path: tests/gym/envs/managers/test_event_manager_interval_fastpath.py
Line: 43
Comment:
**Cache reuse remains untested**
The test calls `apply()` only once, so it would pass if the interval-one path went back to allocating a new ID tensor on every control step. The repository requires focused tests that prove new production behavior. Assert that successive calls reuse the cached tensor to protect this throughput change before merging.
**Context Used:** CLAUDE.md ([source](https://github.com/dexforce/embodichain/blob/main/CLAUDE.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
|
|
||
| assert len(received) == 1 | ||
| ids = received[0] | ||
| assert ids is not None, "快路径传了 None——functor 的 len(env_ids) 会崩" | ||
| assert ids.shape[0] == num_envs | ||
| assert ids.dtype == torch.long | ||
| assert torch.equal(ids, torch.arange(num_envs, dtype=torch.long)) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new file omits the required DexForce 2021–2026 Apache 2.0 copyright header and
from __future__ import annotations. The multilineself.calls.appendat lines 14–16 also needs the repository-required Black formatting. These requirements must be satisfied before merging.Context Used: CLAUDE.md (source)
Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!