Skip to content

feat(entity): expose sensor and body tensor reads - #1720

Merged
TATP-233 merged 2 commits into
develop/tensor-runtimefrom
feat/issue-1703-sensor-body-tensor-reads
Sep 29, 2026
Merged

TATP-233 merged 2 commits into
develop/tensor-runtimefrom
feat/issue-1703-sensor-body-tensor-reads

Conversation

@TATP-233

Copy link
Copy Markdown
Collaborator

Summary

  • add the next NpEnv removal P1: tensor-native Manager-Based TorchEnv runtime #1703 Entity tensor facade for explicit named sensor reads
  • add entity-ordered world-frame body tensor reads over the canonical backend track_* sensor contract
  • validate execution capability, exact device, dtype, shape/layout, and finite values while preserving the public SimBackend boundary

Scope boundary

This is the narrow public Entity read API. Broad CPU host-bridge Manager execution must still aggregate these requests into one packed host-bridge plan; it must not call the per-name path from each term.

Validation

  • uv run ruff format src/unilab/base/entity.py tests/envs/mdp/test_joint_position_action.py
  • uv run ruff check src/unilab/base/entity.py tests/envs/mdp/test_joint_position_action.py
  • uv run mypy src/unilab/base/entity.py
  • make check
  • uv run pytest -q tests/base/test_entity_facade.py tests/envs/mdp/test_joint_position_action.py tests/managers tests/envs tests/tasks — 505 passed, 8 skipped

Closes part of #1703

@TATP-233

Copy link
Copy Markdown
Collaborator Author

Validation at head 34cb90b5:

  • local make check: pass (ruff/mypy/pyright; pyright has the existing optional drake import warning)
  • focused suite uv run pytest -q tests/base/test_entity_facade.py tests/envs/mdp/test_joint_position_action.py tests/managers tests/envs tests/tasks: 505 passed, 8 skipped
  • remote Focused CPU tensor profile: pass in 3m5s
  • Gated single-GPU tensor profile: skipped as expected

Scope note: this adds the narrow public per-name Entity facade. Broad host-bridge Manager execution still needs the scene-level packed aggregation from these names and must not call this API per term.

@TATP-233

Copy link
Copy Markdown
Collaborator Author

Review-response update at 3eb0f3d0:

  • normalize device once through torch.device(device); capability negotiation, backend reads, and exact tensor validation now use the same resolved device (fixes the str/unindexed CUDA mismatch risk);
  • split dtype and exact-device validation diagnostics;
  • cache resolved body layouts per requested-name tuple, using the existing strict _readonly_ids path (shape, integer dtype, negative, duplicate checks);
  • fail closed on direct HOST_BRIDGE body tensor reads: CPU execution requires the next scene-owned packed host-bridge plan, so the facade no longer exposes a 4×B scattered-H2D path;
  • fail closed on multi-name HOST_BRIDGE direct sensor reads for the same reason; single-name reads remain the narrow diagnostic path;
  • tests now cover all four body fields, string-device input, host-bridge fail-closed behavior, and a device-resident fake profile.

Remaining accepted follow-ups for the next slice rather than this PR: public UniSim sensor-name capability metadata, entity-qualified body alias negotiation, tensor phase-scoped caching, and the actual scene-owned packed host-bridge plan.

@TATP-233
TATP-233 merged commit dca96fd into develop/tensor-runtime Sep 29, 2026
2 checks passed
@TATP-233
TATP-233 deleted the feat/issue-1703-sensor-body-tensor-reads branch September 29, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant