Conversation
Add the DEEPSEEK41 model architecture enum, its GGUF metadata keys (hidden size, MoE routing, index attention, Engram config) and tensor names, plus the DeepSeek-V4.1-specific hparams fields (kv/index source layer maps, engram layer bitset). Reconciled onto the current gguf-py constants and llama-arch content. Assisted-by: Claude Sonnet 5 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… infra Add llama_bounded_file, a direct-IO-aware file reader abstraction with exception-based error handling, and integrate it into llama_ple_disk's row-gather path (replacing the old raw pread/O_DIRECT logic) while keeping master's current gather/dequant job scheduling and read-size accounting intact. Add llama_engram (fixed-capacity KV/index recall state) and llama_expert_store (host-resident MoE expert weight cache) as new standalone modules, plus their unit tests. Extend llama_mmap, llama_kv_cache and llama_memory with the small hooks these modules need. Assisted-by: Claude Sonnet 5 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add llama-dsv41, the DeepSeek V4.1-specific glue that binds Engram recall state and the expert store to the model runtime hparams, and llama-memory-dsv41, the llama_memory implementation that admits and schedules Engram/expert state per sequence. Add unit tests for the engram runtime, expert runtime, and memory admission paths. Assisted-by: Claude Sonnet 5 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add llama_model_deepseek41's arch graph, hparam and tensor loading in src/models/deepseek41.cpp, and register it in the model factory and llama_model::create_memory. Reconcile llama-model.cpp, llama-model.h, llama-model-loader.cpp, llama-context.cpp and llama-graph.cpp against master's own drift since the merge-base this content is sourced from: - llama-model-loader gains register_external_tensor and an external_read tracker so expert-store tensors can be read straight from disk instead of being mapped or fully loaded; load_all_data and init_mappings take explicit load_from_mmap/discard_file_cache parameters instead of assuming the loader-wide mmap setting. - llama-model's load_tensors keeps mmap unsafe for any context that overlaps an external tensor range, still applying master's own ple_on_disk/lazy-mode-direct mapping skip alongside it. - llama-context adds a memory-context commit/rollback transaction guard around graph compute, and model runtime acquire/release hooks used by the dsv41 engram/expert runtime. - llama-graph's build_moe_ffn takes a separate expert lookup tensor from the routing tensor, needed because dsv41's expert store lets the physical MoE weight slot differ from the logical expert id. Add --expert-cache-slots/--expert-cache-mib CLI options and extend test-llama-archs.cpp with a no-allocation DeepSeek V4.1 graph-shape smoke test (its full published geometry is too large for the compact generated-model fixture used by the rest of that test). Assisted-by: Claude Sonnet 5 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add scripts/strix_memory_watchdog.py, a standalone process-group supervisor that requires zero active swap and stops a wrapped command before host-wide memory reaches a validation ceiling. This is a plain external monitoring script: it does not touch or link against llama.cpp runtime code, and is unrelated to the (deliberately excluded from this layer) in-process host-memory-guard integration. Add its unit tests, usage docs, and a README table entry. Use a full git commit hash instead of the short form for GGML_BUILD_COMMIT so a build can be traced back unambiguously during a watchdog-flagged run. Assisted-by: Claude Sonnet 5 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Register the new DeepSeek V4.1 unit tests (schema, engram, expert store, memory admission, runtime) and the test-deepseek41-no-alloc allocation-guard case for the deepseek41 arch. Register the Python strix-memory-watchdog unit test alongside the other python-labeled tests. This intentionally omits the trace-harness and native-containment test registrations (test-server-child-protocol.cpp, test-deepseek41- trace.py, LLAMA_DEEPSEEK_V41_NATIVE_CONTAINMENT_TESTS); those depend on tools/deepseek-v41-trace/ and tools/server/ content that is out of scope for this layer and will be added by the next layer. Assisted-by: Claude Sonnet 5 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
POSIX_FADV_WILLNEED is not declared on macOS, so the unconditional posix_fadvise() call in prefetch() failed to compile there. Guard it the same way discard_cache() already guards POSIX_FADV_DONTNEED in llama-mmap.cpp: skip the readahead hint when the macro is unavailable, Linux behaviour is unchanged. Assisted-by: Claude Sonnet 5 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
@dzannotti Reopening this as a clean revival of #49 (and its siblings #59/#60), which you closed citing two specific issues: PRs "poorly stacked" against Both are fixed here, concretely:
Both PR descriptions include a full scope accounting, what was/wasn't verified, and an AI-authorship disclosure. What I'm asking for: a re-review of this PR and #67 with the above in mind. If either issue resurfaces, or anything else needs attention, please say so directly and I'll fix it before requesting merge. |
|
Closing and superseding with #70. Same content, same 7 commits, byte-identical diff -- but this PR's commits carried a real name + machine hostname as git author/committer ( |
Overview
This is Layer 1 (PR A) of a two-PR stack reviving closed PR #59 ("trace : recover DeepSeek V4.1 correctness harness"), which was closed alongside #49 and #60 for two reasons: (1) all three PRs targeted
masterdirectly instead of stacking, so each diff showed the combined content of its unmerged predecessors; (2) leaked personal paths. This PR succeeds #49 with the same substantive content, properly restacked with clean history and no personal paths.This layer adds the core DeepSeek V4.1 runtime, scoped as the model-execution half of the correctness-harness effort tracked in #48:
LLM_ARCH_DEEPSEEK41registration and GGUF schema (gguf-py/gguf/constants.py,src/llama-arch.{cpp,h})src/models/deepseek41.cpp,src/llama-model.cpp,src/llama-model-loader.cpp,src/llama-graph.cpp,src/llama-context.cpp,include/llama.h,common/arg.cpp)src/llama-engram.*,src/llama-expert-store.*,src/llama-dsv41-engram.*,src/llama-dsv41-expert.*,src/llama-dsv41.*)src/llama-memory-dsv41.*,src/llama-bounded-file.*,src/llama-ple-disk.cppintegration)scripts/strix_memory_watchdog.py,docs/strix-memory-watchdog.md)PR B (the correctness trace harness under
tools/deepseek-v41-trace/) will be created afterward, stacked on top of this branch. This layer deliberately does not includetools/deepseek-v41-trace/,tools/server/integration, or the PR60 host-memory-guard-in-loader scope; those are out of scope here.AI usage disclosure: AGENT-AUTHORED. I (Claude Sonnet 5, running as GitHub Copilot) rebuilt this layer from scratch: reconciled the 12 files that drifted between the old closed branch and current
master(see below), re-applied the validated DeepSeek V4.1 content on top of currentmaster, and wrote fresh commits.Twelve-file reconciliation
Twelve files changed on current
mastersince the old branch's merge-base and had to be reconciled (3-way merge of base/master/old-branch content) rather than blindly overwritten:gguf-py/gguf/constants.py,src/llama-arch.cpp,src/llama-arch.h,common/arg.cpp,include/llama.h,src/llama-context.cpp,src/llama-graph.cpp,src/llama-model-loader.cpp,src/llama-model.h,tests/CMakeLists.txt-- merged with zero conflicts (purely additive on both sides).src/llama-model.cpp-- one conflict: both master (LLAMA_LAZY_MODE_DIRECTskip) and this branch (!ml.external.any()skip) touched the sameml.init_mappings(...)call; resolved by combining both conditions.src/llama-ple-disk.cpp-- the significant one: master had independently reworked the row-gather algorithm (olduniq-sorted scheme -> neworder/runs/job_kindscheme with calling-thread work-stealing) since the merge-base. This branch'sllama_bounded_fileabstraction (exception-based I/O error handling, replacing rawpread/O_DIRECT) was hand-integrated onto master's newer scheduling algorithm, including extending exception propagation to cover the calling thread's own work-stealing pass, and keeping a dedicated raw fd forprefetch()'sposix_fadvisehint (a master-only addition postdating the merge-base thatllama_bounded_filedoesn't expose).Scope decision made during implementation
tests/test-deepseek41-runtime.cpp(checked out into this layer, per plan) includestools/deepseek-v41-trace/trace-components.hto validate the trace-tensor naming contract round-trip. Since that header is explicitly PR B's content, its CTest registration is deferred to that layer (the file exists in this tree but is not yet wired intotests/CMakeLists.txt; PR B will add that registration when it adds the header).Measurements
Not applicable. This layer only adds new architecture registration, loader plumbing, and CPU-side runtime infrastructure; nothing in this PR is reachable without a DeepSeek V4.1 GGUF, and no such model was loaded or run as part of this work (standing constraint: no inference, no GGUF loaded). There is no throughput or latency claim to make, and no baseline to compare against, until PR B's trace harness can actually drive a model through this code. This section will be populated as needed by future performance work once end-to-end correctness is established.
Correctness:
Model-free build and targeted CTest, run on this development machine (macOS/arm64, not Strix hardware):
Also ran directly (not wired into CTest on non-Linux):
gguf-py/tests/test_deepseek41_schema.py(4 passed) andtests/test_strix_memory_watchdog.py(36 passed, 8 skipped - Linux-only process-group cases).Note: building in this macOS environment required a local, uncommitted one-line guard around a pre-existing
posix_fadvise/POSIX_FADV_WILLNEEDcall inllama-ple-disk.cppthat is unrelated to this PR (it predates this branch, landed at the merge-base commit, and is a known, currently-failingCI (apple)issue onmasteritself --POSIX_FADV_WILLNEEDdoes not exist on macOS). That local shim was reverted before committing; it is not part of this PR's diff.Additional information
Related: #48 (tracking issue), #49 (predecessor, closed for stacking/leak hygiene), #59 (predecessor, closed for the same reason), #60 (companion PR covering the host-memory-guard-in-loader integration, deliberately excluded from this layer's scope).
Requirements