forked from nod-ai/shark-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shortfin LLM Deviceid Support (nod-ai#493)
# Description Add the ability to specify device_ids that you want Shortfin LLM Server to run with. The setup is essentially 1-1 with how SD server sets device_ids support up. Created a new `shortfin/interop/support/device_setup.py` module and moved the `get_selected_devices` function there to be shared across `managers`. ## Example ```bash python -m shortfin_apps.llm.server --tokenizer_json=/data/llama3.1/8b/tokenizer.json --model_config=./export/edited_config.json --vmfb=./export/model.vmfb --parameters=/data/llama3.1/8b/llama8b_f16.irpa --device=amdgpu --device_ids=0 ```
- Loading branch information
Showing
4 changed files
with
57 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import shortfin as sf | ||
|
||
|
||
def get_selected_devices(sb: sf.SystemBuilder, device_ids=None): | ||
available = sb.available_devices | ||
selected = [] | ||
if device_ids is not None: | ||
if len(device_ids) > len(available): | ||
raise ValueError( | ||
f"Requested more device ids ({device_ids}) than available ({available})." | ||
) | ||
for did in device_ids: | ||
if isinstance(did, str): | ||
try: | ||
did = int(did) | ||
except ValueError: | ||
did = did | ||
if did in available: | ||
selected.append(did) | ||
elif isinstance(did, int): | ||
selected.append(available[did]) | ||
else: | ||
raise ValueError(f"Device id {did} could not be parsed.") | ||
else: | ||
selected = available | ||
return selected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters