fix(perception): rendezvous completed gpu handoff

This commit is contained in:
DCCONSTRUCTIONS
2026-09-02 01:48:25 +03:00
parent 380a13688c
commit 294585936f
3 changed files with 82 additions and 12 deletions
+38
View File
@@ -176,6 +176,44 @@ def test_gpu_stage_preserves_order_and_reserves_bounded_output_before_compute(pi
assert stage.close()
def test_waiting_consumer_uses_direct_handoff_without_evicting_ingress(pilot):
mailbox = pilot("pilot_queue").Mailbox(capacity=2, byte_limit=100)
compute_started = threading.Event()
release_compute = threading.Event()
def compute(bundle):
if bundle["sequence"] == 0:
compute_started.set()
assert release_compute.wait(1)
return bundle["sequence"] * 10
stage = pilot("pilot_scheduler").GpuStage(mailbox, compute, threading.Event())
bundles = [{"sequence": sequence, "payload_bytes": 10} for sequence in range(3)]
mailbox.put(bundles[0])
assert compute_started.wait(1)
mailbox.put(bundles[1])
mailbox.put(bundles[2])
mailbox.finish()
received = []
consumer = threading.Thread(target=lambda: received.append(stage.take()))
consumer.start()
with stage.output_condition:
assert stage.output_condition.wait_for(lambda: stage.consumer_waiting, timeout=1)
release_compute.set()
consumer.join(timeout=1)
assert not consumer.is_alive()
assert received[0][0]["sequence"] == 0
assert not mailbox.dropped
assert stage.direct_handoffs == 1
for expected in (1, 2):
bundle, result = stage.take()
assert (bundle["sequence"], result) == (expected, expected * 10)
for bundle in bundles:
mailbox.release(bundle)
assert stage.take() is None
assert mailbox.bytes == 0 and stage.close()
def test_gpu_stage_propagates_failure_and_stops_waiting_for_input(pilot):
mailbox = pilot("pilot_queue").Mailbox(capacity=1)