Skip to content

Write OvRTX lidar returns only for due environments - #9229

Open
temiroff wants to merge 2 commits into
isaac-sim:mainfrom
temiroff:atemirov/ovrtx-lidar-env-mask
Open

temiroff wants to merge 2 commits into
isaac-sim:mainfrom
temiroff:atemirov/ovrtx-lidar-env-mask

Conversation

@temiroff

Copy link
Copy Markdown
Contributor

Description

With update_period > 0, OVRTXLidar keeps one sampling clock per environment, but a tiled lidar product traces
every environment and the capture wrote the returns of every environment. Any due environment therefore refreshed
all of them. After a partial reset the clocks drift apart, so environments that were not due received new scans
on other environments' schedules and update_period no longer held per environment.

This PR passes the sensor's outdated mask through render_lidar to the point-cloud copy:

  • copy_dense_lidar_points_kernel returns early for slots whose environment is not due, the same pattern as the
    reset kernel.
  • The CPU-map fallback writes with torch.where, so it adds no GPU-to-CPU sync.
  • Forced captures and update_period == 0 use the all-true mask that SensorBase already allocates.

The capture still traces every tile, because OvRTX cannot render a subset of a tiled product, so this does not
reduce tracing. The existing env_mask.numpy().any() skip is unchanged.

Validation

Linux GPU machine, main at cb71c9b plus this change. Ruff and the changelog check pass.

  • test_ovrtx_renderer_contract.py (114), test_ovrtx_lidar.py (10) and test_ovrtx_renderer_kernels.py (13)
    pass, each file in its own process. The kernel, CPU-fallback and integration tests now include an environment
    that is not due and must keep its previous returns.
  • Probe with 4 environments, physics dt 1/120, update_period=0.1, and environments 1, 2 and 3 reset at steps
    30, 55 and 80: before the change every capture rewrote all four environments; after it each environment's
    points change every 12 steps. Captures stay at about 40 per second, since every tile is still traced.
  • Running the three files in one process fails 2 lidar tests on an ovstage schema-order error; unchanged main
    fails the same way.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with uv run isaaclab --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have validated the changed behavior with focused coverage and applied the test-audit criteria to any test changes
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package (do not edit CHANGELOG.rst or bump package versions — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

Release backport

  • Backport this pull request to the active release branch after it merges into main

A tiled lidar product traces every environment, so any due environment
triggered a capture that overwrote all environments' returns. After a
partial reset this refreshed not-due environments on the reset clock
instead of their own update_period.

Pass the sensor's outdated mask through render_lidar to the point-cloud
copy. The CUDA kernel and the CPU fallback write only the masked tiles.
Forced captures and update_period == 0 use the all-true mask.
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Nov 25, 2026
@temiroff

Copy link
Copy Markdown
Contributor Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Nov 25, 2026
Comment on lines +296 to +297
masked = self.cfg.update_period > 0.0 and not self._force_capture
if masked and not bool(env_mask.numpy().any()):

@huidongc huidongc Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

masked sound weird for the two conditions it represents.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to due_envs_only in a follow-up commit: it is True when only the due environments are written (a positive update_period and no forced capture).

@temiroff
temiroff marked this pull request as ready for review November 26, 2026 17:21
@temiroff
temiroff requested a review from a team November 26, 2026 17:21
@temiroff

Copy link
Copy Markdown
Contributor Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Nov 26, 2026

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isaac Lab Review Bot

Needs attention: Compatibility and deprecation (3), Implementation (1), Style consistency (1), Test quality (1). Other reviewed categories look good.

  • PR description: Correct the non-breaking label; title and validation match selective publication, but fallback allocation costs need reproducible baseline/candidate latency and peak-memory measurements specifying revisions, command/workload, hardware, backend, environment/ray counts, and warmup.
  • Design and architecture: Architecture looks good.
  • Scope and over-engineering: No over-engineering issues.
  • API: API changes look good.
  • Compatibility and deprecation: Breaking changes: mask-free render_lidar and copy_tiled_point_cloud calls and seven-input kernel launches now fail; preserve their all-environment behavior until a warned, documented, tested deprecation transition completes.
  • Implementation: CPU fallback creates three full-sized selection outputs and then copies them into existing buffers; use torch.where with destination out= arguments to remove those allocations and copies.
  • Style consistency: render_lidar requires env_mask without documenting its dtype, shape, or device; specify a boolean (num_envs,) mask on the lidar data device.
  • Test quality: The exact mask assertion checks a mocked private handoff already exercised observably by integration; retain submission checks and assert publication occurred, while keeping distinct kernel and CPU-fallback coverage.

Significant concerns. Posted 6 inline findings.

Automated review; human maintainers own approval decisions.


def copy_tiled_point_cloud(mapped, points: torch.Tensor, intensity: torch.Tensor, valid: torch.Tensor) -> None:
def copy_tiled_point_cloud(
mapped, points: torch.Tensor, intensity: torch.Tensor, valid: torch.Tensor, *, env_mask: wp.array

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Compatibility — Preserve mask-free point-cloud copies

Existing four-argument copy_tiled_point_cloud calls now raise TypeError. Keep omission copying every tile; requiring a mask later needs a warned, documented, tested deprecation transition.

intensity.copy_(signal)
valid.copy_(hits)
due = wp.to_torch(env_mask).unsqueeze(-1)
points.copy_(torch.where(due.unsqueeze(-1), filled, points))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Implementation — Avoid fallback selection temporaries

Each CPU-map capture allocates three full-sized torch.where outputs and copies them into existing buffers. Write each selection directly to its destination with out=.

mapping.unmap(stream=stream)

def render_lidar(self, render_data: OVRTXLidarRenderData, lidar_data: LidarData) -> None:
def render_lidar(self, render_data: OVRTXLidarRenderData, lidar_data: LidarData, *, env_mask: wp.array) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Compatibility — Preserve mask-free lidar captures

Existing two-argument render_lidar calls now raise TypeError. Make omission retain all-environment publication; requiring the mask later needs a warned, documented, tested deprecation transition.

captures, so including it here would replace its buffers with a scan from a stale pose.
Camera products stay on the camera step. A lidar needs the point cloud immediately, so this
submission waits.
submission waits. The product traces every tile; only the tiles in ``env_mask`` are written.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Style Consistency — Specify the required mask

The public method now requires env_mask, but its docstring gives no dtype, shape, or device requirement. Document the boolean (num_envs,) mask on the lidar data device.

intensity_out: wp.array(dtype=wp.float32),
valid: wp.array(dtype=wp.bool),
spherical: bool,
env_mask: wp.array(dtype=wp.bool),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Compatibility — Preserve the existing kernel launch

Existing seven-input launches no longer match this public kernel. Keep that launch functional and add a masked variant; retire the original only through a documented, warned, tested transition.

renderer.render_lidar(lidar, data, env_mask=env_mask)
native.step.assert_called_with(render_products={lidar.render_product_path}, delta_time=0.1)
publish.assert_called_once_with(lidar, native.step.return_value, data)
publish.assert_called_once_with(lidar, native.step.return_value, data, env_mask=env_mask)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Warning · Test Quality — Drop private mask forwarding assertion

The new exact mask assertion checks a mocked private handoff, while integration checks its observable effect. Retain the separate-step assertion and check only that publication occurred.

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5 · Fix the CPU-map fallback's stream ordering before merging so due scans cannot be skipped.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change is limited to OVRTX lidar sampling across simulation environments.

Fix the CPU-map fallback's stream ordering before merging so due scans cannot be skipped.

Findings

  1. P1 Due scans can be skipped ▶

Summary

This PR carries the per-environment sampling mask through lidar capture to the output copies.

  • Periodic lidar scans update only environments that are due.

Reviews (1) · Last reviewed commit: "Rename the OvRTX lidar due-environment f..." · Reviewed by Greptile

Comment on lines +188 to +191
due = wp.to_torch(env_mask).unsqueeze(-1)
points.copy_(torch.where(due.unsqueeze(-1), filled, points))
intensity.copy_(torch.where(due, signal, intensity))
valid.copy_(torch.where(due, hits, valid))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Due scans can be skipped

If Torch and Warp use different CUDA streams, the CPU-map fallback can read env_mask after SensorBase clears it. The three torch.where calls queue reads on Torch's current stream, but the caller immediately queues the clear on Warp's stream without waiting for those reads.

A due environment can keep old returns or get mismatched points, intensity, and validity, while its sampling clock is marked updated. Run the fallback copies on Warp's consuming stream too, so they read the mask before it is cleared.

This branch has not been deployed

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

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants