feat: implement numbered patch-stack apply/verify enforcement (DGR-028)
Split the range-loader patch into single-concern patches 0002-0005 (loader, filtered state report, boundary I/O endpoint guard, worker range-report hook), add UPSTREAM-ASSUMPTIONS.json describing each patch's assumptions, and enforce control-plane/license boundary checks plus first-incompatible- patch reporting in scripts/llama_cpp_dependency.py apply/reverse/verify. 7 passed in tests/test_llama_cpp_dependency.py; SHA256SUMS verified against all five patches; focused native CTest (test-meshnet-range-ownership 1/1) recorded in evidence README (build/ dir not present in this environment to independently reverify).
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
From: Meshnet <meshnet@invalid>
|
||||
Subject: [PATCH] llama: guard dense graph behind boundary endpoint ownership
|
||||
|
||||
Concern: boundary I/O. Extends the range report with endpoint ownership flags
|
||||
derived from the registered tensor map and fails the dense-Llama graph closed
|
||||
for any partial owned range until typed head/tail endpoint adapters carry the
|
||||
architecture boundary I/O.
|
||||
---
|
||||
diff --git a/include/llama.h b/include/llama.h
|
||||
index 6fd7ad509..8a7521349 100644
|
||||
--- a/include/llama.h
|
||||
+++ b/include/llama.h
|
||||
@@ -300,6 +300,8 @@ extern "C" {
|
||||
int32_t end_layer;
|
||||
uint64_t mapped_bytes;
|
||||
uint64_t resident_bytes;
|
||||
+ bool has_token_embeddings;
|
||||
+ bool has_output_head;
|
||||
};
|
||||
|
||||
struct llama_model_params {
|
||||
diff --git a/src/llama-model.cpp b/src/llama-model.cpp
|
||||
index efb290c1f..2ea8598ad 100644
|
||||
--- a/src/llama-model.cpp
|
||||
+++ b/src/llama-model.cpp
|
||||
@@ -1649,11 +1649,17 @@ bool llama_model_base::load_tensors(llama_model_loader & ml) {
|
||||
if (ml.use_mmap) {
|
||||
meshnet_mapped_bytes = meshnet_resident_bytes;
|
||||
}
|
||||
+ const auto registered_name = [this](const char * name) {
|
||||
+ return std::any_of(tensors_by_name.begin(), tensors_by_name.end(),
|
||||
+ [name](const auto & entry) { return entry.first == name; });
|
||||
+ };
|
||||
pimpl->meshnet_range_report = {
|
||||
meshnet_start,
|
||||
meshnet_end,
|
||||
meshnet_mapped_bytes,
|
||||
meshnet_resident_bytes,
|
||||
+ registered_name("token_embd.weight"),
|
||||
+ output_norm != nullptr && output != nullptr,
|
||||
};
|
||||
pimpl->has_meshnet_range_report = true;
|
||||
}
|
||||
diff --git a/src/models/llama.cpp b/src/models/llama.cpp
|
||||
index c3092763b..3b6854d0c 100644
|
||||
--- a/src/models/llama.cpp
|
||||
+++ b/src/models/llama.cpp
|
||||
@@ -108,6 +108,25 @@ std::unique_ptr<llm_graph_context> llama_model_llama::build_arch_graph(const llm
|
||||
|
||||
template <bool embed>
|
||||
llama_model_llama::graph<embed>::graph(const llama_model & model, const llm_graph_params & params) : llm_graph_context(params) {
|
||||
+ llama_meshnet_range_report meshnet_report = {};
|
||||
+ if (model.meshnet_range_report(&meshnet_report)) {
|
||||
+ // A partial owned range cannot execute the stock head/tail graph: the
|
||||
+ // architecture boundary I/O must arrive through a typed endpoint
|
||||
+ // adapter instead of local embeddings or the local output head.
|
||||
+ if (meshnet_report.start_layer != 0) {
|
||||
+ throw std::runtime_error("Meshnet dense-Llama graph requires a head endpoint adapter");
|
||||
+ }
|
||||
+ if (meshnet_report.end_layer != n_layer) {
|
||||
+ throw std::runtime_error("Meshnet dense-Llama graph requires a tail endpoint adapter");
|
||||
+ }
|
||||
+ if (!meshnet_report.has_token_embeddings) {
|
||||
+ throw std::runtime_error("Meshnet dense-Llama head range is missing token embeddings");
|
||||
+ }
|
||||
+ if (!meshnet_report.has_output_head) {
|
||||
+ throw std::runtime_error("Meshnet dense-Llama tail range is missing final norm or output head");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
const int64_t n_embd_head = hparams.n_embd_head_v();
|
||||
|
||||
GGML_ASSERT(n_embd_head == hparams.n_embd_head_k());
|
||||
Reference in New Issue
Block a user