Open-source inference server and production cluster for all the models your agent needs.
Python bgecolbertdata-pipelinedeep-learningembeddingsinferenceinference-serverinformation-retrievalllmmlmlopsnatural-language-processingnlppythonrerankingretrievalretrieval-augmented-generationsemantic-searchspladevector-search
feat(helm): mount equivalence evidence into remote lanes (#577)
Krisztian Gajdar738cf38d7a3a
diff --git a/deploy/helm/sie-cluster/README.md b/deploy/helm/sie-cluster/README.mdindex 6b1875d51..098fb81c5 100644--- a/deploy/helm/sie-cluster/README.md+++ b/deploy/helm/sie-cluster/README.md@@ -794,6 +794,16 @@ Below, `<fullname>` is the chart's full name: `<release>-sie-cluster`, orinto values. The chart checks these fields as the server does when itrenders, and a test sends the same URLs and definitions through the chartand the server's own parser.+- An upstream of kind `openai` may also declare `equivalence` (`max_age_s`, at+ most 604800, and `record_files`): the evidence that lets a model serve+ `encode` or `score` from both its local and its remote profile. Put the+ evidence files in a ConfigMap you create, for example+ `kubectl create configmap remote-equivalence --from-file=bge-m3.json`, and set+ `workers.remote.equivalence.configMap` to its name. Remote lanes mount it+ read-only at `/etc/sie/equivalence`, and every `record_files` path must then+ be `/etc/sie/equivalence/<key>`. No other lane receives it. Remote lanes read+ the files when they use them, so replacing the ConfigMap's data takes effect+ without a restart, once the kubelet has synced the volume.- Only the `worker` container of a `remote` lane receives the upstreams file(the `<fullname>-upstreams` Secret, mounted read-only) and the credentials(environment variables read from the Secrets you name). The file is adiff --git a/deploy/helm/sie-cluster/templates/_helpers.tpl b/deploy/helm/sie-cluster/templates/_helpers.tplindex 43c05ab3b..25759250c 100644--- a/deploy/helm/sie-cluster/templates/_helpers.tpl+++ b/deploy/helm/sie-cluster/templates/_helpers.tpl@@ -1675,6 +1675,15 @@ Args (dict): url, field, requireTls.{{- end -}}{{- end }}+{{/* The ConfigMap of equivalence evidence mounted into remote lanes, or "". */}}+{{- define "sie-cluster.upstreams.evidenceConfigMap" -}}+{{- $evidence := dig "remote" "equivalence" dict .Values.workers -}}+{{- if kindIs "map" $evidence -}}+{{- $name := dig "configMap" "" $evidence -}}+{{- if kindIs "string" $name -}}{{- $name -}}{{- end -}}+{{- end -}}+{{- end }}+{{/* Validate the worker-owned proof policy without repeating artifact paths. */}}{{- define "sie-cluster.upstreams.validateEquivalence" -}}{{- $policy := .upstream.equivalence -}}@@ -1703,6 +1712,12 @@ Args (dict): url, field, requireTls.{{- if not (and (kindIs "string" $name) (gt (len $name) 0) (le (len (splitList "" $name)) 256) (kindIs "string" $file) (gt (len $file) 0) (le (len (splitList "" $file)) 4096) (hasPrefix "/" $file)) -}}{{- fail (printf "%s record names must be bounded; file paths must be bounded and absolute" $path) -}}{{- end -}}+{{- if $.evidenceMounted -}}+{{- $key := trimPrefix "/etc/sie/equivalence/" $file -}}+{{- if not (and (hasPrefix "/etc/sie/equivalence/" $file) (regexMatch "^[-._a-zA-Z0-9]{1,253}$" $key) (ne $key ".") (ne $key "..")) -}}+{{- fail (printf "%s record files must be keys of workers.remote.equivalence.configMap, named /etc/sie/equivalence/<key>" $path) -}}+{{- end -}}+{{- end -}}{{- end -}}{{- end -}}{{- end }}@@ -1804,6 +1819,22 @@ credential pasted as a key would otherwise be printed.{{- if not (kindIs "bool" $serving) -}}{{- fail "workers.remote.serving must be a boolean" -}}{{- end -}}+{{- $evidence := dig "remote" "equivalence" dict $root.Values.workers -}}+{{- if not (kindIs "map" $evidence) -}}+{{- fail "workers.remote.equivalence must be a map with a configMap name" -}}+{{- end -}}+{{- range $field, $_ := $evidence -}}+{{- if ne $field "configMap" -}}+{{- fail "workers.remote.equivalence takes only configMap" -}}+{{- end -}}+{{- end -}}+{{- $evidenceConfigMap := dig "configMap" "" $evidence -}}+{{- if not (kindIs "string" $evidenceConfigMap) -}}+{{- fail "workers.remote.equivalence.configMap must be a ConfigMap name" -}}+{{- end -}}+{{- if and $evidenceConfigMap (not (and (le (len $evidenceConfigMap) 253) (regexMatch "^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$" $evidenceConfigMap))) -}}+{{- fail "workers.remote.equivalence.configMap must be a valid ConfigMap name" -}}+{{- end -}}{{- $chartSecretKeys := list -}}{{- $hfCache := $root.Values.workers.common.hfCache | default dict -}}{{- with $hfCache.tokenSecret -}}@@ -1904,7 +1935,7 @@ credential pasted as a key would otherwise be printed.{{- fail (printf "%s.kind must be sie or openai" $path) -}}{{- end -}}{{- include "sie-cluster.upstreams.validateOpenaiFields" (dict "upstream" $upstream "path" $path) -}}-{{- include "sie-cluster.upstreams.validateEquivalence" (dict "upstream" $upstream "path" $path) -}}+{{- include "sie-cluster.upstreams.validateEquivalence" (dict "upstream" $upstream "path" $path "evidenceMounted" (ne (include "sie-cluster.upstreams.evidenceConfigMap" $root) "")) -}}{{- include "sie-cluster.upstreams.validateUrl" (dict "url" $upstream.base_url "field" (printf "%s.base_url" $path) "requireTls" true) -}}{{- if not (kindIs "invalid" $upstream.proxy_url) -}}{{- include "sie-cluster.upstreams.validateUrl" (dict "url" $upstream.proxy_url "field" (printf "%s.proxy_url" $path) "requireTls" false) -}}diff --git a/deploy/helm/sie-cluster/templates/worker-statefulset.yaml b/deploy/helm/sie-cluster/templates/worker-statefulset.yamlindex 1fd9f40ce..d986d1c72 100644--- a/deploy/helm/sie-cluster/templates/worker-statefulset.yaml+++ b/deploy/helm/sie-cluster/templates/worker-statefulset.yaml@@ -162,6 +162,7 @@ fast at render time.{{- end }}{{- end }}{{- $deliverUpstreams := and $remoteLane (dig "remote" "serving" true $root.Values.workers) }}+{{- $evidenceConfigMap := include "sie-cluster.upstreams.evidenceConfigMap" $root }}{{- $poolSidecar := default dict $pool.sidecar }}{{- $emulatedChildCount := int (dig "emulatedChildCount" 0 $poolSidecar) }}{{- if and (gt $emulatedChildCount 0) (gt $gpuCount 0) }}@@ -533,6 +534,11 @@ spec:- name: upstreamsmountPath: /etc/sie/upstreamsreadOnly: true+ {{- if $evidenceConfigMap }}+ - name: equivalence+ mountPath: /etc/sie/equivalence+ readOnly: true+ {{- end }}{{- end }}{{- end }}{{- if $root.Values.workers.common.workerSidecar.enabled }}@@ -833,6 +839,13 @@ spec:- name: upstreamssecret:secretName: {{ include "sie-cluster.upstreams.secretName" $root }}+ {{- if $evidenceConfigMap }}+ # Equivalence evidence the upstreams' record_files name. Remote lanes+ # re-read it on use, so a replaced ConfigMap needs no restart.+ - name: equivalence+ configMap:+ name: {{ $evidenceConfigMap | quote }}+ {{- end }}{{- end }}{{- end }}{{- end }}diff --git a/deploy/helm/sie-cluster/values.yaml b/deploy/helm/sie-cluster/values.yamlindex 05c2a64ef..bfdd1e894 100644--- a/deploy/helm/sie-cluster/values.yaml+++ b/deploy/helm/sie-cluster/values.yaml@@ -920,6 +920,14 @@ workers:# iam.gke.io/gcp-service-account).serviceAccount:annotations: {}+ # -- Equivalence evidence for hybrid encode and score routing. Name an+ # existing ConfigMap whose keys are the evidence files that the upstreams'+ # equivalence.record_files name. It is mounted read-only at+ # /etc/sie/equivalence in remote lanes only, and every record_files path+ # must then be /etc/sie/equivalence/<key>. Remote lanes re-read the files on+ # use, so replacing the ConfigMap's data needs no restart.+ equivalence:+ configMap: ""# -- NetworkPolicy for the remote lanes' pods, rendered whenever a remote# lane is enabled. Ingress: only this release's gateway pods, on the worker# ports; the generic workers.networkPolicy then excludes the remote lanes.diff --git a/tools/ci/tests/test_helm_render.py b/tools/ci/tests/test_helm_render.pyindex ea40d4db0..ffbfa5b5d 100644--- a/tools/ci/tests/test_helm_render.py+++ b/tools/ci/tests/test_helm_render.py@@ -1702,6 +1702,123 @@ def test_changing_an_upstream_restarts_the_remote_lane(tmp_path: Path) -> None:assert checksum(before) != checksum(after)+EVIDENCE_CONFIG_MAP = "remote-equivalence-evidence"+++def evidence_values(record_file: str = "/etc/sie/equivalence/local-model.json", **remote: object) -> dict:+ values = remote_pool_values(l4={"enabled": True})+ values["upstreams"]["open-host"]["equivalence"]["record_files"] = {"local/model": record_file}+ values["workers"]["remote"] = {"equivalence": {"configMap": EVIDENCE_CONFIG_MAP}, **remote}+ return values+++def evidence_mounts(docs: list[dict]) -> dict[tuple[str, str, str], dict]:+ mounts = {}+ for doc, spec in pod_specs(docs):+ volumes = {+ volume["name"]+ for volume in spec.get("volumes", [])+ if volume.get("configMap", {}).get("name") == EVIDENCE_CONFIG_MAP+ }+ for container in [*spec.get("initContainers", []), *spec["containers"]]:+ for mount in container.get("volumeMounts", []):+ if mount["name"] in volumes:+ mounts[(doc["kind"], doc["metadata"]["name"], container["name"])] = mount+ return mounts+++def test_only_the_remote_lane_worker_mounts_equivalence_evidence(tmp_path: Path) -> None:+ docs = rendered_documents(tmp_path, evidence_values())++ assert evidence_mounts(docs) == {+ REMOTE_WORKER: {"name": "equivalence", "mountPath": "/etc/sie/equivalence", "readOnly": True}+ }+ (secret,) = [doc for doc in docs if doc["kind"] == "Secret" and doc["metadata"]["name"] == UPSTREAMS_SECRET]+ rendered = yaml.safe_load(secret["stringData"]["upstreams.yaml"])+ assert rendered["upstreams"]["open-host"]["equivalence"]["record_files"] == {+ "local/model": "/etc/sie/equivalence/local-model.json"+ }+++def test_a_remote_lane_without_remote_serving_mounts_no_evidence(tmp_path: Path) -> None:+ assert evidence_mounts(rendered_documents(tmp_path, evidence_values(serving=False))) == {}+++def test_replacing_the_evidence_does_not_restart_the_remote_lane(tmp_path: Path) -> None:+ def template_annotations(values: dict) -> dict:+ (statefulset,) = [+ doc+ for doc in rendered_documents(tmp_path, values)+ if doc["kind"] == "StatefulSet" and doc["metadata"]["name"] == REMOTE_WORKER[1]+ ]+ return statefulset["spec"]["template"]["metadata"]["annotations"]++ before = evidence_values()+ after = evidence_values()+ after["workers"]["remote"]["equivalence"]["configMap"] = "other-evidence"++ assert template_annotations(before) == template_annotations(after)+++ "record_file",+ [+ "/proofs/local-model.json",+ "/etc/sie/equivalence/",+ "/etc/sie/equivalence/..",+ "/etc/sie/equivalence/nested/local-model.json",+ "/etc/sie/equivalence-other/local-model.json",+ ],+)+def test_mounted_evidence_requires_each_record_file_to_be_one_of_its_keys(tmp_path: Path, record_file: str) -> None:+ error = render_error(tmp_path, evidence_values(record_file))++ assert "record files must be keys of workers.remote.equivalence.configMap" in error+ assert "/proofs/" not in error+++ "evidence",+ [+ {"configMap": "Upper"},+ {"configMap": "-leading"},+ {"configMap": "has_underscore"},+ {"configMap": "proofs..remote"},+ {"configMap": "proofs.-remote"},+ {"configMap": "proofs-.remote"},+ {"configMap": "proofs."},+ {"configMap": "a" * 254},+ {"configMap": 5},+ {"configMap": "evidence", "secret": "evidence"},+ "evidence",+ ],+)+def test_the_evidence_setting_names_one_valid_config_map(tmp_path: Path, evidence: object) -> None:+ values = evidence_values()+ values["workers"]["remote"]["equivalence"] = evidence++ assert "workers.remote.equivalence" in render_error(tmp_path, values)++[email protected]("name", ["evidence", "remote.equivalence-evidence", "a" * 63 + "." + "b" * 63])+def test_dotted_config_map_names_are_accepted(tmp_path: Path, name: str) -> None:+ values = evidence_values()+ values["workers"]["remote"]["equivalence"]["configMap"] = name+ docs = rendered_documents(tmp_path, values)++ (statefulset,) = [+ doc for doc in docs if doc["kind"] == "StatefulSet" and doc["metadata"]["name"] == REMOTE_WORKER[1]+ ]+ volumes = {volume["name"]: volume for volume in statefulset["spec"]["template"]["spec"]["volumes"]}+ assert volumes["equivalence"]["configMap"]["name"] == name+++def test_without_mounted_evidence_record_paths_are_only_checked_for_shape(tmp_path: Path) -> None:+ docs = rendered_documents(tmp_path, remote_pool_values())++ assert evidence_mounts(docs) == {}++def upstream(**overrides: object) -> dict:definition: dict = {"kind": "sie",