Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/exo/worker/engines/image/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class ImageEngine(Engine):
Generator[tuple[TaskId, Chunk | FinishedResponse | CancelledResponse]] | None
) = field(init=False, default=None)
queue: deque[ImageTask] = field(init=False, default_factory=deque)
_cancelled_tasks: set[TaskId] = field(init=False, default_factory=set)

def warmup(self) -> None:
image = warmup_image_generator(model=self.image_model)
Expand All @@ -168,7 +169,11 @@ def step(
task = self.queue.popleft()
self.current_gen = self._run_image_task(task.task_id, task.task_params)
resp = next(self.current_gen, None)
return (resp,) if resp is not None else ()
return (
(resp,)
if resp is not None and _is_primary_output_node(self.shard_metadata)
else ()
)

def close(self) -> None:
with contextlib.suppress(NameError, AttributeError):
Expand Down
18 changes: 14 additions & 4 deletions src/exo/worker/runner/llm_inference/batch_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,14 @@ def step(
self._active = None
raise

return itertools.chain(
output,
map(lambda task: (task, CancelledResponse()), self._cancelled_tasks),
return filter(
lambda chunk: (
not isinstance(chunk[1], GenerationChunk) or self.device_rank == 0
),
itertools.chain(
output,
map(lambda task: (task, CancelledResponse()), self._cancelled_tasks),
),
)

def _start_next(self) -> None:
Expand Down Expand Up @@ -449,7 +454,12 @@ def step(
output.append((task.task_id, FinishedResponse()))
del self._active_tasks[uid]

return itertools.chain(output, self._apply_cancellations())
return filter(
lambda chunk: (
not isinstance(chunk[1], GenerationChunk) or self.device_rank == 0
),
itertools.chain(output, self._apply_cancellations()),
)

def _apply_cancellations(
self,
Expand Down
4 changes: 2 additions & 2 deletions src/exo/worker/runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,5 +390,5 @@ def send_chunk(
chunk: Chunk,
command_id: CommandId,
):
if self.device_rank == 0:
self.event_sender.send(ChunkGenerated(command_id=command_id, chunk=chunk))
assert isinstance(self.generator, Engine)
self.event_sender.send(ChunkGenerated(command_id=command_id, chunk=chunk))
Loading