Skip to content

Commit 30e5c35

Browse files
authored
fix: add capi to pip and make it fallback (#1904)
1 parent 35c5606 commit 30e5c35

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

deploy/sdk/src/dynamo/sdk/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from dynamo.sdk.core.lib import DYNAMO_IMAGE, depends, liveness, readiness, service
2424
from dynamo.sdk.core.protocol.interface import AbstractService
2525
from dynamo.sdk.lib.decorators import async_on_start, on_shutdown
26+
from dynamo.sdk.lib.utils import get_capi_library_path
2627

2728
dynamo_context: dict[str, Any] = {}
2829

@@ -39,4 +40,5 @@
3940
"abstract_endpoint",
4041
"liveness",
4142
"readiness",
43+
"get_capi_library_path",
4244
]

deploy/sdk/src/dynamo/sdk/lib/utils.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,28 @@ def upload_graph(
132132
)
133133
if resp.status_code not in (200, 201, 204):
134134
raise RuntimeError(f"Failed to upload graph artifact: {resp.text}")
135+
136+
137+
def get_capi_library_path() -> str:
138+
"""
139+
Get the path to the libdynamo_llm_capi.so library.
140+
141+
First checks the VLLM_KV_CAPI_PATH environment variable.
142+
If not set, returns the path where the library is installed by the wheel.
143+
144+
Returns:
145+
The path to the library.
146+
"""
147+
# First check environment variable
148+
env_path = os.environ.get("VLLM_KV_CAPI_PATH")
149+
if env_path:
150+
return env_path
151+
152+
# Fall back to the installed location
153+
# The library is installed at dynamo/sdk/cli/bin/libdynamo_llm_capi.so
154+
import dynamo.sdk
155+
156+
sdk_path = os.path.dirname(dynamo.sdk.__file__)
157+
lib_path = os.path.join(sdk_path, "cli", "bin", "libdynamo_llm_capi.so")
158+
159+
return lib_path

hatch_build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ def initialize(self, version, build_data):
2828
f"{bin_path}/http": "dynamo/sdk/cli/bin/http",
2929
f"{bin_path}/metrics": "dynamo/sdk/cli/bin/metrics",
3030
f"{bin_path}/mock_worker": "dynamo/sdk/cli/bin/mock_worker",
31+
f"{bin_path}/libdynamo_llm_capi.so": "dynamo/sdk/cli/bin/libdynamo_llm_capi.so",
3132
}

launch/dynamo-run/src/subprocess/vllm_inc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
)
3737
from dynamo.runtime import DistributedRuntime, dynamo_worker
3838
from dynamo.runtime.logging import configure_dynamo_logging
39+
from dynamo.sdk.lib.utils import get_capi_library_path
3940

4041
# Only used if you run it manually from the command line
4142
DEFAULT_ENDPOINT = "dyn://dynamo.backend.generate"
@@ -208,7 +209,7 @@ async def init(runtime: DistributedRuntime, config: Config):
208209

209210
_check_and_set_env_value("VLLM_WORKER_ID", str(endpoint.lease_id()))
210211
_check_and_set_env_value(
211-
"VLLM_KV_CAPI_PATH", "libdynamo_llm_capi.so", allow_override=True
212+
"VLLM_KV_CAPI_PATH", get_capi_library_path(), allow_override=True
212213
)
213214
_check_and_set_env_value("VLLM_KV_NAMESPACE", config.namespace)
214215
_check_and_set_env_value("VLLM_KV_COMPONENT", config.component)

0 commit comments

Comments
 (0)