Skip to content

perf(k8s): serve Qwen3 embeddings on TEI with Ollama fallback #4975

Done

Description

@dan-petty

Update 2026-11-26 (infra move): the serving work is now in dan-petty/homelab.

  • The TEI Deployment, the gateway order and the live proofs are a follow-up issue there.
  • This issue keeps the AI spend change in k8s/devops/dashboards/ai-spend.json, so TEI embedding tokens count as local.
  • A new manifest file also needs a line in MANIFESTS_BY_STACK here (devops k8s deploy-stack).
  • Read each k8s/llm path below as a homelab path.

Follow-up: dan-petty/homelab#286.


Problem or Motivation

The two Ollama embed pods (ollama-24gib-embed-gpu0 and -gpu1, Pascal P6000) queue. Measured at the gateway over 7 days:

  • each batch request has p50 8.4 s and p95 28.6 s;
  • 745 requests took over 30 s, and 529 calls ended with status 499 in 30 days;
  • each pod is busy about 42% of the day.

Ollama makes one runner call for each input, with no token batching, and interactive query embeddings wait behind bulk batches.

In the cluster trial of 2026-11-11 (#4961), TEI 1.9.4 on one RTX 3090 embedded with Qwen3-Embedding-0.6B at up to 40,971 tokens/s (151 texts/s), against 6,626 tokens/s (45 texts/s) for both Ollama pods through the gateway. Its single-query latency was p50 4.0 ms and p95 4.5 ms, with a VRAM peak of 2,258 MiB. Its vectors match the Ollama route (cosine min 0.9984), so no re-embed is necessary. This is a speed change, not a quality change.

TEI does not run on the Pascal GPUs (cc 6.1). A move needs a share of an Ampere or newer GPU. With the rerank pod of #4970 on the same RTX 3090, both TEI pods leave about 1.1 GiB of the 7-day headroom.

Proposed Solution & Architectural Design

Do this only if the trial #4968 shows that the shared GPU keeps the chat tier safe.

  • Add a TEI 1.9.4 Deployment with Qwen/Qwen3-Embedding-0.6B at revision 97b0c614 on an Ampere or newer GPU (the Blackwell node when it is Ready again), with the pattern of feat(k8s): serve a cross-encoder rerank route on TEI #4970.
  • In LiteLLM, keep model_name: qwen3-embedding:0.6b. Add the TEI deployment (openai/ provider, api_base <tei-embed-service>/v1) as order 1, and keep the two Ollama deployments as order 2 for fallback.
  • The client keeps its query instruction prefix. Set no TEI default prompt.
  • The model name does not change, so the retriever model check, the Qdrant points and the cache keys stay valid.
  • Decide the future of the Pascal GPUs in the same change: PyTorch CUDA 12.6 wheels, the last with sm_61 and sm_70, stop at PyTorch 2.15, and only Ollama and llama.cpp still run on them.

Target Subsystem

Kubernetes manifests in k8s/llm and the LiteLLM gateway config of dan-petty/homelab (follow-up issue), and the AI spend dashboard.

Existing Tool Considered

Hugging Face Text Embeddings Inference 1.9.4 (Apache-2.0) with Qwen/Qwen3-Embedding-0.6B (Apache-2.0), LiteLLM order fallback, Argo CD and DCGM. No code is added to the CLI. Estimated cost: about 0.20M tokens and 3 hours.

Acceptance criteria

  • Gateway embedding p95 <= 5 s over 7 days (today 28.6 s), and 0 status 499 in 7 days.
  • Single-query embedding p95 <= 250 ms during a full re-index.
  • When the TEI pod stops, embedding calls go to Ollama with no client error.
  • Cosine of TEI and Ollama vectors >= 0.998 on 100 texts. Eval nDCG@10 changes by less than the bootstrap interval. No re-index.
  • The chat tier on the shared GPU has 0 OOM restarts in 7 days.

Dependencies

#4968 (the GPU trial) and #4970 (the TEI deployment pattern).

Source: #4961

Alternatives check of 2026-11-26: not-applicable.
Class: perf, no model call.
Tool: none found.

Proposed design

Problem statement

The two Pascal Ollama embed pods queue: gateway embedding p95 is 28.6 s over 7 days and 529 calls ended with status 499 in 30 days. The TEI trial of 2026-11-11 matched the Ollama vectors at cosine 0.9984 and served much faster. The TEI Deployment, the gateway order and the live proofs moved to dan-petty/homelab#286 in the infra repo dan-petty/homelab. This issue keeps the AI spend change: the dashboard must count the TEI embedding tokens as local savings, so the local savings do not fall when the embedding traffic moves off Ollama. dan-petty/homelab#286 must use a LiteLLM provider label that no hosted provider uses.

Acceptance criteria

Requirement: TEI embedding tokens count as local savings

The AI spend dashboard SHALL include the provider label of the TEI embedding deployment in the in-cluster filter of every local-savings query, and SHALL name that provider in the description of each local-savings panel.

Scenario: The k8s check accepts the AI spend dashboard

  • WHEN a person runs uv run devops ci --check --only k8s after the change
  • THEN the check exits 0 and reports no error for k8s/devops/dashboards/ai-spend.json.

Requirement: The TEI prompt tokens get the embedding price

The local-savings query MUST map the TEI provider to operation embeddings, so its prompt tokens join the reference price at the embedding operation and not the chat operation.

Scenario: The k8s check accepts the local-savings query

  • WHEN a person runs uv run devops ci --check --only k8s after the change
  • THEN the check exits 0 and reports no error for the rendered dashboard.

Requirement: Pending a person after the merge

The change MUST show the TEI embedding tokens as local savings in the AI spend dashboard after dan-petty/homelab#286 serves the TEI deployment.

Scenario: A person reads the local savings after the TEI deployment is live

  • WHEN a person queries sum(increase(litellm_input_tokens_metric_total{api_provider="hosted_vllm"}[1h])) in Prometheus after the TEI deployment serves traffic
  • THEN the query returns a value above zero, and the Local Cloud Savings in Range panel counts that value.

Existing Tool Considered

The alternatives check of 2026-11-26 gives not-applicable for this perf item and found no tool; the block in the issue body holds that result. Grafana, with Prometheus and the LiteLLM counters, covers the need: the change edits the existing dashboard k8s/devops/dashboards/ai-spend.json and builds no code. The TEI Deployment and its provider label land in dan-petty/homelab#286, so the cost of that work is not in this issue.

Key questions

  • Which provider label does the dashboard use for the TEI embedding tokens?: The TEI deployment uses LiteLLM's self-hosted OpenAI-compatible provider hosted_vllm/, so its api_provider label is hosted_vllm. The dashboard adds hosted_vllm to the in-cluster filter of each local-savings query and maps it to operation embeddings. No hosted provider uses that label, so a hosted call never counts as local savings. dan-petty/homelab#286 must set the same provider. (best practice) [sources: k8s/devops/dashboards/ai-spend.json]
  • Does the reference embedding price change for the TEI tokens?: No. The dashboard prices an embedding prompt token at the hosted price of qwen/qwen3-embedding-8b. The TEI deployment serves the same 0.6B model as the Ollama route, so the reference price stays. [sources: k8s/devops/dashboards/ai-spend.json, src/devops_cli/ai/spend/pricing.py]
  • Do the embedding model name and the vector dimension change?: No. The gateway keeps model_name: qwen3-embedding:0.6b, and the TEI deployment serves Qwen/Qwen3-Embedding-0.6B under that name. The retriever model check, the Qdrant points and the cache keys stay valid. [sources: k8s/devops/dashboards/ai-spend.json, tests/ai/rag/test_embedding_model_compatibility.py]
  • Where do the TEI Deployment, the gateway order and the live proofs go?: They go to dan-petty/homelab#286 in the infra repo dan-petty/homelab. This issue keeps the AI spend dashboard change only. [sources: CONTEXT.md]
  • What happens to the MANIFESTS_BY_STACK line and the Pascal GPU decision?: The proposal defers the MANIFESTS_BY_STACK line to a new issue, because the manifest file lands in dan-petty/homelab#286. The Pascal GPU decision is a hardware decision and moves with the serving work to dan-petty/homelab#286. (best practice) [sources: src/devops_cli/commands/k8s/stack_lifecycle.py:293, CONTEXT.md]
    • Chosen: Defer the MANIFESTS_BY_STACK line to a new issue. deploy-stack would name a manifest file that the environment tree does not hold until dan-petty/homelab#286 merges.
    • Rejected: Add the line in this change. The path does not exist in the environment tree yet.
    • Rejected: Block this issue on dan-petty/homelab#286. The dashboard change is workable now, and a post-merge live proof covers the rest.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Moved to new items

#7365

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/infra
    scope/k8s
    status/new
    value/high
    effort/medium
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 12, 2026
  5. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: perf. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.

  6. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 181f85e while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  7. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  8. added
    status/ready
    and removed
    status/new
    on Nov 27, 2026
  9. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

  10. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 29, 2026
  11. removed
    status/in-review
    on Nov 29, 2026
  12. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 16:50 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/k8ssource/agenttype/infravalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions