Skip to content

Separate prefill and decode fiber pools #1417

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion shortfin/python/shortfin_apps/llm/components/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(
responder: FastAPIResponder,
fiber: sf.Fiber | None = None,
):
super().__init__(fiber=service.fiber_pool.fibers[0] if fiber is None else fiber)
super().__init__(fiber=service.prefill_fiber_pool.fibers[0] if fiber is None else fiber)
self.service = service
self.gen_req = gen_req
self.responder = responder
Expand Down
30 changes: 19 additions & 11 deletions shortfin/python/shortfin_apps/llm/components/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,26 @@ def initialize_worker_and_fiber(self):
logger.info(
f"Creating {num_workers} workers, with {fibers_per_worker} fibers per worker..."
)
fibers = []
prefill_fibers = []
decode_fibers = []
for i in range(num_workers):
worker = self.sysman.ls.create_worker(f"{self.name}-inference-{i}")
prefill_worker = self.sysman.ls.create_worker(f"{self.name}-prefill_inference-{i}")
decode_worker = self.sysman.ls.create_worker(f"{self.name}-decode_inference-{i}")
for _ in range(fibers_per_worker):
fiber = self.sysman.ls.create_fiber(worker)
fibers.append(fiber)

self.fiber_pool = FiberPool(
fibers,
fibers,
prefill_fiber = self.sysman.ls.create_fiber(prefill_worker)
prefill_fibers.append(prefill_fiber)
decode_fiber = self.sysman.ls.create_fiber(decode_worker)
decode_fibers.append(decode_fiber)

self.prefill_fiber_pool = FiberPool(
prefill_fibers,
prefill_fibers,
)
self.decode_fiber_pool = FiberPool(
decode_fibers,
decode_fibers,
)
self.devices = fibers[0].devices_dict.values()
self.devices = prefill_fibers[0].devices_dict.values()

def initialize_page_cache(self):
"""Initialize page pool and attention cache."""
Expand Down Expand Up @@ -133,15 +141,15 @@ def start(self):
self.initialize_function_references()

self.prefill_batcher = PrefillBatcherProcess(
self.fiber_pool,
self.prefill_fiber_pool,
self.page_cache,
self.model_params,
self.prefill_functions,
self.prog_isolation,
)

self.decode_batcher = DecodeBatcherProcess(
self.fiber_pool,
self.decode_fiber_pool,
self.page_cache,
self.model_params,
self.decode_functions,
Expand Down
Loading