From 52ef385a6591ba07a98f4699ce287e6b5480b6c9 Mon Sep 17 00:00:00 2001 From: hhhappyshow <1253332472@qq.com> Date: Wed, 18 Nov 2026 12:36:57 +0800 Subject: [PATCH 1/2] fix(entity): slice device-resident packet body fields by their own axes The device-resident branch of SceneTensorReadPlan._read_packet fetched one tracked-body view for the first packet field's aggregate axis and published every body field from that same view. When fields declare different body axes (e.g. a pose-only floor entity is absent from the velocity fields), the published width no longer matched the compiled per-field axes and refresh failed with a shape mismatch. Host-bridge plans compile per-field widths and were unaffected. Select each body field's columns from the shared view by public body name through the existing _packet_body_indices cache; fields whose axes match the first field keep the previous fast path. Found while bringing the G1 navigation raycast task up on the mjwarp backend; host-bridge (mujoco) behavior is unchanged. Co-authored-by: Cursor --- src/unilab/base/entity.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/unilab/base/entity.py b/src/unilab/base/entity.py index 4416168d8..fae584f05 100644 --- a/src/unilab/base/entity.py +++ b/src/unilab/base/entity.py @@ -1124,10 +1124,26 @@ def _read_packet( for name in self._packet_names: if name in self._packet_sensor_owners: raw[name] = backend.get_sensor_view(name, device=self._device) - else: - raw[name] = getattr(body_view, _PACKET_FIELD_BODY_FIELDS[name]).reshape( - backend.num_envs, -1 + continue + block = getattr(body_view, _PACKET_FIELD_BODY_FIELDS[name]) + if tuple(self._packet_body_axes[name]) != tuple( + self._packet_body_axes[body_packet_names[0]] + ): + # Device-resident backends return one tracked-body view + # for the first packet field's aggregate axis. Fields + # with narrower axes (e.g. a pose-only floor body is + # absent from the velocity fields) must select their + # columns from that shared view by public body name; + # host-bridge plans compile per-field widths instead. + requested = tuple( + part.partition("/")[2] if "/" in part else part + for part in self._packet_body_axes[name] ) + columns = self._packet_body_indices( + requested, tuple(body_view.body_names) + ) + block = block[:, columns] + raw[name] = block.reshape(backend.num_envs, -1) except (AttributeError, KeyError, TypeError, ValueError, NotImplementedError) as exc: raise type(exc)( "Manager scene device-resident tensor read on backend " From d316827ab307fcafed8e10179999b52c522d6324 Mon Sep 17 00:00:00 2001 From: hhhappyshow <1253332472@qq.com> Date: Wed, 18 Nov 2026 12:48:21 +0800 Subject: [PATCH 2/2] style: ruff format Co-authored-by: Cursor --- src/unilab/base/entity.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/unilab/base/entity.py b/src/unilab/base/entity.py index fae584f05..95eeab7b3 100644 --- a/src/unilab/base/entity.py +++ b/src/unilab/base/entity.py @@ -1139,9 +1139,7 @@ def _read_packet( part.partition("/")[2] if "/" in part else part for part in self._packet_body_axes[name] ) - columns = self._packet_body_indices( - requested, tuple(body_view.body_names) - ) + columns = self._packet_body_indices(requested, tuple(body_view.body_names)) block = block[:, columns] raw[name] = block.reshape(backend.num_envs, -1) except (AttributeError, KeyError, TypeError, ValueError, NotImplementedError) as exc: