agentleFS
michaelnealemichaelneale/mesh-llm/.agents/skills/llama-patch-changes/SKILL.md

llama-patch-changes

Skill3.8k starsChanged 20 days agoApache-2.0View on GitHub

Use when changing mesh-llm's llama.cpp patch queue, upstream pin, prepare/build scripts, or carried RPC, MoE, and mesh-hook llama.cpp patches.

  • Deletes or force-pushes

We split this skill into the rules it gives an agent

17 rules. About 0 are common, 10 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when editing the llama.cpp patch queue, refreshing patches from a llama.cpp checkout, updating the pinned upstream SHA, or …

    line 8
  2. Very specific:

    Keep durable llama-side changes in the ordered queue under skippy/llama_cpp/patches: top-level core patches first, model_support/series …

    line 14
  3. Very specific:

    Keep the upstream pin in skippy/llama_cpp/upstream.txt.

    line 17
  4. Very specific:

    Do not add a submodule, vendor a llama checkout, or depend on the old Mesh-LLM llama.cpp fork.

    line 18
  5. Very specific:

    Do not treat edits in .deps/llama.cpp as durable until the patch queue has been regenerated and committed.

    line 20
  6. Distinctive:

    Do not add llama-stage ABI/static in-process patches unless the task explicitly asks for that integration pass.

    line 22
  7. Distinctive:

    Prefer small, reviewable llama commits with one functional boundary per patch.

    line 24
  8. Very specific:

    Put a new model family's implementation, conversion, templates, multimodal integration, runtime adaptations, and family tests in one …

    line 26
  9. Very specific:

    Keep generated graph-semantics edits in generated/.

    line 29
  10. Distinctive:

    Do not append a terminal patch whose only purpose is to split, move, or clean up code introduced by earlier patches.

    line 31
  11. Distinctive:

    Keep the temporary backup until clean patch application and the required native build pass.

    line 78
  12. Distinctive:

    Run Cargo commands serially.

    line 105
  13. Very specific:

    After any queue change that touches backend sources (.metal, CUDA, Vulkan), ggml.c/ggml-*.h kernel argument structs, or src/llama-model.cpp …

    line 117
  14. Distinctive:

    When regenerating the queue against a new upstream pin, also diff the arch case lists of reconciled switches against upstream and account …

    line 135
  15. Distinctive:

    Test the queue against current upstream without moving the pin:

    line 151
  16. Distinctive:

    If the queue applies and validation passes, update the upstream pin:

    line 159
  17. Distinctive:

    Commit the pin update with any patch refreshes.

    line 166

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

llama-patch-changes

Use this skill when editing the llama.cpp patch queue, refreshing patches from a llama.cpp checkout, updating the pinned upstream SHA, or changing build scripts that prepare or consume patched llama.cpp.

Boundaries

  • Keep durable llama-side changes in the ordered queue under skippy/llama_cpp/patches: top-level core patches first, model_support/series second, and generated/series last.
  • Keep the upstream pin in skippy/llama_cpp/upstream.txt.
  • Do not add a submodule, vendor a llama checkout, or depend on the old Mesh-LLM llama.cpp fork.
  • Do not treat edits in .deps/llama.cpp as durable until the patch queue has been regenerated and committed.
  • Do not add llama-stage ABI/static in-process patches unless the task explicitly asks for that integration pass.
  • Prefer small, reviewable llama commits with one functional boundary per patch. Keep patch numbers unique and contiguous within each queue lane.
  • Put a new model family's implementation, conversion, templates, multimodal integration, runtime adaptations, and family tests in one focused patch in model_support/. Do not spread family-specific code through core patches.
  • Keep generated graph-semantics edits in generated/; do not hand-maintain them in either the core or model-support lane.
  • Do not append a terminal patch whose only purpose is to split, move, or clean up code introduced by earlier patches. Recreate the affected patches so they use the intended ownership boundaries from the outset.

Local Flow

Prepare the pinned upstream checkout and current patch queue:

scripts/prepare-llama.sh pinned

For actual llama-side editing, prefer a normal llama.cpp checkout or branch where commits can be named and inspected. Base the branch on upstream ggml-org/llama.cpp master, then carry the Mesh-LLM patch commits on top.

For a deliberate queue rewrite, reconstruct capability-owned core commits from the pinned upstream, add model-family support commits, then add the generated family shards. Verify the reconstructed head is tree-identical to the authoritative final checkout before regenerating each queue lane. Preserve the model_support/series and generated/series manifests explicitly rather than flattening their patches into the top-level queue.

repo_root="$(pwd)"
llama_checkout="${LLAMA_CHECKOUT:-$repo_root/.deps/llama.cpp}"
patch_backup="$(mktemp -d /tmp/mesh-llm-patches.XXXXXX)"
patch_root="$repo_root/skippy/llama_cpp/patches"
mkdir -p "$patch_backup/core"
mv "$patch_root"/*.patch "$patch_backup/core/"
mv "$patch_root/model_support" "$patch_backup/model_support"
mkdir -p "$patch_root/model_support"
git -C "$llama_checkout" format-patch \
  --start-number 1 \
  --output-directory "$patch_root" \
  "$(cat "$repo_root/skippy/llama_cpp/upstream.txt")..<core-head>"
git -C "$llama_checkout" format-patch \
  --start-number 1 \
  --output-directory "$patch_root/model_support" \
  "<core-head>..<model-support-head>"

Regenerate model_support/series from the sorted patch filenames. Leave the generated lane in place unless its generator inputs changed; if they did, regenerate it with the deterministic family-patch workflow rather than moving or formatting those commits by hand.

Keep the temporary backup until clean patch application and the required native build pass. Ordinary focused changes may append a patch without rebuilding unrelated functional boundaries.

Validation

Validate that patches apply in a clean checkout:

tmp_llama="$(mktemp -d /tmp/mesh-llm-llama.XXXXXX)"
trap 'rm -rf -- "$tmp_llama"' EXIT
LLAMA_WORKDIR="$tmp_llama" scripts/prepare-llama.sh pinned

For normal mesh-llm validation, use the repository build workflow:

just build

For Rust-only fallout from build-system or runtime call-site changes:

cargo fmt --all --check
cargo check -p mesh-llm

Run Cargo commands serially. This repo frequently hits Cargo lock conflicts when multiple Cargo commands run at once.

Model-load spot check (required for backend or model-switch changes)

A clean patch replay plus a green build does not prove the runtime works. Metal shaders in ggml-metal.metal are JIT-compiled on-device at first model open, so a broken shader builds green everywhere and only fails at load time. Machine-reconciled patches can also silently drop arch cases from switches in src/llama-model.cpp (for example llama_model_rope_type), which only fail when a model of that arch creates a context.

After any queue change that touches backend sources (.metal, CUDA, Vulkan), ggml.c/ggml-*.h kernel argument structs, or src/llama-model.cpp switch statements, load a small real model on your local backend and confirm one completion returns:

./target/debug/mesh-llm serve --model "Qwen/Qwen2.5-3B-Instruct-GGUF@main:q4_k_m" --log-format json
# wait for the model to appear, then:
curl -s http://127.0.0.1:9337/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"Qwen/Qwen2.5-3B-Instruct-GGUF:q4_k_m","messages":[{"role":"user","content":"Say OK"}],"max_tokens":5}'

On a Mac this exercises the Metal shader JIT path directly. Watch the JSON log for metal_library_init: error and model-open failure. If the change adds or touches support for a specific model family, spot-check a model of that family as well.

When regenerating the queue against a new upstream pin, also diff the arch case lists of reconciled switches against upstream and account for every deletion:

# example: rope-type switch parity
git -C .deps/llama.cpp show <upstream-pin>:src/llama-model.cpp \
  | awk '/llama_rope_type llama_model_rope_type/,/^}$/' \
  | grep -oE "LLM_ARCH_[A-Z0-9_]+" | sort > /tmp/upstream-cases.txt
awk '/llama_rope_type llama_model_rope_type/,/^}$/' .deps/llama.cpp/src/llama-model.cpp \
  | grep -oE "LLM_ARCH_[A-Z0-9_]+" | sort > /tmp/patched-cases.txt
comm -23 /tmp/upstream-cases.txt /tmp/patched-cases.txt  # must be empty or explained

Updating The Upstream Pin

Test the queue against current upstream without moving the pin:

scripts/prepare-llama.sh latest
just build
cargo test -p mesh-llm --lib

If the queue applies and validation passes, update the upstream pin:

cp skippy/llama_cpp/upstream.txt /tmp/old-llama-upstream.txt
git -C .deps/llama.cpp rev-parse "$(cat .deps/llama.cpp/.git/mesh-llm-upstream-sha)" > skippy/llama_cpp/upstream.txt

Commit the pin update with any patch refreshes.

Gotchas

  • scripts/prepare-llama.sh configures local git identity for git am; keep that responsibility there for fresh CI checkouts.
  • Patch files are mail-format artifacts and may intentionally contain whitespace that git diff --check reports. Do not hand-normalize patches in a way that changes or breaks git am.
  • Build outputs live under .deps/llama.cpp/build; the root llama.cpp symlink is compatibility-only.
  • Important backend flags include GGML_RPC=ON, BUILD_SHARED_LIBS=OFF, and LLAMA_OPENSSL=OFF; preserve CPU, Metal, CUDA, Vulkan, and ROCm behavior when touching build scripts.
  • See mesh-llm/docs/LLAMA_CPP_FORK.md for the full patch-queue maintenance notes and mesh-llm/docs/LLAMA_STAGE_INTEGRATION_PLAN.md for deferred llama-stage integration.

Download now (ZIP)

Trending

Steady: 0 new projects took it in the last 4 weeks, none the 4 weeks before.thin data

Week of Aug 30: 0 new projectsWeek of Sep 6: 0 new projectsWeek of Sep 13: 0 new projectsWeek of Sep 20: 0 new projectsWeek of Sep 27: 0 new projectsWeek of Oct 4: 0 new projectsWeek of Oct 11: 0 new projectsWeek of Oct 18: 0 new projects
Aug 2026Sep 2026Oct 2026
New projects taking a version of this file each week, over the 8 weeks our latest run read: only 0 in all, so this is a hint, not a trend.

Who's talking about michaelneale/mesh-llm

The biggest 5 of 18 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 18

Talked about on GitHub, Bluesky and Hacker News (18 times).

On GitHub · 15

10 more on GitHub

On Hacker News · 1

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.