Skip to content

[Interactive Drive] Annotate nvtx and Optimize#382

Open
ArielG-NV wants to merge 4 commits into
NVIDIA:mainfrom
ArielG-NV:annotate-nvtx-and-optimize
Open

[Interactive Drive] Annotate nvtx and Optimize#382
ArielG-NV wants to merge 4 commits into
NVIDIA:mainfrom
ArielG-NV:annotate-nvtx-and-optimize

Conversation

@ArielG-NV

Copy link
Copy Markdown
Collaborator

Changes:

Reduce BEV waiting by delaying BEV by 1 chunk. Visually this looks better since it looks like GoogleMaps in a car (slightly behind real life, floating feeling). This is better for perf since we don't need to wait/worry on our BEV, we had a whole 8 frames to build the BEV+HUD

Delete things in a different order due to nuance in how they cause syncing (overlap)

Remove some unneeded cuda-stream passing (which introduced long cuda sync points which don't do anything)

Remove the python-GIL on code that does not need it

Add NVTX annotations & nsys guide so that we have an easier time in exploring profiler driven optimizations in the future

Reduce BEV waiting by delaying BEV by 1 chunk. Visually this looks better since it looks like GoogleMaps in a car (slightly behind real life, floating feeling). This is better for perf since we don't need to wait/worry on our BEV, we had a whole 8 frames to build the BEV+HUD

delete things in a different order due to nuance in how they cause syncing (overlap)

remove some unneeded cuda-stream passing (which introduced long cuda sync points which don't do anything)

remove the python-GIL on code that does not need it
@copy-pr-bot

copy-pr-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR introduces NVTX profiling annotations across the Interactive Drive pipeline, offloads BEV panel image building and MJPEG BEV encoding to background thread pools, and decouples BEV rendering from the RGB critical path by delivering BEV one chunk behind RGB (eliminating the present-side wait). It also removes unnecessary cuda_stream forwarding to submit_command_buffer and adds present-interval percentile stats to the profiling window.

  • Lagged BEV pipeline (rasterizer.py): render_chunk is split into render_rgb_frames + render_bev_frames + build_chunk; LudusConditionRasterizer now polls a _pending_bev future so BEV rendering never blocks RGB delivery.
  • Async BEV panel (slangpy_hud_presenter.py): BEV is stored as a lazy source and processed by a single-worker thread pool; cache invalidation is epoch + generation keyed; close path shuts down the executor cleanly.
  • Streaming BEV offload (streaming_presenter.py): JPEG BEV encoding moves to a dedicated executor with frame-drop-on-busy semantics; prepare_frame is added to mirror the SlangPy prefetch path.

Confidence Score: 4/5

Safe to merge after verifying the test failure and the two dead attributes in the HUD presenter.

One newly added test asserts BEV prefetch deduplication via source_group_key that the production prepare_frame does not implement — the test will fail as written. The rest of the changes are correct and well-tested.

integrations/omnidreams/tests/interactive_drive/test_presenter.py (failing test) and integrations/omnidreams/omnidreams/interactive_drive/slangpy_hud_presenter.py (two unread attributes).

Important Files Changed

Filename Overview
integrations/omnidreams/omnidreams/interactive_drive/slangpy_hud_presenter.py Major refactor of BEV panel rendering: lazy source tracking, async thread-pool build, epoch-based cache invalidation, and _bev_panel_future management. Contains two dead attributes (_bev_panel_target_size, _prepared_bev_source_key) and the existing self.bev_panel_future = None typo (flagged in a prior review thread).
integrations/omnidreams/omnidreams/interactive_drive/rasterizer.py Splits render_chunk into render_rgb_frames + render_bev_frames + build_chunk; adds 1-chunk-lagged BEV pipeline in LudusConditionRasterizer using _pending_bev future polling. Logic appears correct and well-tested by the new rasterizer tests.
integrations/omnidreams/tests/interactive_drive/test_presenter.py Adds several new presenter tests. One new test asserts BEV prefetch deduplication via source_group_key that the production prepare_frame does not implement — this test will fail.
integrations/omnidreams/omnidreams/interactive_drive/streaming_presenter.py Offloads BEV JPEG encoding to a dedicated single-worker executor via _submit_bev_publish; adds prepare_frame with prefetch mirroring SlangPy path; NVTX annotations throughout. Logic is clean and the frame-drop-on-busy behavior is intentional.
integrations/omnidreams/omnidreams/interactive_drive/presenter.py Removes cuda_stream forwarding to submit_command_buffer, reorders del surface_texture after present(), and adds dense NVTX annotations. All changes are clearly intentional and explained in comments.
integrations/omnidreams/omnidreams/interactive_drive/runtime/loop.py Adds present-interval percentile stats (p50/p95/p99/max) to the profiling window, NVTX annotations on major loop functions, and resets _PROFILE_PRESENT_INTERVALS_MS on window roll. Straightforward and correct.
integrations/omnidreams/omnidreams/interactive_drive/world_model/flashdreams_adapter.py NVTX annotations added to all key pipeline stages. Pure instrumentation with no logic changes.
integrations/omnidreams/tests/interactive_drive/test_rasterizer.py New tests cover lagged BEV polling (in-flight vs completed) and _resampled_frame_indices resampling across different chunk sizes. All tests look correct.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Main as Main Thread
    participant Exec as Rasterizer Worker
    participant BevPanel as BEV Panel Worker
    Main->>Exec: render_rgb_frames(chunk N)
    Exec-->>Main: rgb_frames
    Main->>Main: poll_ready_bev() returns chunk N-1 BEV
    Main->>Exec: render_bev_frames(chunk N) async
    Main->>Main: "build_chunk(rgb=N, bev=N-1)"
    Main->>Main: _update_bev_pil() stores lazy source
    Main->>BevPanel: _build_bev_panel_image async
    BevPanel-->>Main: cached Image on next poll
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Main as Main Thread
    participant Exec as Rasterizer Worker
    participant BevPanel as BEV Panel Worker
    Main->>Exec: render_rgb_frames(chunk N)
    Exec-->>Main: rgb_frames
    Main->>Main: poll_ready_bev() returns chunk N-1 BEV
    Main->>Exec: render_bev_frames(chunk N) async
    Main->>Main: "build_chunk(rgb=N, bev=N-1)"
    Main->>Main: _update_bev_pil() stores lazy source
    Main->>BevPanel: _build_bev_panel_image async
    BevPanel-->>Main: cached Image on next poll
Loading

Reviews (3): Last reviewed commit: "Merge branch 'main' into annotate-nvtx-a..." | Re-trigger Greptile

@wlewNV

wlewNV commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

/ok to test 79fc0c0

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.

2 participants