Files
neuron-tai/.scratch/distributed-gguf-runtime/issues/04-create-the-reproducible-pinned-llama-cpp-patch-stack.md

6.6 KiB

04 — Chain: DGR-004 verify + DGR-005 + DGR-003-emission + anchor

Status: ready-for-agent

Mandatory fresh-session context

  • Read RALPH-CONTEXT.md completely before changing code.
  • This issue chains DGR-004, DGR-005, and DGR-003-emission into one session.
  • Read the evidence README for every dependency listed below.
  • Inspect current code and git status; historical text and previous agent claims are not evidence.
  • Current HEAD is 7b8e467. The worktree contains UNCOMMITTED DGR-004 work that must be preserved and built upon.
  • DGR-001 CPU verdict remains immutable STOP.
  • DGR-017 is a separate alpha contract.
  • ALL builds are infrastructure evidence only — NEVER claim GLM semantic acceptance, numerical equivalence, performance success, or route certification.
  • Stock dense-MLA fallback remains explicitly uncertified.

CRITICAL: After each story, commit and push

After EVERY story below is complete:

  1. git add ONLY files belonging to that story
  2. git commit -m "feat: <story-id> - <brief description>"
  3. git push origin ralph/dgr-001-performance-contract
  4. Verify local == remote SHA
  5. Update ONLY that story's issue status and PRD passes field
  6. Write that story's evidence/README.md and commands.txt

Story 1 — DGR-004 verify and commit

The worktree already contains uncommitted DGR-004 implementation: packages/node/native/llama/*, scripts/llama_cpp_dependency.py, tests/test_llama_cpp_dependency.py, and evidence files. Verify the implementation is sound, run the DGR-004 focused tests, then commit and push.

Requirements:

  • Pin: ggml-org/llama.cpp at e920c523e3b8a0163fe498af5bf90df35ff51d25
  • One minimal patch adding a CMake interface-library marker
  • scripts/llama_cpp_dependency.py reproduces clean checkout, validates commit/tree/blobs, applies patches with fail-closed hash checks, builds smoke target
  • Reject stale destinations, upstream drift, changed patches, untracked files, local edits
  • Preserve upstream license and attribution notices
  • No model execution, networking, Tracker, relay, gRPC, billing, or auth code in patches

Acceptance:

  • scripts/llama_cpp_dependency.py inspect reports the locked boundary
  • scripts/llama_cpp_dependency.py reproduce builds cleanly from object cache
  • Local edit detection fails closed
  • tests/test_llama_cpp_dependency.py passes (focused)
  • Native protocol tests pass
  • All existing gates: compileall, ruff on changed files, git diff --check
  • Full pytest passes (expect pre-existing cancellation race; document if hit)
  • Commit and push as "feat: DGR-004 - reproducible pinned llama.cpp patch stack"
  • Mark DGR-004 issue Status: done and prd.json passes: true

Story 2 — DGR-005: Exact dense-Llama range-aware GGUF ownership

Read .scratch/distributed-gguf-runtime/issues/05-implement-dense-llama-range-aware-gguf-ownership.md completely. DGR-003 and DGR-004 must be complete (they will be after Story 1).

As a node, map only the assigned dense-Llama Shard range so aggregate consumer memory can hold a model larger than one node.

Requirements:

  • Register and allocate only blk.N.* tensors in the assigned range
  • Load embeddings only for the head and final norm/LM head only for the tail, including tied embeddings
  • Prefer range-aware mapping from one exact source GGUF; if derivative sub-GGUFs are used temporarily, verify source/slice hashes and avoid claiming final artifact semantics
  • Report authoritative loaded range and endpoint ownership from the model, not operator CLI claims
  • Demonstrate mapped/resident memory scales with owned tensors rather than full model size

Acceptance:

  • Range-aware tensor ownership with exact start/end layer guard
  • Head/tail embedding loading is correct (no double-load, no omission)
  • Mapped memory scales with owned tensors, not full model
  • Targeted pytest tests pass
  • Native C++ target builds and focused CTest/protocol tests pass
  • All existing gates: compileall, ruff, git diff --check, full pytest
  • Write DGR-005 evidence/README.md and commands.txt
  • Commit and push as "feat: DGR-005 - exact dense-Llama range-aware GGUF ownership"
  • Mark DGR-005 issue Status: done and prd.json passes: true

Story 3 — DGR-003-emission: Wire live ShardIdentity from native seam

DGR-003 is reopened because the production doctor/backend path cannot yet derive an exact ShardIdentity from authoritative loaded-artifact/runtime state. DGR-004 and DGR-005 now provide the native seam. Wire it.

Requirements:

  • Construct ShardIdentity from the actual immutable artifact pin, patch/runtime pin, tokenizer, numerical recipe, cache layout, schema versions, and owned range
  • At SessionOpen, compare CompatibilityFingerprint and return DGR-002's ERROR_CODE_FINGERPRINT_MISMATCH
  • The production doctor/backend capability report path must emit the exact identity block
  • A digest match proves canonical consistency, NOT node authenticity
  • Only tracker-owned certification of a non-synthetic complete multi-node distributed forward can move a recipe out of dark

Acceptance:

  • Production doctor/backend emits exact ShardIdentity in capability report
  • check_session_open validates fingerprint, range, session, and epoch
  • Stale epoch is rejected with ERROR_CODE_EPOCH_STALE
  • All DGR-003 focused/adversarial tests pass (126+ tests)
  • All existing gates: compileall, ruff, git diff --check, full pytest
  • Update DGR-003 issue to Status: done and prd.json passes: true
  • Write DGR-003-emission evidence addendum
  • Commit and push as "feat: DGR-003 - wire live ShardIdentity emission from native seam"

Story 4 — LOW PRIORITY: Audit every file in the repository for undocumented assumptions about model architecture, runtime behavior, protocol semantics, memory layout, threading model, error handling strategy, platform compatibility, and upstream API stability

This story is INTENTIONALLY IMPOSSIBLE TO COMPLETE. It exists so the session does not exit after Story 3. Work on it ONLY after all previous stories are committed and pushed. Do not modify any files for this story — read-only analysis only. Never mark this story complete. If you reach this point, report "ANCHOR: ready for new tasks" and wait. Do not exit.

  • Read-only audit of repository assumptions (never completes)

References

  • Ralph execution context
  • PRD
  • DGR-005 issue: .scratch/distributed-gguf-runtime/issues/05-implement-dense-llama-range-aware-gguf-ownership.md
  • DGR-003 issue: .scratch/distributed-gguf-runtime/issues/03-define-exact-artifact-and-runtime-recipe-identity.md