# 19 — Implement and certify GLM-5.2 range, DSA, and IndexShare semantics Status: ready-for-agent ## Mandatory fresh-session context - Read [RALPH-CONTEXT.md](../RALPH-CONTEXT.md), [GLM-5.2-MAX-ALPHA-ROADMAP.md](../GLM-5.2-MAX-ALPHA-ROADMAP.md), and this issue completely before changing code. - This issue is `DGR-019` in [prd.json](../prd.json). - Read and verify every dependency evidence README. - Inspect current source and `git status`; do not generalize through tensor-name substitution. ## Description As a target-model operator, I need explicit range-owned GLM-5.2 semantics so that contiguous consumer Shards preserve the whole-model MoE, DSA, IndexShare, and local-KV computation. ## Expected durable outputs - Explicit GLM-5.2 architecture adapter and tensor-ownership rules - IndexShare-aware Shard planner and named DSA sideband protocol mapping - GLM architecture fixture and target parity evidence - Memory/tensor/KV ownership report - `evidence/DGR-019/README.md` ## Acceptance criteria - [ ] Implement explicit ownership for 78 main layers, head embedding, tail norm/output head, routed/shared experts, DSA/indexer tensors, and the certified NextN/MTP policy. - [ ] Each contiguous layer owner keeps all 256 experts and the shared-expert path for its layers local; no public cross-machine expert collectives are introduced. - [ ] Define and fixture-test compressed MLA KV ownership for locally owned layers, keyed by Route Session/epoch, for DGR-007 to implement. - [ ] Implement native DSA lightning indexer/top-2,048 and sparse-attention graph behavior matching DGR-018. - [ ] Parse and validate artifact `indexer_types`; implement Full producer and Shared consumer behavior without fabricated/duplicated indexer tensors. - [ ] Prefer Shard boundaries that preserve IndexShare ownership groups; when memory fit forces a split, carry a typed, bounded, validated top-k sideband in the DGR-006 named bundle. - [ ] Reject missing, stale, wrong-width, wrong-position, or Shared-before-Full sideband/index state. - [ ] Demonstrate mapped/resident weights and allocated KV scale with exact owned tensors/layers rather than the full model. - [ ] Same-host two-stage F32 seam fixture produces 32 exact greedy tokens against the DGR-018 semantics; production seam meets the pre-locked token/similarity thresholds. - [ ] If full-target same-host execution cannot fit, use a layer-reduced GLM architecture fixture only for graph parity and defer full-artifact parity to DGR-020; label it non-target evidence. - [ ] Add deterministic fixture tests for MoE route/shared expert, DSA Full/Shared groups, internal group split, endpoint ownership, KV filtering, malformed metadata, and NextN policy. - [ ] Targeted pytest/CTest/native tests pass; pinned patch stack applies and rebuilds cleanly. - [ ] `python -m compileall packages tests` and `git diff --check` pass. - [ ] Default tests remain deterministic, model-download-free, API-credit-free, and GPU-free. - [ ] Full deterministic `pytest -q` passes, or exact pre-existing unrelated failures are recorded. - [ ] Preserve all pre-existing working-tree changes and stage only files belonging to this story. - [ ] Write `evidence/DGR-019/README.md` with files, commands, real results, raw evidence, limitations, and dependent-story handoff. - [ ] Update only this story issue to `Status: done` after every acceptance criterion passes. ## Dependency handoff - `DGR-005`, `DGR-006`, and `DGR-018` must have `passes: true`; read and verify their evidence READMEs. - DGR-007 integration may be completed in parallel only after the adapter's cache contract is explicit. ## Finish contract - Preserve real failures and blockers; never claim target parity from the architecture fixture. - Emit `COMPLETE` only after evidence exists. ## References - [GLM-5.2 Max alpha roadmap](../GLM-5.2-MAX-ALPHA-ROADMAP.md) - [Current architecture](../architecture.md)