Skip to content

Add flyteplugins-llamacpp: serve GGUF models with llama.cpp - #1521

Merged
cosmicBboy merged 4 commits into
mainfrom
worktree-llamacpp-plugin
Sep 3, 2026
Merged

Add flyteplugins-llamacpp: serve GGUF models with llama.cpp#1521
cosmicBboy merged 4 commits into
mainfrom
worktree-llamacpp-plugin

Conversation

@cosmicBboy

Copy link
Copy Markdown
Collaborator

Summary

Adds a new flyteplugins-llamacpp plugin for serving GGUF models with llama.cpp's llama-server behind Flyte Apps, adapted from internal-union-apps/llm-service and following the existing vllm/sglang plugin structure.

  • LlamaCppAppEnvironment: OpenAI-compatible endpoint (/v1) + embedded Web UI. Serves weights from object storage (model_path as remote path / RunOutput / ArtifactValue, downloaded and mounted) or straight from a Hugging Face GGUF repo (model_hf_path--hf-repo, downloaded by llama-server at startup). Supports speculative decoding via draft_model_path / draft_model_hf_path (→ --model-draft / --hf-repo-draft), with tuning through extra_args.
  • llama-cpp-fserve shim (console script): the GGUF filename inside a mounted directory is unknown at deploy time, so the shim rewrites --model-dir/--draft-model-dir into concrete --model/--model-draft paths at startup (first-shard aware for sharded models) and execs llama-server.
  • build_llama_cpp_image: llama.cpp has no GPU pip wheel, so the default image compiles llama-server from source with CUDA 12.8 and the embedded SvelteKit Web UI (Node build), keeping the internal app's stub-linking and base64 RUN-script workarounds. Knobs: cuda_arch (fat binaries), repo/ref pinning, and cuda=False for a CPU-only image.

Not carried over from the internal app: the preset catalog, subdomain derivation, and deployment-config machinery (internal concerns, not plugin API).

CI needs no changes: unit tests, lint, and publish workflows auto-discover plugins.

Test plan

  • 39 unit tests (make unit_test_plugins with FLYTE_PLUGIN=plugins/llamacpp): env validation, argv construction, HF vs mounted weights, draft models, shell quoting, clone_with, and shim GGUF resolution.
  • ruff check/format clean; pre-commit (mypy, ty) passed.
  • Deploy smoke test on a live cluster.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MmFSWkpi4eoke3vBE64Wuc

Adds a LlamaCppAppEnvironment (adapted from internal-union-apps' llm-service)
following the vllm/sglang plugin structure:

- LlamaCppAppEnvironment serves GGUF weights from object storage
  (model_path / RunOutput / ArtifactValue) or straight from a Hugging Face
  GGUF repo (--hf-repo), with draft-model speculative decoding support.
- llama-cpp-fserve shim resolves the concrete .gguf inside the mounted
  model directory at startup (first-shard aware) and execs llama-server.
- build_llama_cpp_image compiles llama-server from source with CUDA (and
  the embedded Web UI), with knobs for CUDA arch, repo/ref pin, and a
  CPU-only variant.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MmFSWkpi4eoke3vBE64Wuc
@cosmicBboy
cosmicBboy marked this pull request as ready for review September 2, 2026 15:55
@cosmicBboy
cosmicBboy merged commit 434003c into main Sep 3, 2026
59 checks passed
@cosmicBboy
cosmicBboy deleted the worktree-llamacpp-plugin branch September 3, 2026 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant