[Bug]: Variable-size emitter recycling writes particle indices beyond capacity

Author: peachtree0222Created Sep 26, 2026Updated Sep 26, 2026
Labelsbug

Bug Description

Emitter.emit and Emitter.emit_omni construct their particle index range before checking whether the pending batch fits in the remaining entity capacity. After each write, they predict whether to recycle by adding the size of the just-completed emission to the new cursor. That prediction is incorrect when the next emission has a different number of particles.

With capacity 10 and valid emission sizes 3, 3, 2, and 3, the cursor is 8 before the fourth call. The implementation constructs indices [8, 9, 10] and addresses index 10 even though the valid range ends at 9.

This affects both directional emission and emit_omni; particle count may vary with geometry, sampler, and per-call particle size.

Steps to Reproduce

  1. Check out c27875eb56947808b3105d25d3c09b6dd96484b3 and install the repository environment.
  2. Download the reproduction package from

emitter-variable-size-recycling-poc.zip

  1. Run uv run python reproducer.py from the package directory.
  2. Observe that the fourth call in each method attempts particle index 10 for a capacity of 10.

The script calls the exact production Emitter.emit and Emitter.emit_omni methods. It patches only the particle samplers to return the deterministic valid cardinalities and uses a minimal entity adapter that enforces the same half-open storage bound.

Expected Behavior

Before constructing indices, the emitter should recycle to zero if the actual pending particle batch does not fit. The fourth batch should use [0, 1, 2] for both methods.

Screenshots/Videos

Not applicable; the textual index trace is deterministic.

Relevant log output

bash
directional_call=1 indices=[0, 1, 2] next=3
directional_call=2 indices=[3, 4, 5] next=6
directional_call=3 indices=[6, 7] next=8
directional_call=4 error=particle index 10 >= capacity 10 next=8
omni_call=1 indices=[0, 1, 2] next=3
omni_call=2 indices=[3, 4, 5] next=6
omni_call=3 indices=[6, 7] next=8
omni_call=4 error=particle index 10 >= capacity 10 next=8

Environment

  • OS: Ubuntu 24.04.5 LTS, Linux 7.0.0-28-generic x86_64
  • GPU/CPU: CPU backend used for the deterministic proof
  • GPU-driver version: N/A for reproduction
  • CUDA / CUDA-toolkit version: N/A for reproduction
  • Python 3.12.13, PyTorch 2.11.0

Release version or Commit ID

Genesis World 1.4.1, main commit c27875eb56947808b3105d25d3c09b6dd96484b3.

Additional Context

Sources:

I have a tested patch that checks the actual pending batch before index creation in both methods and adds parameterized regression coverage. After this issue receives a number, I will open a pull request and link it here.

Source: Genesis-Embodied-AI/genesis-world