From a31e86a65515c3c156a58e23aaa077330d5a0202 Mon Sep 17 00:00:00 2001 From: 0xamlab <79715912+0xamlab@users.noreply.github.com> Date: Sun, 8 Nov 2026 10:43:54 -0500 Subject: [PATCH 1/4] Add optional Telys connector example --- docs/configuration.md | 23 +++ examples/telys/Dockerfile | 27 +++ examples/telys/README.md | 123 ++++++++++++ examples/telys/entrypoint.sh | 115 ++++++++++++ tests/test_telys_example.py | 354 +++++++++++++++++++++++++++++++++++ 5 files changed, 642 insertions(+) create mode 100644 examples/telys/Dockerfile create mode 100644 examples/telys/README.md create mode 100755 examples/telys/entrypoint.sh create mode 100644 tests/test_telys_example.py diff --git a/docs/configuration.md b/docs/configuration.md index 17566531..0ae9a1d8 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -162,3 +162,26 @@ is gone: `SWAP_SPACE`, `ROPE_SCALING`/`ROPE_THETA`, `NUM_LOOKAHEAD_SLOTS`, and `GUIDED_DECODING_*` are in `REMOVED_FLAGS`: setting them logs a warning and they are ignored instead of crashing the worker at startup. + +## Optional Telys connector example + +[`examples/telys/`](../examples/telys/README.md) is a separate derived image; the +standard worker image and its default behavior do not include or enable Telys. The +example's `TELYS_VLLM_COMMIT` build argument defaults to connector `v0.1.2` at +`49662f299b3c17b0f8c51050c8600cc8706362fd`, installed from the immutable `git+https` +source at that commit. Overrides must use a full 40-character lowercase SHA; branches, +tags, and short SHAs are rejected. + +The derived image adds these wrapper-level settings: + +| Variable | Default | Description | +| -------- | ------- | ----------- | +| `TELYS_ENABLED` | `false` | Exactly `true` opts in. Otherwise the original worker entrypoint runs and non-Telys connector configuration is unchanged. Telys credentials or connector configuration are rejected while disabled. | +| `TELYS_HOME` | SDK default | Persistent SDK runtime and login-state directory; the example uses `/runpod-volume/telys-home`. | +| `TELYS_PATH` | — | Persistent embedded-engine data path. Remote-engine configuration is described in the example README. | +| `TELYS_API_KEY` / `TELYS_OAUTH_TOKEN` | — | Optional first-run provisioning secrets. API-key provisioning takes precedence; failures never fall back to the other mechanism. Both are removed from the environment after successful provisioning. | +| `KV_TRANSFER_CONFIG` | Telys connector when enabled | Automatically supplied for `TELYS_ENABLED=true` unless already set. A custom value must select `TelysKVConnector` from `telys_vllm.connector` with `kv_role=kv_both`. | +| `TELYS_VLLM_LOAD_ASYNC` | `0` when enabled | Async KV loading is unsupported; attempts to enable it through the environment or connector extra config fail startup. | + +See the example README for the build command, persistent paths, provisioning flow, and +the real GPU/model/endpoint acceptance checks that remain necessary. diff --git a/examples/telys/Dockerfile b/examples/telys/Dockerfile new file mode 100644 index 00000000..0b446d04 --- /dev/null +++ b/examples/telys/Dockerfile @@ -0,0 +1,27 @@ +FROM runpod/worker-v1-vllm:v2.30.3 + +ARG TELYS_VLLM_COMMIT=49662f299b3c17b0f8c51050c8600cc8706362fd +RUN python3 - "$TELYS_VLLM_COMMIT" <<'PY' +import re +import sys + +commit = sys.argv[1] +if re.fullmatch(r"[0-9a-f]{40}", commit) is None: + raise SystemExit( + "TELYS_VLLM_COMMIT must be a full 40-character lowercase SHA; " + "branches, tags, short SHAs, and other revision forms are not accepted" + ) +PY + +RUN apt-get update \ + && apt-get install -y --no-install-recommends git \ + && rm -rf /var/lib/apt/lists/* + +RUN python3 -m pip install --no-cache-dir "telys==0.1.14" \ + && python3 -m pip install --no-cache-dir --no-deps \ + "telys-vllm @ git+https://github.com/thyn-ai/telys-vllm.git@${TELYS_VLLM_COMMIT}" \ + && python3 -c 'from importlib.metadata import version; vllm_version = version("vllm"); assert vllm_version == "0.32.0", f"expected vllm==0.32.0, found {vllm_version}"; telys_version = version("telys"); assert telys_version == "0.1.14", f"expected telys==0.1.14, found {telys_version}"; connector_version = version("telys-vllm"); assert connector_version == "0.1.2", f"expected telys-vllm==0.1.2, found {connector_version}"; from telys_vllm.connector import TelysKVConnector' + +COPY --chmod=0755 examples/telys/entrypoint.sh /usr/local/bin/telys-vllm-entrypoint + +ENTRYPOINT ["/usr/local/bin/telys-vllm-entrypoint"] diff --git a/examples/telys/README.md b/examples/telys/README.md new file mode 100644 index 00000000..0402b24c --- /dev/null +++ b/examples/telys/README.md @@ -0,0 +1,123 @@ +# Optional Telys KV connector example + +This derived image adds the [Telys vLLM connector](https://github.com/thyn-ai/telys-vllm) +to the stock `runpod/worker-v1-vllm:v2.30.3` image (vLLM 0.32.0). The upstream worker's +`/src/main.py` startup path remains unchanged. Telys is disabled unless +`TELYS_ENABLED=true` is set explicitly. + +## Build + +`TELYS_VLLM_COMMIT` defaults to +`49662f299b3c17b0f8c51050c8600cc8706362fd`, the source commit for connector `v0.1.2`. +The Dockerfile installs from the immutable `git+https` source at that commit. Overrides +must use a full 40-character lowercase SHA; branches, tags, short SHAs, and uppercase +SHAs are rejected. + +Build from the worker repository root: + +```bash +docker build --platform=linux/amd64 \ + --file examples/telys/Dockerfile \ + --build-arg TELYS_VLLM_COMMIT=49662f299b3c17b0f8c51050c8600cc8706362fd \ + --tag your-dockerhub-user/telys-worker-vllm:VERSION . +``` + +The build installs `telys==0.1.14`, installs the connector directly from the pinned +commit with `--no-deps`, and checks that vLLM remains exactly 0.32.0, the connector +distribution is 0.1.2, and `TelysKVConnector` imports. It does not bake in a model, +Telys credentials, or a signed Telys runtime. Publishing the resulting image is a +separate operation. + +## Stock behavior (default) + +Leave `TELYS_ENABLED` unset or set it to `false`. The entrypoint immediately executes +`python3 /src/main.py` with the original arguments and environment. Non-Telys vLLM +configuration, including another `KV_TRANSFER_CONFIG` connector such as the stock +filesystem offloader, is passed through unchanged. + +To prevent an accidental partial configuration, the disabled path rejects nonempty +`TELYS_API_KEY` or `TELYS_OAUTH_TOKEN`, and rejects a `KV_TRANSFER_CONFIG` that names +`TelysKVConnector` or `telys_vllm.connector`. It never provisions Telys in this mode. +`TELYS_ENABLED` accepts exactly `true` or `false`. + +## Enable Telys + +Attach a network volume at `/runpod-volume`. A minimal endpoint configuration is: + +```bash +TELYS_ENABLED=true +TELYS_HOME=/runpod-volume/telys-home +TELYS_PATH=/runpod-volume/telys-data +MODEL_NAME=Qwen/Qwen2.5-7B-Instruct +ENABLE_PREFIX_CACHING=false +VLLM_ENABLE_V1_MULTIPROCESSING=0 +# HF_TOKEN= +``` + +When enabled, the entrypoint supplies this connector configuration unless one is +already present: + +```bash +KV_TRANSFER_CONFIG={"kv_connector":"TelysKVConnector","kv_connector_module_path":"telys_vllm.connector","kv_role":"kv_both"} +``` + +A custom `KV_TRANSFER_CONFIG` must be valid JSON with those same connector, module, +and role values. `kv_connector_extra_config` may contain supported Telys settings. Do +not configure another KV connector on the same endpoint. Disabling native prefix +caching and V1 multiprocessing matches the connector-only validation setup; choose +those settings deliberately for other workloads. + +The entrypoint sets `TELYS_VLLM_LOAD_ASYNC=0`. Asynchronous KV loading is unsupported +in this connector revision. Startup fails if the environment or +`kv_connector_extra_config.telys_load_async` attempts to enable it. + +`TELYS_HOME` holds the SDK runtime and login state. Embedded engine data uses +`TELYS_PATH`; BlobStore payloads use `TELYS_PATH` with `_blobs` appended, and the +fallback slab defaults to `TELYS_PATH` with `_kv.slab` appended. Set +`TELYS_VLLM_SLAB_PATH` explicitly when using a remote engine with the slab fallback. +Keep runtime state, metadata, and payloads on persistent storage, use separate cache +namespaces for incompatible model/KV configurations, and restrict access to the volume. + +## Provision the Telys runtime + +For a runtime that is not installed yet, configure exactly one credential as a Runpod +secret: + +- `TELYS_API_KEY`: direct API-key provisioning. The entrypoint registers the device, + atomically writes `login_license.jwt` under `TELYS_HOME` with mode `0600`, and calls + the SDK installer. An API key is not an OAuth token. +- `TELYS_OAUTH_TOKEN`: OAuth-only provisioning through + `telys login --token ... --no-browser --plan telys_developer`. + +If both are present, API-key provisioning takes precedence; there is no fallback from +a failed API-key attempt to OAuth. Any provisioning failure stops startup. After +success, both credential variables are removed from the worker environment before the +upstream entrypoint runs. Do not put credentials in the Dockerfile, `ENV`, +`KV_TRANSFER_CONFIG`, or `VLLM_EXTRA_ARGS`. + +After the signed runtime and login state are installed on the volume, remove both +credential variables. The entrypoint skips login when both are empty and uses the +existing runtime. Perform initial provisioning with one worker before allowing +concurrent workers to initialize the same `TELYS_HOME`. + +## Checks and required acceptance + +The CPU-only checks exercise the entrypoint with fake SDK/CLI boundaries, inspect the +Dockerfile, and execute its commit validator: + +```bash +python3 -m pytest tests/test_telys_example.py -v +``` + +They do not pull the base image, install the connector, download a model, access a GPU, +or contact Telys or Runpod. They are not remote acceptance evidence. + +Before production use, complete all of the following with the selected final commit: + +- Build the `linux/amd64` image and confirm its vLLM, SDK, and connector import checks. +- Verify the default path with the normal worker smoke test and a non-Telys connector. +- Provision the signed runtime and start a real endpoint with the target model, GPU, + network volume, and model/KV settings. +- Check cold misses, warm hits from a fresh worker, output equivalence against an + uncached reference, persistence drain, disk use, and restart behavior. +- Validate multi-writer or multi-group topologies separately rather than assuming them. diff --git a/examples/telys/entrypoint.sh b/examples/telys/entrypoint.sh new file mode 100755 index 00000000..418ed052 --- /dev/null +++ b/examples/telys/entrypoint.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash +set -euo pipefail +set +x + +readonly DEFAULT_KV_TRANSFER_CONFIG='{"kv_connector":"TelysKVConnector","kv_connector_module_path":"telys_vllm.connector","kv_role":"kv_both"}' + +fail() { + printf 'telys-vllm entrypoint: %s\n' "$1" >&2 + exit 64 +} + +case "${TELYS_ENABLED:-false}" in + false) + if [[ -n "${TELYS_API_KEY:-}" || -n "${TELYS_OAUTH_TOKEN:-}" ]]; then + fail "Telys credentials require TELYS_ENABLED=true" + fi + if [[ "${KV_TRANSFER_CONFIG:-}" == *"TelysKVConnector"* || "${KV_TRANSFER_CONFIG:-}" == *"telys_vllm.connector"* ]]; then + fail "the Telys connector requires TELYS_ENABLED=true" + fi + exec python3 /src/main.py "$@" + ;; + true) + ;; + *) + fail "TELYS_ENABLED must be exactly 'true' or 'false'" + ;; +esac + +export KV_TRANSFER_CONFIG="${KV_TRANSFER_CONFIG:-$DEFAULT_KV_TRANSFER_CONFIG}" +python3 - <<'PY' +import json +import os + +FALSE_VALUES = {"0", "false", "no", "off"} +EXPECTED = { + "kv_connector": "TelysKVConnector", + "kv_connector_module_path": "telys_vllm.connector", + "kv_role": "kv_both", +} + + +def require_false(value, source): + if isinstance(value, bool): + valid = not value + elif isinstance(value, str): + valid = value.strip().lower() in FALSE_VALUES + else: + valid = False + if not valid: + raise SystemExit( + f"telys-vllm entrypoint: {source} must be false; " + "asynchronous KV loading is unsupported" + ) + + +try: + config = json.loads(os.environ["KV_TRANSFER_CONFIG"]) +except json.JSONDecodeError as exc: + raise SystemExit( + "telys-vllm entrypoint: KV_TRANSFER_CONFIG must be valid JSON" + ) from exc + +if not isinstance(config, dict): + raise SystemExit("telys-vllm entrypoint: KV_TRANSFER_CONFIG must be a JSON object") +if any(config.get(key) != value for key, value in EXPECTED.items()): + raise SystemExit( + "telys-vllm entrypoint: TELYS_ENABLED=true requires TelysKVConnector " + "from telys_vllm.connector with kv_role=kv_both" + ) + +extra = config.get("kv_connector_extra_config", {}) +if not isinstance(extra, dict): + raise SystemExit( + "telys-vllm entrypoint: kv_connector_extra_config must be a JSON object" + ) +require_false(extra.get("telys_load_async", False), "telys_load_async") +if "TELYS_VLLM_LOAD_ASYNC" in os.environ: + require_false( + os.environ["TELYS_VLLM_LOAD_ASYNC"], "TELYS_VLLM_LOAD_ASYNC" + ) +PY +export TELYS_VLLM_LOAD_ASYNC=0 + +if [[ -n "${TELYS_API_KEY:-}" ]]; then + python3 - <<'PY' +import os +import tempfile + +import telys.installer +import telys.login +import telys.paths + +key = os.environ["TELYS_API_KEY"] +home = telys.paths.telys_home() +os.makedirs(home, mode=0o700, exist_ok=True) +license_token = telys.login.register_device( + api=telys.paths.api_url(), api_key=key +) +license_path = os.path.join(home, "login_license.jwt") +descriptor, temporary_path = tempfile.mkstemp(dir=home, prefix=".login_license.") +try: + with os.fdopen(descriptor, "w", encoding="utf-8") as license_file: + license_file.write(license_token) + os.replace(temporary_path, license_path) +finally: + if os.path.exists(temporary_path): + os.unlink(temporary_path) +telys.installer.install_from_host(token=key, license_path=license_path) +PY +elif [[ -n "${TELYS_OAUTH_TOKEN:-}" ]]; then + telys login --token "$TELYS_OAUTH_TOKEN" --no-browser --plan telys_developer +fi + +unset TELYS_API_KEY TELYS_OAUTH_TOKEN +exec python3 /src/main.py "$@" diff --git a/tests/test_telys_example.py b/tests/test_telys_example.py new file mode 100644 index 00000000..41846e5d --- /dev/null +++ b/tests/test_telys_example.py @@ -0,0 +1,354 @@ +"""Static and CPU-only checks for the optional Telys example; no image or GPU.""" + +import json +import re +import shlex +import stat +import subprocess +import sys +from pathlib import Path + +import pytest + +ROOT = Path(__file__).resolve().parent.parent +DOCKERFILE = ROOT / "examples" / "telys" / "Dockerfile" +ENTRYPOINT = ROOT / "examples" / "telys" / "entrypoint.sh" +README = ROOT / "examples" / "telys" / "README.md" +CONNECTOR_COMMIT = "49662f299b3c17b0f8c51050c8600cc8706362fd" +DEFAULT_CONFIG = ( + '{"kv_connector":"TelysKVConnector",' + '"kv_connector_module_path":"telys_vllm.connector","kv_role":"kv_both"}' +) +STOCK_CONFIG = ( + '{"kv_connector":"OffloadingConnector","kv_role":"kv_both",' + '"kv_connector_extra_config":{"spec_name":"TieringOffloadingSpec"}}' +) + + +def write_executable(path: Path, content: str) -> None: + path.write_text(content) + path.chmod(0o755) + + +@pytest.fixture +def entrypoint_env(tmp_path): + capture = tmp_path / "capture" + capture.mkdir() + bin_dir = tmp_path / "bin" + bin_dir.mkdir() + packages = tmp_path / "packages" + telys_package = packages / "telys" + telys_package.mkdir(parents=True) + (telys_package / "__init__.py").write_text("") + (telys_package / "paths.py").write_text( + """import os + +def api_url(): + return "https://example.invalid" + +def telys_home(): + return os.environ["TELYS_HOME"] +""" + ) + (telys_package / "login.py").write_text( + """import os + +def register_device(*, api, api_key): + assert api == "https://example.invalid" + assert api_key == os.environ["TELYS_API_KEY"] + if os.environ.get("FAKE_REGISTER_FAIL") == "1": + raise RuntimeError("provisioning failed") + with open(os.path.join(os.environ["CAPTURE_DIR"], "api-called"), "w") as marker: + marker.write("registered") + return "test-license-token" +""" + ) + (telys_package / "installer.py").write_text( + """import os + +def install_from_host(*, token, license_path): + assert token == os.environ["TELYS_API_KEY"] + with open(license_path) as license_file: + assert license_file.read() == "test-license-token" + with open(os.path.join(os.environ["CAPTURE_DIR"], "installed"), "w") as marker: + marker.write("installed") +""" + ) + write_executable( + bin_dir / "python3", + f"""#!/bin/sh +if [ "${{1:-}}" = "-" ]; then + exec {shlex.quote(sys.executable)} "$@" +fi +printf '%s\\n' "$@" > "$CAPTURE_DIR/python-args" +env > "$CAPTURE_DIR/python-env" +printf called > "$CAPTURE_DIR/main-called" +""", + ) + write_executable( + bin_dir / "telys", + """#!/bin/sh +if [ "$#" -ne 6 ] || [ "$1" != "login" ] || [ "$2" != "--token" ] || \ + [ "$3" != "$TELYS_OAUTH_TOKEN" ] || [ "$4" != "--no-browser" ] || \ + [ "$5" != "--plan" ] || [ "$6" != "telys_developer" ]; then + exit 64 +fi +printf called > "$CAPTURE_DIR/oauth-called" +""", + ) + + def run(overrides=None, *args): + env = { + "CAPTURE_DIR": str(capture), + "HOME": str(tmp_path / "home"), + "LC_ALL": "C", + "PATH": f"{bin_dir}:/usr/bin:/bin", + "PYTHONPATH": str(packages), + "TELYS_HOME": str(tmp_path / "telys-home"), + } + for key, value in (overrides or {}).items(): + if value is None: + env.pop(key, None) + else: + env[key] = value + return subprocess.run( + ["bash", str(ENTRYPOINT), *args], + capture_output=True, + env=env, + text=True, + timeout=10, + ) + + return run, capture, tmp_path + + +def captured_env(capture: Path) -> dict[str, str]: + return dict( + line.split("=", 1) + for line in (capture / "python-env").read_text().splitlines() + ) + + +@pytest.mark.parametrize("enabled", [None, "false"]) +def test_disabled_preserves_stock_entrypoint_and_environment(entrypoint_env, enabled): + run, capture, _ = entrypoint_env + result = run( + {"TELYS_ENABLED": enabled, "KV_TRANSFER_CONFIG": STOCK_CONFIG, "SENTINEL": "kept"}, + "--worker-arg", + "two words", + ) + + assert result.returncode == 0, result.stderr + assert (capture / "python-args").read_text().splitlines() == [ + "/src/main.py", + "--worker-arg", + "two words", + ] + env = captured_env(capture) + assert env["KV_TRANSFER_CONFIG"] == STOCK_CONFIG + assert env["SENTINEL"] == "kept" + assert "TELYS_VLLM_LOAD_ASYNC" not in env + assert not (capture / "api-called").exists() + assert not (capture / "oauth-called").exists() + + +@pytest.mark.parametrize("credential", ["TELYS_API_KEY", "TELYS_OAUTH_TOKEN"]) +def test_disabled_rejects_credentials_without_starting(entrypoint_env, credential): + run, capture, _ = entrypoint_env + result = run({credential: "test-secret-value"}) + + assert result.returncode == 64 + assert "TELYS_ENABLED=true" in result.stderr + assert "test-secret-value" not in result.stderr + result.stdout + assert not (capture / "main-called").exists() + + +def test_disabled_rejects_telys_connector(entrypoint_env): + run, capture, _ = entrypoint_env + result = run({"KV_TRANSFER_CONFIG": DEFAULT_CONFIG}) + + assert result.returncode == 64 + assert "requires TELYS_ENABLED=true" in result.stderr + assert not (capture / "main-called").exists() + + +def test_opt_in_rejects_ambiguous_boolean(entrypoint_env): + run, capture, _ = entrypoint_env + result = run({"TELYS_ENABLED": "1"}) + + assert result.returncode == 64 + assert "exactly 'true' or 'false'" in result.stderr + assert not (capture / "main-called").exists() + + +def test_enabled_supplies_connector_and_disables_async(entrypoint_env): + run, capture, _ = entrypoint_env + result = run({"TELYS_ENABLED": "true"}) + + assert result.returncode == 0, result.stderr + env = captured_env(capture) + assert json.loads(env["KV_TRANSFER_CONFIG"]) == { + "kv_connector": "TelysKVConnector", + "kv_connector_module_path": "telys_vllm.connector", + "kv_role": "kv_both", + } + assert env["TELYS_VLLM_LOAD_ASYNC"] == "0" + assert not (capture / "api-called").exists() + assert not (capture / "oauth-called").exists() + + +def test_enabled_preserves_valid_custom_config(entrypoint_env): + run, capture, _ = entrypoint_env + config = json.dumps( + { + "kv_role": "kv_both", + "kv_connector_module_path": "telys_vllm.connector", + "kv_connector": "TelysKVConnector", + "kv_connector_extra_config": { + "telys_namespace": "test", + "telys_load_async": False, + }, + } + ) + result = run({"TELYS_ENABLED": "true", "KV_TRANSFER_CONFIG": config}) + + assert result.returncode == 0, result.stderr + env = captured_env(capture) + assert env["KV_TRANSFER_CONFIG"] == config + assert env["TELYS_VLLM_LOAD_ASYNC"] == "0" + + +@pytest.mark.parametrize( + "overrides", + [ + {"KV_TRANSFER_CONFIG": "not-json"}, + {"KV_TRANSFER_CONFIG": STOCK_CONFIG}, + {"KV_TRANSFER_CONFIG": '{"kv_connector":"TelysKVConnector"}'}, + { + "KV_TRANSFER_CONFIG": json.dumps( + { + "kv_connector": "TelysKVConnector", + "kv_connector_module_path": "telys_vllm.connector", + "kv_role": "kv_both", + "kv_connector_extra_config": {"telys_load_async": True}, + } + ) + }, + {"TELYS_VLLM_LOAD_ASYNC": "true"}, + ], +) +def test_enabled_rejects_invalid_connector_or_async_config(entrypoint_env, overrides): + run, capture, _ = entrypoint_env + result = run({"TELYS_ENABLED": "true", **overrides}) + + assert result.returncode != 0 + assert not (capture / "main-called").exists() + assert not (capture / "api-called").exists() + assert not (capture / "oauth-called").exists() + + +def test_api_key_provisioning_takes_precedence_and_unsets_credentials(entrypoint_env): + run, capture, tmp_path = entrypoint_env + result = run( + { + "TELYS_ENABLED": "true", + "TELYS_API_KEY": "test-api-key", + "TELYS_OAUTH_TOKEN": "test-oauth-token", + } + ) + + assert result.returncode == 0, result.stderr + assert (capture / "api-called").exists() + assert (capture / "installed").exists() + assert not (capture / "oauth-called").exists() + env = captured_env(capture) + assert "TELYS_API_KEY" not in env + assert "TELYS_OAUTH_TOKEN" not in env + license_path = tmp_path / "telys-home" / "login_license.jwt" + assert license_path.read_text() == "test-license-token" + assert stat.S_IMODE(license_path.stat().st_mode) == 0o600 + + +def test_oauth_provisioning_and_secret_cleanup(entrypoint_env): + run, capture, _ = entrypoint_env + result = run({"TELYS_ENABLED": "true", "TELYS_OAUTH_TOKEN": "test-oauth-token"}) + + assert result.returncode == 0, result.stderr + assert (capture / "oauth-called").exists() + assert not (capture / "api-called").exists() + assert "TELYS_OAUTH_TOKEN" not in captured_env(capture) + + +def test_provisioning_failure_does_not_fall_back_or_start_worker(entrypoint_env): + run, capture, _ = entrypoint_env + result = run( + { + "TELYS_ENABLED": "true", + "TELYS_API_KEY": "test-api-key", + "TELYS_OAUTH_TOKEN": "test-oauth-token", + "FAKE_REGISTER_FAIL": "1", + } + ) + + assert result.returncode != 0 + assert "provisioning failed" in result.stderr + assert "test-api-key" not in result.stderr + result.stdout + assert "test-oauth-token" not in result.stderr + result.stdout + assert not (capture / "oauth-called").exists() + assert not (capture / "main-called").exists() + + +def test_dockerfile_pins_final_connector_commit(): + dockerfile = DOCKERFILE.read_text() + + assert "FROM runpod/worker-v1-vllm:v2.30.3" in dockerfile + assert f"ARG TELYS_VLLM_COMMIT={CONNECTOR_COMMIT}" in dockerfile + assert 'r"[0-9a-f]{40}"' in dockerfile + assert ( + "telys-vllm @ git+https://github.com/thyn-ai/telys-vllm.git@" + "${TELYS_VLLM_COMMIT}" + ) in dockerfile + assert "apt-get install -y --no-install-recommends git" in dockerfile + assert "--no-deps" in dockerfile + assert 'vllm_version == "0.32.0"' in dockerfile + assert 'connector_version == "0.1.2"' in dockerfile + assert re.findall(r"(? Date: Sun, 8 Nov 2026 17:13:22 -0500 Subject: [PATCH 2/4] Reject connector overrides in Telys passthrough args --- examples/telys/README.md | 5 +++++ examples/telys/entrypoint.sh | 18 ++++++++++++++++++ tests/test_telys_example.py | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/examples/telys/README.md b/examples/telys/README.md index 0402b24c..c04e309f 100644 --- a/examples/telys/README.md +++ b/examples/telys/README.md @@ -40,6 +40,11 @@ To prevent an accidental partial configuration, the disabled path rejects nonemp `TelysKVConnector` or `telys_vllm.connector`. It never provisions Telys in this mode. `TELYS_ENABLED` accepts exactly `true` or `false`. +In both modes, the entrypoint rejects `--kv-transfer-config` in `VLLM_EXTRA_ARGS`, +including both `--kv-transfer-config value` and `--kv-transfer-config=value` forms, +instead of letting it bypass the connector checks. Set `KV_TRANSFER_CONFIG` instead. +Other extra arguments pass through unchanged. + ## Enable Telys Attach a network volume at `/runpod-volume`. A minimal endpoint configuration is: diff --git a/examples/telys/entrypoint.sh b/examples/telys/entrypoint.sh index 418ed052..8ffc1e17 100755 --- a/examples/telys/entrypoint.sh +++ b/examples/telys/entrypoint.sh @@ -9,6 +9,24 @@ fail() { exit 64 } +python3 - <<'PY' +import os +import shlex +import sys + +extra_args = shlex.split(os.environ.get("VLLM_EXTRA_ARGS", "")) +if any( + arg == "--kv-transfer-config" or arg.startswith("--kv-transfer-config=") + for arg in extra_args +): + print( + "telys-vllm entrypoint: --kv-transfer-config is not allowed in " + "VLLM_EXTRA_ARGS; set KV_TRANSFER_CONFIG instead", + file=sys.stderr, + ) + raise SystemExit(64) +PY + case "${TELYS_ENABLED:-false}" in false) if [[ -n "${TELYS_API_KEY:-}" || -n "${TELYS_OAUTH_TOKEN:-}" ]]; then diff --git a/tests/test_telys_example.py b/tests/test_telys_example.py index 41846e5d..fc529829 100644 --- a/tests/test_telys_example.py +++ b/tests/test_telys_example.py @@ -181,6 +181,41 @@ def test_opt_in_rejects_ambiguous_boolean(entrypoint_env): assert not (capture / "main-called").exists() +@pytest.mark.parametrize("enabled", [None, "false", "true"]) +@pytest.mark.parametrize( + "extra_args", + [ + f"--kv-transfer-config '{STOCK_CONFIG}'", + f"--kv-transfer-config={STOCK_CONFIG}", + f"--kv-transfer-config={shlex.quote(json.dumps(json.loads(DEFAULT_CONFIG)))}", + f"--uvicorn-log-level warning --kv-transfer-config {shlex.quote(DEFAULT_CONFIG)}", + ], +) +def test_rejects_connector_overrides_in_extra_args(entrypoint_env, enabled, extra_args): + run, capture, _ = entrypoint_env + result = run({"TELYS_ENABLED": enabled, "VLLM_EXTRA_ARGS": extra_args}) + + assert result.returncode == 64 + assert "--kv-transfer-config is not allowed in VLLM_EXTRA_ARGS" in result.stderr + assert "KV_TRANSFER_CONFIG" in result.stderr + assert not (capture / "main-called").exists() + assert not (capture / "api-called").exists() + assert not (capture / "oauth-called").exists() + + +@pytest.mark.parametrize("enabled", [None, "false", "true"]) +def test_generic_extra_args_remain_unchanged(entrypoint_env, enabled): + run, capture, _ = entrypoint_env + extra_args = ( + "--max-model-len 2048 --override-generation-config " + "'{\"max_new_tokens\": 512}' --uvicorn-log-level warning" + ) + result = run({"TELYS_ENABLED": enabled, "VLLM_EXTRA_ARGS": extra_args}) + + assert result.returncode == 0, result.stderr + assert captured_env(capture)["VLLM_EXTRA_ARGS"] == extra_args + + def test_enabled_supplies_connector_and_disables_async(entrypoint_env): run, capture, _ = entrypoint_env result = run({"TELYS_ENABLED": "true"}) From ca87e653a85430df41af342ac33ce73b99236711 Mon Sep 17 00:00:00 2001 From: 0xamlab <79715912+0xamlab@users.noreply.github.com> Date: Thu, 12 Nov 2026 11:07:23 -0500 Subject: [PATCH 3/4] Update Telys example to connector 0.1.5 --- docs/configuration.md | 8 ++++---- examples/telys/Dockerfile | 6 +++--- examples/telys/README.md | 15 +++++++++++---- tests/test_telys_example.py | 22 +++++++++++++++++++--- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 0ae9a1d8..85c8c428 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -167,10 +167,10 @@ is gone: [`examples/telys/`](../examples/telys/README.md) is a separate derived image; the standard worker image and its default behavior do not include or enable Telys. The -example's `TELYS_VLLM_COMMIT` build argument defaults to connector `v0.1.2` at -`49662f299b3c17b0f8c51050c8600cc8706362fd`, installed from the immutable `git+https` -source at that commit. Overrides must use a full 40-character lowercase SHA; branches, -tags, and short SHAs are rejected. +example's `TELYS_VLLM_COMMIT` build argument defaults to connector `v0.1.5` at +`3505b767cc9d6f9cfd7751fa3ad9946b92d54bb8`, installed from the immutable `git+https` +source at that commit. The derived image installs `telys==0.1.15`. Overrides must use +a full 40-character lowercase SHA; branches, tags, and short SHAs are rejected. The derived image adds these wrapper-level settings: diff --git a/examples/telys/Dockerfile b/examples/telys/Dockerfile index 0b446d04..64ef02ea 100644 --- a/examples/telys/Dockerfile +++ b/examples/telys/Dockerfile @@ -1,6 +1,6 @@ FROM runpod/worker-v1-vllm:v2.30.3 -ARG TELYS_VLLM_COMMIT=49662f299b3c17b0f8c51050c8600cc8706362fd +ARG TELYS_VLLM_COMMIT=3505b767cc9d6f9cfd7751fa3ad9946b92d54bb8 RUN python3 - "$TELYS_VLLM_COMMIT" <<'PY' import re import sys @@ -17,10 +17,10 @@ RUN apt-get update \ && apt-get install -y --no-install-recommends git \ && rm -rf /var/lib/apt/lists/* -RUN python3 -m pip install --no-cache-dir "telys==0.1.14" \ +RUN python3 -m pip install --no-cache-dir "telys==0.1.15" \ && python3 -m pip install --no-cache-dir --no-deps \ "telys-vllm @ git+https://github.com/thyn-ai/telys-vllm.git@${TELYS_VLLM_COMMIT}" \ - && python3 -c 'from importlib.metadata import version; vllm_version = version("vllm"); assert vllm_version == "0.32.0", f"expected vllm==0.32.0, found {vllm_version}"; telys_version = version("telys"); assert telys_version == "0.1.14", f"expected telys==0.1.14, found {telys_version}"; connector_version = version("telys-vllm"); assert connector_version == "0.1.2", f"expected telys-vllm==0.1.2, found {connector_version}"; from telys_vllm.connector import TelysKVConnector' + && python3 -c 'from importlib.metadata import version; vllm_version = version("vllm"); assert vllm_version == "0.32.0", f"expected vllm==0.32.0, found {vllm_version}"; telys_version = version("telys"); assert telys_version == "0.1.15", f"expected telys==0.1.15, found {telys_version}"; connector_version = version("telys-vllm"); assert connector_version == "0.1.5", f"expected telys-vllm==0.1.5, found {connector_version}"; from telys_vllm.connector import TelysKVConnector' COPY --chmod=0755 examples/telys/entrypoint.sh /usr/local/bin/telys-vllm-entrypoint diff --git a/examples/telys/README.md b/examples/telys/README.md index c04e309f..3efca49d 100644 --- a/examples/telys/README.md +++ b/examples/telys/README.md @@ -8,7 +8,7 @@ to the stock `runpod/worker-v1-vllm:v2.30.3` image (vLLM 0.32.0). The upstream w ## Build `TELYS_VLLM_COMMIT` defaults to -`49662f299b3c17b0f8c51050c8600cc8706362fd`, the source commit for connector `v0.1.2`. +`3505b767cc9d6f9cfd7751fa3ad9946b92d54bb8`, the source commit for connector `v0.1.5`. The Dockerfile installs from the immutable `git+https` source at that commit. Overrides must use a full 40-character lowercase SHA; branches, tags, short SHAs, and uppercase SHAs are rejected. @@ -18,16 +18,23 @@ Build from the worker repository root: ```bash docker build --platform=linux/amd64 \ --file examples/telys/Dockerfile \ - --build-arg TELYS_VLLM_COMMIT=49662f299b3c17b0f8c51050c8600cc8706362fd \ + --build-arg TELYS_VLLM_COMMIT=3505b767cc9d6f9cfd7751fa3ad9946b92d54bb8 \ --tag your-dockerhub-user/telys-worker-vllm:VERSION . ``` -The build installs `telys==0.1.14`, installs the connector directly from the pinned +The build installs `telys==0.1.15`, installs the connector directly from the pinned commit with `--no-deps`, and checks that vLLM remains exactly 0.32.0, the connector -distribution is 0.1.2, and `TelysKVConnector` imports. It does not bake in a model, +distribution is 0.1.5, and `TelysKVConnector` imports. It does not bake in a model, Telys credentials, or a signed Telys runtime. Publishing the resulting image is a separate operation. +The stable `telys-vllm==0.1.5` and `telys==0.1.15` packages are public on PyPI. The +connector project's stable GHCR release image is also public and can be pulled without +registry credentials at +`ghcr.io/thyn-ai/telys-worker-vllm@sha256:01b9b967a1d36e61ecb4ec3d2b179329762048e020e7dbbf0bc61285e7fbeb4b`. +The build above uses the immutable connector source commit rather than that prebuilt +image. + ## Stock behavior (default) Leave `TELYS_ENABLED` unset or set it to `false`. The entrypoint immediately executes diff --git a/tests/test_telys_example.py b/tests/test_telys_example.py index fc529829..dbe0cc98 100644 --- a/tests/test_telys_example.py +++ b/tests/test_telys_example.py @@ -14,7 +14,13 @@ DOCKERFILE = ROOT / "examples" / "telys" / "Dockerfile" ENTRYPOINT = ROOT / "examples" / "telys" / "entrypoint.sh" README = ROOT / "examples" / "telys" / "README.md" -CONNECTOR_COMMIT = "49662f299b3c17b0f8c51050c8600cc8706362fd" +CONNECTOR_COMMIT = "3505b767cc9d6f9cfd7751fa3ad9946b92d54bb8" +CONNECTOR_VERSION = "0.1.5" +TELYS_SDK_VERSION = "0.1.15" +PUBLIC_IMAGE = ( + "ghcr.io/thyn-ai/telys-worker-vllm@sha256:" + "01b9b967a1d36e61ecb4ec3d2b179329762048e020e7dbbf0bc61285e7fbeb4b" +) DEFAULT_CONFIG = ( '{"kv_connector":"TelysKVConnector",' '"kv_connector_module_path":"telys_vllm.connector","kv_role":"kv_both"}' @@ -346,7 +352,11 @@ def test_dockerfile_pins_final_connector_commit(): assert "apt-get install -y --no-install-recommends git" in dockerfile assert "--no-deps" in dockerfile assert 'vllm_version == "0.32.0"' in dockerfile - assert 'connector_version == "0.1.2"' in dockerfile + assert f'pip install --no-cache-dir "telys=={TELYS_SDK_VERSION}"' in dockerfile + assert f'telys_version == "{TELYS_SDK_VERSION}"' in dockerfile + assert f"expected telys=={TELYS_SDK_VERSION}" in dockerfile + assert f'connector_version == "{CONNECTOR_VERSION}"' in dockerfile + assert f"expected telys-vllm=={CONNECTOR_VERSION}" in dockerfile assert re.findall(r"(? Date: Thu, 12 Nov 2026 13:37:22 -0500 Subject: [PATCH 4/4] Update Telys connector to 0.1.6 --- docs/configuration.md | 4 ++-- examples/telys/Dockerfile | 4 ++-- examples/telys/README.md | 10 +++++----- tests/test_telys_example.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 85c8c428..ab26e7f3 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -167,8 +167,8 @@ is gone: [`examples/telys/`](../examples/telys/README.md) is a separate derived image; the standard worker image and its default behavior do not include or enable Telys. The -example's `TELYS_VLLM_COMMIT` build argument defaults to connector `v0.1.5` at -`3505b767cc9d6f9cfd7751fa3ad9946b92d54bb8`, installed from the immutable `git+https` +example's `TELYS_VLLM_COMMIT` build argument defaults to connector `v0.1.6` at +`2f0c20ccec56afcb613973e296281f51e23cbe26`, installed from the immutable `git+https` source at that commit. The derived image installs `telys==0.1.15`. Overrides must use a full 40-character lowercase SHA; branches, tags, and short SHAs are rejected. diff --git a/examples/telys/Dockerfile b/examples/telys/Dockerfile index 64ef02ea..48c15fc4 100644 --- a/examples/telys/Dockerfile +++ b/examples/telys/Dockerfile @@ -1,6 +1,6 @@ FROM runpod/worker-v1-vllm:v2.30.3 -ARG TELYS_VLLM_COMMIT=3505b767cc9d6f9cfd7751fa3ad9946b92d54bb8 +ARG TELYS_VLLM_COMMIT=2f0c20ccec56afcb613973e296281f51e23cbe26 RUN python3 - "$TELYS_VLLM_COMMIT" <<'PY' import re import sys @@ -20,7 +20,7 @@ RUN apt-get update \ RUN python3 -m pip install --no-cache-dir "telys==0.1.15" \ && python3 -m pip install --no-cache-dir --no-deps \ "telys-vllm @ git+https://github.com/thyn-ai/telys-vllm.git@${TELYS_VLLM_COMMIT}" \ - && python3 -c 'from importlib.metadata import version; vllm_version = version("vllm"); assert vllm_version == "0.32.0", f"expected vllm==0.32.0, found {vllm_version}"; telys_version = version("telys"); assert telys_version == "0.1.15", f"expected telys==0.1.15, found {telys_version}"; connector_version = version("telys-vllm"); assert connector_version == "0.1.5", f"expected telys-vllm==0.1.5, found {connector_version}"; from telys_vllm.connector import TelysKVConnector' + && python3 -c 'from importlib.metadata import version; vllm_version = version("vllm"); assert vllm_version == "0.32.0", f"expected vllm==0.32.0, found {vllm_version}"; telys_version = version("telys"); assert telys_version == "0.1.15", f"expected telys==0.1.15, found {telys_version}"; connector_version = version("telys-vllm"); assert connector_version == "0.1.6", f"expected telys-vllm==0.1.6, found {connector_version}"; from telys_vllm.connector import TelysKVConnector' COPY --chmod=0755 examples/telys/entrypoint.sh /usr/local/bin/telys-vllm-entrypoint diff --git a/examples/telys/README.md b/examples/telys/README.md index 3efca49d..0c4cee7f 100644 --- a/examples/telys/README.md +++ b/examples/telys/README.md @@ -8,7 +8,7 @@ to the stock `runpod/worker-v1-vllm:v2.30.3` image (vLLM 0.32.0). The upstream w ## Build `TELYS_VLLM_COMMIT` defaults to -`3505b767cc9d6f9cfd7751fa3ad9946b92d54bb8`, the source commit for connector `v0.1.5`. +`2f0c20ccec56afcb613973e296281f51e23cbe26`, the source commit for connector `v0.1.6`. The Dockerfile installs from the immutable `git+https` source at that commit. Overrides must use a full 40-character lowercase SHA; branches, tags, short SHAs, and uppercase SHAs are rejected. @@ -18,20 +18,20 @@ Build from the worker repository root: ```bash docker build --platform=linux/amd64 \ --file examples/telys/Dockerfile \ - --build-arg TELYS_VLLM_COMMIT=3505b767cc9d6f9cfd7751fa3ad9946b92d54bb8 \ + --build-arg TELYS_VLLM_COMMIT=2f0c20ccec56afcb613973e296281f51e23cbe26 \ --tag your-dockerhub-user/telys-worker-vllm:VERSION . ``` The build installs `telys==0.1.15`, installs the connector directly from the pinned commit with `--no-deps`, and checks that vLLM remains exactly 0.32.0, the connector -distribution is 0.1.5, and `TelysKVConnector` imports. It does not bake in a model, +distribution is 0.1.6, and `TelysKVConnector` imports. It does not bake in a model, Telys credentials, or a signed Telys runtime. Publishing the resulting image is a separate operation. -The stable `telys-vllm==0.1.5` and `telys==0.1.15` packages are public on PyPI. The +The stable `telys-vllm==0.1.6` and `telys==0.1.15` packages are public on PyPI. The connector project's stable GHCR release image is also public and can be pulled without registry credentials at -`ghcr.io/thyn-ai/telys-worker-vllm@sha256:01b9b967a1d36e61ecb4ec3d2b179329762048e020e7dbbf0bc61285e7fbeb4b`. +`ghcr.io/thyn-ai/telys-worker-vllm@sha256:1b02b3cdac471064e8b9968fe2ab87f99da2d455e04d9cffea6b74b745a4218f`. The build above uses the immutable connector source commit rather than that prebuilt image. diff --git a/tests/test_telys_example.py b/tests/test_telys_example.py index dbe0cc98..3376c787 100644 --- a/tests/test_telys_example.py +++ b/tests/test_telys_example.py @@ -14,12 +14,12 @@ DOCKERFILE = ROOT / "examples" / "telys" / "Dockerfile" ENTRYPOINT = ROOT / "examples" / "telys" / "entrypoint.sh" README = ROOT / "examples" / "telys" / "README.md" -CONNECTOR_COMMIT = "3505b767cc9d6f9cfd7751fa3ad9946b92d54bb8" -CONNECTOR_VERSION = "0.1.5" +CONNECTOR_COMMIT = "2f0c20ccec56afcb613973e296281f51e23cbe26" +CONNECTOR_VERSION = "0.1.6" TELYS_SDK_VERSION = "0.1.15" PUBLIC_IMAGE = ( "ghcr.io/thyn-ai/telys-worker-vllm@sha256:" - "01b9b967a1d36e61ecb4ec3d2b179329762048e020e7dbbf0bc61285e7fbeb4b" + "1b02b3cdac471064e8b9968fe2ab87f99da2d455e04d9cffea6b74b745a4218f" ) DEFAULT_CONFIG = ( '{"kv_connector":"TelysKVConnector",'