Skip to content

Commit

Permalink
[Shortfin] SD server indexing fix (#892)
Browse files Browse the repository at this point in the history
Fixes a bug in the sd server that was not connecting the appropriate
fibers to workers resulting in unbalanced workers threads
  • Loading branch information
IanNod authored Feb 3, 2025
1 parent c07248e commit c10a5de
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions shortfin/python/shortfin_apps/sd/components/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ def __init__(
self.idle_fibers = set()
# For each worker index we create one on each device, and add their fibers to the idle set.
# This roughly ensures that the first picked fibers are distributed across available devices.
for i in range(self.workers_per_device):
for idx, device in enumerate(self.sysman.ls.devices):
for idx, device in enumerate(self.sysman.ls.devices):
for i in range(self.workers_per_device):
worker = sysman.ls.create_worker(f"{name}-inference-{device.name}-{i}")
self.workers.append(worker)
for idx, device in enumerate(self.sysman.ls.devices):
for i in range(self.fibers_per_device):
tgt_worker = self.workers[i % len(self.workers)]
tgt_worker = self.workers[
idx * workers_per_device + i % workers_per_device
]
fiber = sysman.ls.create_fiber(tgt_worker, devices=[device])
self.fibers.append(fiber)
self.idle_fibers.add(fiber)
Expand Down

0 comments on commit c10a5de

Please sign in to comment.