Unverified Commit 30e5c35b authored by Alec's avatar Alec Committed by GitHub
Browse files

fix: add capi to pip and make it fallback (#1904)

parent 35c56065
...@@ -23,6 +23,7 @@ from dynamo.sdk.core.decorators.endpoint import abstract_endpoint, api, endpoint ...@@ -23,6 +23,7 @@ from dynamo.sdk.core.decorators.endpoint import abstract_endpoint, api, endpoint
from dynamo.sdk.core.lib import DYNAMO_IMAGE, depends, liveness, readiness, service from dynamo.sdk.core.lib import DYNAMO_IMAGE, depends, liveness, readiness, service
from dynamo.sdk.core.protocol.interface import AbstractService from dynamo.sdk.core.protocol.interface import AbstractService
from dynamo.sdk.lib.decorators import async_on_start, on_shutdown from dynamo.sdk.lib.decorators import async_on_start, on_shutdown
from dynamo.sdk.lib.utils import get_capi_library_path
dynamo_context: dict[str, Any] = {} dynamo_context: dict[str, Any] = {}
...@@ -39,4 +40,5 @@ __all__ = [ ...@@ -39,4 +40,5 @@ __all__ = [
"abstract_endpoint", "abstract_endpoint",
"liveness", "liveness",
"readiness", "readiness",
"get_capi_library_path",
] ]
...@@ -132,3 +132,28 @@ def upload_graph( ...@@ -132,3 +132,28 @@ def upload_graph(
) )
if resp.status_code not in (200, 201, 204): if resp.status_code not in (200, 201, 204):
raise RuntimeError(f"Failed to upload graph artifact: {resp.text}") raise RuntimeError(f"Failed to upload graph artifact: {resp.text}")
def get_capi_library_path() -> str:
"""
Get the path to the libdynamo_llm_capi.so library.
First checks the VLLM_KV_CAPI_PATH environment variable.
If not set, returns the path where the library is installed by the wheel.
Returns:
The path to the library.
"""
# First check environment variable
env_path = os.environ.get("VLLM_KV_CAPI_PATH")
if env_path:
return env_path
# Fall back to the installed location
# The library is installed at dynamo/sdk/cli/bin/libdynamo_llm_capi.so
import dynamo.sdk
sdk_path = os.path.dirname(dynamo.sdk.__file__)
lib_path = os.path.join(sdk_path, "cli", "bin", "libdynamo_llm_capi.so")
return lib_path
...@@ -28,4 +28,5 @@ class CustomBuildHook(BuildHookInterface): ...@@ -28,4 +28,5 @@ class CustomBuildHook(BuildHookInterface):
f"{bin_path}/http": "dynamo/sdk/cli/bin/http", f"{bin_path}/http": "dynamo/sdk/cli/bin/http",
f"{bin_path}/metrics": "dynamo/sdk/cli/bin/metrics", f"{bin_path}/metrics": "dynamo/sdk/cli/bin/metrics",
f"{bin_path}/mock_worker": "dynamo/sdk/cli/bin/mock_worker", f"{bin_path}/mock_worker": "dynamo/sdk/cli/bin/mock_worker",
f"{bin_path}/libdynamo_llm_capi.so": "dynamo/sdk/cli/bin/libdynamo_llm_capi.so",
} }
...@@ -36,6 +36,7 @@ from dynamo.llm import ( ...@@ -36,6 +36,7 @@ from dynamo.llm import (
) )
from dynamo.runtime import DistributedRuntime, dynamo_worker from dynamo.runtime import DistributedRuntime, dynamo_worker
from dynamo.runtime.logging import configure_dynamo_logging from dynamo.runtime.logging import configure_dynamo_logging
from dynamo.sdk.lib.utils import get_capi_library_path
# Only used if you run it manually from the command line # Only used if you run it manually from the command line
DEFAULT_ENDPOINT = "dyn://dynamo.backend.generate" DEFAULT_ENDPOINT = "dyn://dynamo.backend.generate"
...@@ -208,7 +209,7 @@ async def init(runtime: DistributedRuntime, config: Config): ...@@ -208,7 +209,7 @@ async def init(runtime: DistributedRuntime, config: Config):
_check_and_set_env_value("VLLM_WORKER_ID", str(endpoint.lease_id())) _check_and_set_env_value("VLLM_WORKER_ID", str(endpoint.lease_id()))
_check_and_set_env_value( _check_and_set_env_value(
"VLLM_KV_CAPI_PATH", "libdynamo_llm_capi.so", allow_override=True "VLLM_KV_CAPI_PATH", get_capi_library_path(), allow_override=True
) )
_check_and_set_env_value("VLLM_KV_NAMESPACE", config.namespace) _check_and_set_env_value("VLLM_KV_NAMESPACE", config.namespace)
_check_and_set_env_value("VLLM_KV_COMPONENT", config.component) _check_and_set_env_value("VLLM_KV_COMPONENT", config.component)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment