Add files using upload-large-folder tool
Browse filesFiles changed (9)
- CHANGELOG.mdAdded+12
- CITATION.cff+2-3
- README.md+14-4
- VERSION+1-1
- artifacts/cached_decode.jsonAdded+422
- inventory.json+99-19
- replications/summary.jsonAdded+229
- source/src/strata/modeling/compose/__init__.py+4
- source/src/strata/modeling/compose/head_quotient.py+316
123456789101112# Changelog
## 1.2.0 - 2026-07-21
- Added two fresh seeded Q25 checkpoints, complete 6903-pair/128-triple audits, selection plans, and post-failure characterization results.- Added the corrected matched-capacity H0 reanalysis; all three marginal graph-effect confidence intervals include zero.- Added the cached prefill/decode profile and cache-capable transitive source snapshot.- Narrowed the article claim to functional localization plus a separate causally operative typed graph path.
## 1.1.0 - 2026-07-21
- Initial public physical Q25 model and evaluation release.1 unmodified line23456787 unmodified lines161718192021221 unmodified line242526271 unmodified linemessage: "If you use this checkpoint, cite the accompanying article and model release."title: "STRATA-HeadQuotient Q25 Model and Evaluation Package"type: softwareversion: 1.1.0date-released: 2026-07-21authors:- family-names: Kadyrbek7 unmodified lineslicense: CC-BY-4.0preferred-citation:type: articletitle: "STRATA-HeadQuotient: Functional Localization of One Quarter of Global KV Groups with Typed Predicate-Graph Handoff at 8k Context"authors:- family-names: Kadyrbekgiven-names: Nurgali1 unmodified linegiven-names: Madinajournal: "Machine Learning and Knowledge Extraction"year: 20261 unmodified line23456787 unmodified lines161718192021221 unmodified line2425261 unmodified linemessage: "If you use this checkpoint, cite the accompanying article and model release."title: "STRATA-HeadQuotient Q25 Model and Evaluation Package"type: softwareversion: 1.2.0date-released: 2026-07-21authors:- family-names: Kadyrbek7 unmodified lineslicense: CC-BY-4.0preferred-citation:type: articletitle: "STRATA-HeadQuotient: Functional Localization of One Quarter of Global KV Heads with Typed Predicate-Graph Computation at 8k Context"authors:- family-names: Kadyrbekgiven-names: Nurgali1 unmodified linegiven-names: Madinajournal: "Machine Learning and Knowledge Extraction"year: 2026
20 unmodified lines2122232425262721 unmodified lines49505152535436 unmodified lines9192939495969798991001011021036 unmodified lines11011111211311411511611711811920 unmodified linesThis repository contains the physical Q25 export accompanying:> N. Kadyrbek and M. Mansurova, "STRATA-HeadQuotient: Functional Localization of One Quarter of Global KV Groups with Typed Predicate-Graph Handoff at 8k Context," submitted to *Machine Learning and Knowledge Extraction*, 2026.It complements the compact [analytical artifact dataset](https://huggingface.co/datasets/nur-dev/strata-headquotient-q25). Hugging Face is the sole public maintenance location; no GitHub mirror is required.21 unmodified linestokenizer/strata_sp48k.model fixed SentencePiece tokenizersource/ minimal transitive source snapshotartifacts/ frozen result and provenance recordsverify_export.py structural and cryptographic verificationevaluate_release.py dense/Q25 PPL and semantic confirmation```36 unmodified linesSmall floating-point variation is possible across CUDA and PyTorch builds. The scientific non-inferiority condition is the upper 95% PPL-ratio interval below 1.03, not bitwise equality of GPU reductions.## Training and Selection ReproductionThe source snapshot includes the registration, H0 evaluation, scoped-adapter training, 6,903-pair interaction audit, mixed-integer selection, static frontier export, post-review evaluation, and independent-replication drivers. The original Wikipedia snapshot is not duplicated here. Re-running training or selection therefore requires preparing the source corpus described by `config/headquotient.json` and the article; all local data locations in the public config are represented by relative paths or `source-data://` identifiers.## Intended Use and LimitationsThis is a research checkpoint for reproducing the accompanying architecture study. It is not a production assistant or a general-purpose factual system. The demonstrated boundary is one backbone and 8k context. Q30 failed; cached-decode acceleration, compiler-inclusive serving efficiency, 16k/32k behavior, and broad factual reliability are not established.## Licenses6 unmodified lines```bibtex@article{kadyrbek2026strata,author = {Kadyrbek, Nurgali and Mansurova, Madina},title = {STRATA-HeadQuotient: Functional Localization of One Quarter of Global KV Groups with Typed Predicate-Graph Handoff at 8k Context},journal = {Machine Learning and Knowledge Extraction},year = {2026},note = {Manuscript submitted for publication}}```20 unmodified lines2122232425262721 unmodified lines4950515253545536 unmodified lines92939495969798991001011021031041051061071081091101111121131146 unmodified lines12112212312412512612712812920 unmodified linesThis repository contains the physical Q25 export accompanying:> N. Kadyrbek and M. Mansurova, "STRATA-HeadQuotient: Functional Localization of One Quarter of Global KV Heads with Typed Predicate-Graph Computation at 8k Context," submitted to *Machine Learning and Knowledge Extraction*, 2026.It complements the compact [analytical artifact dataset](https://huggingface.co/datasets/nur-dev/strata-headquotient-q25). Hugging Face is the sole public maintenance location; no GitHub mirror is required.21 unmodified linestokenizer/strata_sp48k.model fixed SentencePiece tokenizersource/ minimal transitive source snapshotartifacts/ frozen result and provenance recordsreplications/ two fresh Q25 checkpoints, audits, plans, and evaluationsverify_export.py structural and cryptographic verificationevaluate_release.py dense/Q25 PPL and semantic confirmation```36 unmodified linesSmall floating-point variation is possible across CUDA and PyTorch builds. The scientific non-inferiority condition is the upper 95% PPL-ratio interval below 1.03, not bitwise equality of GPU reductions.## Cached Prefill and Decode`artifacts/cached_decode.json` records a separate inference-cache profile at 2k, 4k, and 8k prefixes for batch sizes 1, 4, 8, and 16. At an 8160-token prefix, Q25 retained 78.125% of dense persistent KV bytes. Cached decode throughput ranged from 1.003 times dense at batch 1 to 1.237 times dense at batch 16; prefill ranged from 0.926 to 1.018 times dense. This is a model-core profile on one NVIDIA L40 with a fixed 32-token continuation, not an end-to-end serving benchmark.## Training and Selection ReproductionThe source snapshot includes the registration, H0 evaluation, scoped-adapter training, 6,903-pair interaction audit, mixed-integer selection, static frontier export, post-review evaluation, and independent-replication drivers. The original Wikipedia snapshot is not duplicated here. Re-running training or selection therefore requires preparing the source corpus described by `config/headquotient.json` and the article; all local data locations in the public config are represented by relative paths or `source-data://` identifiers.The release also contains two fresh seeded Q25 campaigns. Each used a new graph-adapter initialization, disjoint diagnostic and interaction material, a complete 6,903-pair and 128-triple audit over the frozen 118-head candidate pool, a fresh mixed-integer selection, and a physical export. Their 96-head selections differ from the original but reproduce the PPL non-inferiority and typed-path effects. They do not independently rediscover the 118-head candidate pool.## Corrected Matched-Capacity AttributionThe original development comparator enabled all 16 final-layer graph heads in dense H0 but 15 in Q25. `artifacts/matched_h0_reanalysis.json` and `replications/summary.json` record the corrected comparison, where H0 receives exactly the graph-head/program capacity of each Q25 export. The original and two fresh 95% marginal-effect intervals all include zero. The supported result is therefore a reproducible global-to-local quotient plus a causally operative typed graph path; the artifacts do not establish that graph computation took over a function from the localized attention heads or caused PPL preservation.## Intended Use and LimitationsThis is a research checkpoint for reproducing the accompanying architecture study. It is not a production assistant or a general-purpose factual system. The demonstrated boundary is one backbone and 8k context. Q30 failed; production-serving efficiency, compiler-inclusive acceleration, 16k/32k behavior, and broad factual reliability are not established.## Licenses6 unmodified lines```bibtex@article{kadyrbek2026strata,author = {Kadyrbek, Nurgali and Mansurova, Madina},title = {STRATA-HeadQuotient: Functional Localization of One Quarter of Global KV Heads with Typed Predicate-Graph Computation at 8k Context},journal = {Machine Learning and Knowledge Extraction},year = {2026},note = {Manuscript submitted for publication}}```
11.1.011.2.0
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422{ "created_at": "2026-07-21T02:07:16.839792+00:00", "device": "cuda:6", "graph_enabled": false, "measurement": "inference-only KV cache; BF16 numerical equivalence is checked against full-sequence logits; prefill and autoregressive decode are reported separately", "program": "STRATA-HEADQUOTIENT-Q25-CACHED-DECODE-PROFILE", "rows": [ { "batch_size": 1, "dense": { "batch_size": 1, "decode_seconds": 0.23088740557432175, "decode_steps": 32, "decode_tokens_per_second": 138.59569308426106, "first_cached_token_ms": 7.441435630122821, "peak_allocated_bytes": 2767192064, "persistent_kv_bytes": 204472320, "prefill_seconds": 0.02532536784807841, "prefill_tokens_per_second": 80867.53220271169, "prefix_length": 2048 }, "prefix_length": 2048, "q25": { "batch_size": 1, "decode_seconds": 0.21997203739980856, "decode_steps": 32, "decode_tokens_per_second": 145.47303547422547, "first_cached_token_ms": 7.406104976932208, "peak_allocated_bytes": 2728734208, "persistent_kv_bytes": 178520064, "prefill_seconds": 0.02850375821193059, "prefill_tokens_per_second": 71850.1744497252, "prefix_length": 2048 }, "ratios": { "decode_throughput": 1.0496216169270371, "persistent_kv": 0.8730769230769231, "prefill_throughput": 0.8884922352968238 } }, { "batch_size": 4, "dense": { "batch_size": 4, "decode_seconds": 0.23466505793233713, "decode_steps": 32, "decode_tokens_per_second": 545.458284790347, "first_cached_token_ms": 7.920100043217341, "peak_allocated_bytes": 4261779456, "persistent_kv_bytes": 817889280, "prefill_seconds": 0.09082256692151229, "prefill_tokens_per_second": 90197.84705137681, "prefix_length": 2048 }, "prefix_length": 2048, "q25": { "batch_size": 4, "decode_seconds": 0.2278061956167221, "decode_steps": 32, "decode_tokens_per_second": 561.881118524786, "first_cached_token_ms": 7.969736432035764, "peak_allocated_bytes": 4070479872, "persistent_kv_bytes": 714080256, "prefill_seconds": 0.0923770306011041, "prefill_tokens_per_second": 88680.05332812775, "prefix_length": 2048 }, "ratios": { "decode_throughput": 1.0301083221070724, "persistent_kv": 0.8730769230769231, "prefill_throughput": 0.9831726169430127 } }, { "batch_size": 8, "dense": { "batch_size": 8, "decode_seconds": 0.25229039539893466, "decode_steps": 32, "decode_tokens_per_second": 1014.7037091729136, "first_cached_token_ms": 8.601184313495954, "peak_allocated_bytes": 6273153024, "persistent_kv_bytes": 1635778560, "prefill_seconds": 0.19029431355496249, "prefill_tokens_per_second": 86098.2112072825, "prefix_length": 2048 }, "prefix_length": 2048, "q25": { "batch_size": 8, "decode_seconds": 0.23515919471780458, "decode_steps": 32, "decode_tokens_per_second": 1088.6242415790068, "first_cached_token_ms": 7.94680913289388, "peak_allocated_bytes": 5870467072, "persistent_kv_bytes": 1428160512, "prefill_seconds": 0.19251583764950433, "prefill_tokens_per_second": 85104.6864509341, "prefix_length": 2048 }, "ratios": { "decode_throughput": 1.072849376362629, "persistent_kv": 0.8730769230769231, "prefill_throughput": 0.9884605644830823 } }, { "batch_size": 16, "dense": { "batch_size": 16, "decode_seconds": 0.3312743529677391, "decode_steps": 32, "decode_tokens_per_second": 1545.5467512447628, "first_cached_token_ms": 11.202741414308548, "peak_allocated_bytes": 10296591872, "persistent_kv_bytes": 3271557120, "prefill_seconds": 0.40776471979916096, "prefill_tokens_per_second": 80360.06650143603, "prefix_length": 2048 }, "prefix_length": 2048, "q25": { "batch_size": 16, "decode_seconds": 0.29237379630406696, "decode_steps": 32, "decode_tokens_per_second": 1751.1829256665776, "first_cached_token_ms": 9.928669159611067, "peak_allocated_bytes": 9478374912, "persistent_kv_bytes": 2856321024, "prefill_seconds": 0.41604801764090854, "prefill_tokens_per_second": 78760.13972089658, "prefix_length": 2048 }, "ratios": { "decode_throughput": 1.1330507629459918, "persistent_kv": 0.8730769230769231, "prefill_throughput": 0.9800905244334155 } }, { "batch_size": 1, "dense": { "batch_size": 1, "decode_seconds": 0.23166167673965296, "decode_steps": 32, "decode_tokens_per_second": 138.13247167317354, "first_cached_token_ms": 7.798002411921819, "peak_allocated_bytes": 3247719936, "persistent_kv_bytes": 405798912, "prefill_seconds": 0.04814621185262998, "prefill_tokens_per_second": 85074.19052068697, "prefix_length": 4096 }, "prefix_length": 4096, "q25": { "batch_size": 1, "decode_seconds": 0.22054913143316904, "decode_steps": 32, "decode_tokens_per_second": 145.0923873155069, "first_cached_token_ms": 7.15858240922292, "peak_allocated_bytes": 3113641472, "persistent_kv_bytes": 329515008, "prefill_seconds": 0.05360218447943529, "prefill_tokens_per_second": 76414.79614644154, "prefix_length": 4096 }, "ratios": { "decode_throughput": 1.0503858039896714, "persistent_kv": 0.812015503875969, "prefill_throughput": 0.8982136142436785 } }, { "batch_size": 4, "dense": { "batch_size": 4, "decode_seconds": 0.25190934414664906, "decode_steps": 32, "decode_tokens_per_second": 508.1193015431964, "first_cached_token_ms": 8.424771949648857, "peak_allocated_bytes": 6247872512, "persistent_kv_bytes": 1623195648, "prefill_seconds": 0.20185994543135166, "prefill_tokens_per_second": 81165.18591635038, "prefix_length": 4096 }, "prefix_length": 4096, "q25": { "batch_size": 4, "decode_seconds": 0.231443390250206, "decode_steps": 32, "decode_tokens_per_second": 553.0510068212504, "first_cached_token_ms": 7.94626772403717, "peak_allocated_bytes": 5648562176, "persistent_kv_bytes": 1318060032, "prefill_seconds": 0.20270894095301628, "prefill_tokens_per_second": 80825.2459066296, "prefix_length": 4096 }, "ratios": { "decode_throughput": 1.0884274719373839, "persistent_kv": 0.812015503875969, "prefill_throughput": 0.9958117509880267 } }, { "batch_size": 8, "dense": { "batch_size": 8, "decode_seconds": 0.321361793205142, "decode_steps": 32, "decode_tokens_per_second": 796.6099437234028, "first_cached_token_ms": 10.821449880798658, "peak_allocated_bytes": 10243749888, "persistent_kv_bytes": 3246391296, "prefill_seconds": 0.4328818339854479, "prefill_tokens_per_second": 75697.33222184962, "prefix_length": 4096 }, "prefix_length": 4096, "q25": { "batch_size": 8, "decode_seconds": 0.27276255128284294, "decode_steps": 32, "decode_tokens_per_second": 938.5452614224124, "first_cached_token_ms": 9.249638145168623, "peak_allocated_bytes": 9035757568, "persistent_kv_bytes": 2636120064, "prefill_seconds": 0.43729556041459244, "prefill_tokens_per_second": 74933.30133270327, "prefix_length": 4096 }, "ratios": { "decode_throughput": 1.1781741727144346, "persistent_kv": 0.812015503875969, "prefill_throughput": 0.9899067659754881 } }, { "batch_size": 16, "dense": { "batch_size": 16, "decode_seconds": 0.4728281206140916, "decode_steps": 32, "decode_tokens_per_second": 1082.8459173177632, "first_cached_token_ms": 15.76905200878779, "peak_allocated_bytes": 18239866368, "persistent_kv_bytes": 6492782592, "prefill_seconds": 0.8857398132483164, "prefill_tokens_per_second": 73990.12556481644, "prefix_length": 4096 }, "prefix_length": 4096, "q25": { "batch_size": 16, "decode_seconds": 0.3972581879546245, "decode_steps": 32, "decode_tokens_per_second": 1288.8343538899733, "first_cached_token_ms": 13.64798347155253, "peak_allocated_bytes": 15803827712, "persistent_kv_bytes": 5272240128, "prefill_seconds": 0.8932362391302983, "prefill_tokens_per_second": 73369.1683443221, "prefix_length": 4096 }, "ratios": { "decode_throughput": 1.1902287604153772, "persistent_kv": 0.812015503875969, "prefill_throughput": 0.9916075663373436 } }, { "batch_size": 1, "dense": { "batch_size": 1, "decode_seconds": 0.22510927046338716, "decode_steps": 32, "decode_tokens_per_second": 142.1531860244051, "first_cached_token_ms": 7.497106368343036, "peak_allocated_bytes": 4234716672, "persistent_kv_bytes": 805306368, "prefill_seconds": 0.10965904593467712, "prefill_tokens_per_second": 74412.46575189826, "prefix_length": 8160 }, "prefix_length": 8160, "q25": { "batch_size": 1, "decode_seconds": 0.224536320194602, "decode_steps": 32, "decode_tokens_per_second": 142.5159189046392, "first_cached_token_ms": 7.5872062395016355, "peak_allocated_bytes": 3902450176, "persistent_kv_bytes": 629145600, "prefill_seconds": 0.11838383475939433, "prefill_tokens_per_second": 68928.32975536353, "prefix_length": 8160 }, "ratios": { "decode_throughput": 1.0025517041888306, "persistent_kv": 0.78125, "prefill_throughput": 0.9263008429955861 } }, { "batch_size": 4, "dense": { "batch_size": 4, "decode_seconds": 0.31844382857282955, "decode_steps": 32, "decode_tokens_per_second": 401.95472015789375, "first_cached_token_ms": 10.655300070842108, "peak_allocated_bytes": 10188224512, "persistent_kv_bytes": 3221225472, "prefill_seconds": 0.47874748582641286, "prefill_tokens_per_second": 68177.9037307254, "prefix_length": 8160 }, "prefix_length": 8160, "q25": { "batch_size": 4, "decode_seconds": 0.27023141148189705, "decode_steps": 32, "decode_tokens_per_second": 473.6681028236971, "first_cached_token_ms": 8.966594313581785, "peak_allocated_bytes": 8791914496, "persistent_kv_bytes": 2516582400, "prefill_seconds": 0.4703146008153756, "prefill_tokens_per_second": 69400.35445085618, "prefix_length": 8160 }, "ratios": { "decode_throughput": 1.1784115948125533, "persistent_kv": 0.78125, "prefill_throughput": 1.0179303066424417 } }, { "batch_size": 8, "dense": { "batch_size": 8, "decode_seconds": 0.45806841490169364, "decode_steps": 32, "decode_tokens_per_second": 558.8684826805627, "first_cached_token_ms": 15.288629879554113, "peak_allocated_bytes": 18128516096, "persistent_kv_bytes": 6442450944, "prefill_seconds": 0.9819728036721548, "prefill_tokens_per_second": 66478.41952025653, "prefix_length": 8160 }, "prefix_length": 8160, "q25": { "batch_size": 8, "decode_seconds": 0.3758538272231817, "decode_steps": 32, "decode_tokens_per_second": 681.1158526476502, "first_cached_token_ms": 12.771941100557646, "peak_allocated_bytes": 15313089536, "persistent_kv_bytes": 5033164800, "prefill_seconds": 0.9673846984903017, "prefill_tokens_per_second": 67480.9102334116, "prefix_length": 8160 }, "ratios": { "decode_throughput": 1.2187408554168933, "persistent_kv": 0.78125, "prefill_throughput": 1.0150799420381769 } }, { "batch_size": 16, "dense": { "batch_size": 16, "decode_seconds": 0.7506915175666412, "decode_steps": 32, "decode_tokens_per_second": 682.037811829342, "first_cached_token_ms": 25.01120666662852, "peak_allocated_bytes": 34005301248, "persistent_kv_bytes": 12884901888, "prefill_seconds": 2.1065259805570045, "prefill_tokens_per_second": 61978.82257567861, "prefix_length": 8160 }, "prefix_length": 8160, "q25": { "batch_size": 16, "decode_seconds": 0.606967706233263, "decode_steps": 32, "decode_tokens_per_second": 843.5374645833858, "first_cached_token_ms": 20.8244522412618, "peak_allocated_bytes": 28370909184, "persistent_kv_bytes": 10066329600, "prefill_seconds": 2.119566404571136, "prefill_tokens_per_second": 61597.50396044655, "prefix_length": 8160 }, "ratios": { "decode_throughput": 1.2367898816648804, "persistent_kv": 0.78125, "prefill_throughput": 0.9938475982700953 } } ], "torch_version": "2.5.1+cu124", "verification": { "dense": { "maximum_absolute_logit_difference": 0.0625, "maximum_absolute_probability_difference": 0.0015385262668132782, "mean_absolute_logit_difference": 0.009482888504862785, "numerically_equivalent": true, "top_token_exact": true }, "q25": { "maximum_absolute_logit_difference": 0.078125, "maximum_absolute_probability_difference": 0.002120431512594223, "mean_absolute_logit_difference": 0.011962523683905602, "numerically_equivalent": true, "top_token_exact": true } }}2 unmodified lines345678910114 unmodified lines161718192021222324252627282930313234 unmodified lines67686970717219 unmodified lines9293949596979899100101102103104105106107108109110111112113114115116117118119120121122123104 unmodified lines22822923023123223323423520 unmodified lines2562572582592602612622632 unmodified lines"bytes": 170,"sha256": "3b8aee53918f95097f815387114cec53ee5434c2c1b6bc511abc9028cde0fbb4"},"CITATION.cff": {"bytes": 963,"sha256": "71bd592554e1212d3acd3da57740868b25ebf34b4a2d512b22e6fc465c566a0e"},"EVALUATION_DATA_LICENSE.md": {"bytes": 1080,4 unmodified lines"sha256": "3a060b10cf8dfc39de2b23f9fb7410b869864de8974f61e920729964c16a12cf"},"README.md": {"bytes": 5905,"sha256": "0b60e4c3dfebb0be0e26917696915621abcf219ad801b0df61f3397e5e9cb182"},"VERSION": {"bytes": 6,"sha256": "1575e1af4a95f12f70b4ee6a6adce8160953d93ea17dc2611b90883ccc3ad3b8"},"artifacts/completion_manifest.json": {"bytes": 6444,"sha256": "c5894d0d59464d5ec113c2a97d36d393da4c56a7cd43371aeed1fe527107ad5d"},"artifacts/postreview.json": {"bytes": 271163,"sha256": "22323952f18ea25bd873bd8e1bd8a8acce44623ff69aaafcb4bbfad434860aad"34 unmodified lines"bytes": 4856339,"sha256": "baac74819bcecad8010d6a164da5ba29ea4dae84bc653bff55325dace3ae1299"},"scoped_adapter/adapter.pt": {"bytes": 8392260,"sha256": "83c398187b643de3b3066dbe7cf7036bb8d2ee23ebf5475925032ec4d82bd238"19 unmodified lines"sha256": "2cd897e0c7eac3d4bf15009ac363a9edc1082d9d34491f0888df030251b92e58"},"source/scripts/evaluate_strata_headquotient_q25_postreview.py": {"bytes": 14934,"sha256": "113ecf34b470210a0106bf432b7c8085e8cf5691f76c21cb87ffad3be9a9f596"},"source/scripts/evaluate_strata_headquotient_v1_1_hq0.py": {"bytes": 9152,"sha256": "624959250a334062e737524723f52d3b89ef87df19bbfd2b1191267ef7812866"},"source/scripts/register_strata_headquotient_v1_1.py": {"bytes": 4838,"sha256": "bb29b62bc10e955671b4378d50e244740e4ae0e25a52659da88160c46f3d4819"},"source/scripts/run_strata_headquotient_q25_replication.py": {"bytes": 1669,"sha256": "648a76f619b64721d37030a358f46d209d4dd2f49c7c5dd2b8d4342a16980b04"},"source/scripts/run_strata_headquotient_v1_1_frontier.py": {"bytes": 19053,"sha256": "afe61396d43db39f78f0e3c84c67fa28ce76e4f55c4a4e9da82e9436cfd2ac57"},"source/scripts/select_strata_headquotient_v1_1_groups.py": {"bytes": 12904,"sha256": "301259e80b82c99ce455eb7b0ddd39e5aed26e080ed3e1f90203b73e67c3fc6a"},"source/scripts/train_strata_headquotient_v1_1_scoped.py": {"bytes": 13494,"sha256": "461b1a2976ac72fec647034a997289fbfc4be377dfff57468010913bf996e609"},"source/src/strata/__init__.py": {"bytes": 538,104 unmodified lines"sha256": "1de566d10ee118dc92ed0b1f9ad4a841d05231c24954b655b380f0df696617e2"},"source/src/strata/modeling/compose/__init__.py": {"bytes": 4634,"sha256": "fe82448fff0617d791078b66f2ce6ef1081ecac098615c0c4410b9a496c6e17f"},"source/src/strata/modeling/compose/anchors.py": {"bytes": 3076,20 unmodified lines"sha256": "affab353e7ff62f72274ea06e458a2b8f7ea306c43f567c490e4cee761c31db8"},"source/src/strata/modeling/compose/head_quotient.py": {"bytes": 37715,"sha256": "bab5142a90d221ccede61590a98114a440c80c470f5042a8024b8432897afcec"},"source/src/strata/modeling/compose/lm_adapter.py": {"bytes": 7002,2 unmodified lines34567891011121314154 unmodified lines2021222324252627282930313233343536373839404142434434 unmodified lines79808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314419 unmodified lines164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203104 unmodified lines30830931031131231331431520 unmodified lines3363373383393403413423432 unmodified lines"bytes": 170,"sha256": "3b8aee53918f95097f815387114cec53ee5434c2c1b6bc511abc9028cde0fbb4"},"CHANGELOG.md": {"bytes": 578,"sha256": "795f84e75a12e107aa314636828e2b2862836d267af11ab3de77045aa551bdcc"},"CITATION.cff": {"bytes": 965,"sha256": "8be7494109599f701473c23faa4ec4f10f85378acac5bdbdaa2dd1ca478eacc9"},"EVALUATION_DATA_LICENSE.md": {"bytes": 1080,4 unmodified lines"sha256": "3a060b10cf8dfc39de2b23f9fb7410b869864de8974f61e920729964c16a12cf"},"README.md": {"bytes": 7639,"sha256": "3975465ad4a20263c5837b73b3f1a7e3994f41e70fa7e415088a997839c77353"},"VERSION": {"bytes": 6,"sha256": "1e5b51cde515396a9fa762909cf8ca6584ccc564b325d2eebeea76175fe95c4d"},"artifacts/cached_decode.json": {"bytes": 14580,"sha256": "fec2e25194ef49faa5a5d99fabc9c836f9407075c321a16bfc6ef807f1460654"},"artifacts/completion_manifest.json": {"bytes": 6444,"sha256": "c5894d0d59464d5ec113c2a97d36d393da4c56a7cd43371aeed1fe527107ad5d"},"artifacts/matched_h0_reanalysis.json": {"bytes": 11242,"sha256": "255d14f9399f27c1f7e4a8f8dec93917714162732a3a46e9fef9873d227d1253"},"artifacts/postreview.json": {"bytes": 271163,"sha256": "22323952f18ea25bd873bd8e1bd8a8acce44623ff69aaafcb4bbfad434860aad"34 unmodified lines"bytes": 4856339,"sha256": "baac74819bcecad8010d6a164da5ba29ea4dae84bc653bff55325dace3ae1299"},"replications/rep3/audit.json": {"bytes": 1037,"sha256": "37b89f435ca18730dac96fd19e4892638799729c109e057c233990f415bc5807"},"replications/rep3/config.json": {"bytes": 2633,"sha256": "35e03521f5f5f29b59230c0e1aacf28987804277f14101352dc93d5afbb3ddd7"},"replications/rep3/frontier.json": {"bytes": 11281,"sha256": "bd599bd1a8448de1884b3630b8e1402b509445df98c7a6ec02fb55b9b7cb0526"},"replications/rep3/plan.json": {"bytes": 18870,"sha256": "693296958d38d7f6730716e2dabb531c38f9e88b5160331555b089798d8c6e14"},"replications/rep3/postreview.json": {"bytes": 271296,"sha256": "b11bb50dd037c2a3210c85b106de0bd270d84adb78b27b17dfd9194fbadea6de"},"replications/rep3/q25_export.pt": {"bytes": 1108651176,"sha256": "bc5ccd9f57643ebb48bab156a671a348b237e2cb1fe0cb3017d0438e869aadee"},"replications/rep3/scoped.json": {"bytes": 5643,"sha256": "1aec717b982f7d1ce1a6bec2b7ce76d6e9adc2bd7a3988ec9216a63a959c5c27"},"replications/rep4/audit.json": {"bytes": 1037,"sha256": "c4078b2050be9249419e3f5b71625831cdbbe94f7c4c6727ed440038105db799"},"replications/rep4/config.json": {"bytes": 2633,"sha256": "36b48f160ff433289da229554a3b11fc7f0152d25e2c0c42c2742fd37d5d8dac"},"replications/rep4/frontier.json": {"bytes": 11300,"sha256": "2c9178e839847be4cb2dc23f98dd03638462e2318b0202b0db9f5b49d9bd0b40"},"replications/rep4/plan.json": {"bytes": 18829,"sha256": "6eb61d268a8607c2fecdf6f79cbe08260a9fd973e2aa7a48981490d6c94ad73d"},"replications/rep4/postreview.json": {"bytes": 271260,"sha256": "33c79fa2e1e81ebd938f991343647f6a900192189351f3f1a4c7000728baea51"},"replications/rep4/q25_export.pt": {"bytes": 1108651176,"sha256": "17cb536d9e74fcae58e28d58eca9aff55484c0490770205670983b935b12dced"},"replications/rep4/scoped.json": {"bytes": 5639,"sha256": "6aa03904a02b9872707aee43d9345241a627f927dce7cecf3fbad6b7ff4f95b7"},"replications/summary.json": {"bytes": 7591,"sha256": "3808484a587e995714d3c8ccfe33a74850717b2ab31bc78a227339cdc08f4683"},"scoped_adapter/adapter.pt": {"bytes": 8392260,"sha256": "83c398187b643de3b3066dbe7cf7036bb8d2ee23ebf5475925032ec4d82bd238"19 unmodified lines"sha256": "2cd897e0c7eac3d4bf15009ac363a9edc1082d9d34491f0888df030251b92e58"},"source/scripts/evaluate_strata_headquotient_q25_postreview.py": {"bytes": 16150,"sha256": "a2ff099de01c981a40ad19b87f9291fdb60fc1edda9512d503ebe0b7334248e7"},"source/scripts/evaluate_strata_headquotient_v1_1_hq0.py": {"bytes": 9152,"sha256": "624959250a334062e737524723f52d3b89ef87df19bbfd2b1191267ef7812866"},"source/scripts/profile_strata_headquotient_cached_decode.py": {"bytes": 10083,"sha256": "32c8dda7d389e234632c7c4c77109221028e8a9d37b22fe6fd0e45bb89ff42e0"},"source/scripts/register_strata_headquotient_v1_1.py": {"bytes": 4838,"sha256": "bb29b62bc10e955671b4378d50e244740e4ae0e25a52659da88160c46f3d4819"},"source/scripts/run_strata_headquotient_q25_replication.py": {"bytes": 2054,"sha256": "783ffeed857b18c69ccd91a2e37eb68fa7004abb039b6aebb95dfe66940a04fd"},"source/scripts/run_strata_headquotient_v1_1_frontier.py": {"bytes": 20669,"sha256": "bf0928f81aa5aefecb6246e12d22b9253d7ac891c517c0f405d12b55b79db2ba"},"source/scripts/select_strata_headquotient_v1_1_groups.py": {"bytes": 13556,"sha256": "ec865653241f8953e02443433de72649b52a980ed40316ec0202109581eaf84f"},"source/scripts/summarize_strata_headquotient_q25_replications.py": {"bytes": 8305,"sha256": "255dfab1e4cf7d9e3692c46f2ae290a0f946e104043ca86daf9bc0f568e505b8"},"source/scripts/train_strata_headquotient_v1_1_scoped.py": {"bytes": 13853,"sha256": "82e247e6b14bb39bb35bfba661ae70e90655c28798696e46ebe9982d1b3c5a5b"},"source/src/strata/__init__.py": {"bytes": 538,104 unmodified lines"sha256": "1de566d10ee118dc92ed0b1f9ad4a841d05231c24954b655b380f0df696617e2"},"source/src/strata/modeling/compose/__init__.py": {"bytes": 4742,"sha256": "67c485b161ea85ff1f1a501037782929c43692953fca8e88752dc3f962e7d138"},"source/src/strata/modeling/compose/anchors.py": {"bytes": 3076,20 unmodified lines"sha256": "affab353e7ff62f72274ea06e458a2b8f7ea306c43f567c490e4cee761c31db8"},"source/src/strata/modeling/compose/head_quotient.py": {"bytes": 50668,"sha256": "0a3a6ff33f53624934f76301548b920159af5de0bd7b3386968574ef9da37f1e"},"source/src/strata/modeling/compose/lm_adapter.py": {"bytes": 7002,
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229{ "all_corrected_matched_h0_passed": false, "all_expanded_typed_at_least_0_95": true, "all_expanded_upper_below_1_03": true, "all_invalid_programs_zero": true, "all_localization_and_typed_path_passed": true, "fresh_replications": 2, "program": "STRATA-HEADQUOTIENT-Q25-INDEPENDENT-REPLICATION", "runs": [ { "causal_start": 2048, "checkpoint_sha256": "51120c7ecca5234a4e7cee424c199582e444eb04e434a2d7f08263e3ccc74a90", "config_sha256": "c4a3742f240a67380913554dbfc6efd4862a41fd1ce38bc08fd1e6952730a9c9", "confirmation_stage_opened": true, "confirmation_windows": { "count": 8, "start": 112 }, "corrected_marginal_correct": { "confidence": 0.95, "lower": -0.00023968867026269436, "mean": -8.118145342450589e-05, "samples": 1000, "upper": 7.799099694238976e-05 }, "corrected_matched_h0_passed": false, "diagnostic_windows": { "count": 8, "start": 96 }, "expanded_documents": 470, "expanded_ppl_ratio": 1.0014634161587161, "expanded_ppl_ratio_lower": 1.0013146459959361, "expanded_ppl_ratio_upper": 1.0016112211164634, "expanded_random": 0.1335, "expanded_typed": 0.999, "expanded_untyped": 0.187, "expanded_wrong_event": 0.1335, "expanded_wrong_role": 0.0, "expanded_zero": 0.1335, "frontier_late_ppl_ratio": 0.9993893766212806, "frontier_ppl_ratio": 0.9999388623918676, "frontier_throughput_ratio": 0.9843666476918135, "frontier_typed": 0.9995, "frontier_untyped": 0.179, "initialization": "registered_legacy_adapter", "interaction_audit_sha256": "7a844ea72203f0511b99ab52b71d8b2c62dc305cbbb599f144fba84ebd7ecc5c", "interaction_pairs": 6903, "interaction_triples": 128, "interaction_window": 110, "invalid_programs": 0, "local_graph_groups": 15, "local_groups": 81, "localization_and_typed_path_passed": true, "program": "STRATA-HEADQUOTIENT-v1.1", "registered_result_passed": true, "scoped_correct": 0.97, "scoped_untyped": 0.208, "seed": 20260742, "selected_groups": 96, "selected_layers": { "17": 2, "18": 12, "19": 7, "2": 6, "20": 7, "21": 10, "22": 15, "23": 15, "4": 10, "5": 12 }, "selection_plan_sha256": "cdb8f17ae11322d276b68b96873398257a8936ebb20a007749d4811bce6039e1" }, { "causal_start": 20480, "checkpoint_sha256": "bc5ccd9f57643ebb48bab156a671a348b237e2cb1fe0cb3017d0438e869aadee", "config_sha256": "7bdfa6eae5e5ffbbef0e595acec3b58a9091a665460ed3cf778ecba0ce6d4200", "confirmation_stage_opened": false, "confirmation_windows": { "count": 8, "start": 409 }, "corrected_marginal_correct": { "confidence": 0.95, "lower": -2.0666471755248494e-05, "mean": 0.00013299021520651877, "samples": 1000, "upper": 0.00028320043929852545 }, "corrected_matched_h0_passed": false, "diagnostic_windows": { "count": 8, "start": 400 }, "expanded_documents": 470, "expanded_ppl_ratio": 1.0013051380076936, "expanded_ppl_ratio_lower": 1.0011546308526744, "expanded_ppl_ratio_upper": 1.0014523960525095, "expanded_random": 0.1285, "expanded_typed": 0.9935, "expanded_untyped": 0.191, "expanded_wrong_event": 0.1285, "expanded_wrong_role": 0.0015, "expanded_zero": 0.1285, "frontier_late_ppl_ratio": 1.000198165907381, "frontier_ppl_ratio": 0.9998095370934663, "frontier_throughput_ratio": 0.952829708330366, "frontier_typed": 0.998, "frontier_untyped": 0.186, "initialization": "fresh_seeded_grouped_adapter", "interaction_audit_sha256": "498cd1e0af04a7d1d08d4f750a9e689d8131dc6daa3f45ee68d6386a94abb0f1", "interaction_pairs": 6903, "interaction_triples": 128, "interaction_window": 408, "invalid_programs": 0, "local_graph_groups": 14, "local_groups": 82, "localization_and_typed_path_passed": true, "program": "STRATA-HEADQUOTIENT-v1.1-REP3-FRESH", "registered_result_passed": false, "scoped_correct": 0.9975, "scoped_untyped": 0.1935, "seed": 20260777, "selected_groups": 96, "selected_layers": { "18": 12, "19": 7, "2": 6, "20": 7, "21": 11, "22": 14, "23": 14, "4": 9, "5": 12, "6": 4 }, "selection_plan_sha256": "dd872d27f63c8b9a277afb309ff22be08f37bd0f04a73ed92431b62b8981b190" }, { "causal_start": 24576, "checkpoint_sha256": "17cb536d9e74fcae58e28d58eca9aff55484c0490770205670983b935b12dced", "config_sha256": "5f09189d69fbffe1545bc1cd0180e12fbc17c9727509ef5c9381456549de15f2", "confirmation_stage_opened": false, "confirmation_windows": { "count": 8, "start": 509 }, "corrected_marginal_correct": { "confidence": 0.95, "lower": -0.00018559966702014208, "mean": -3.4817545383702964e-05, "samples": 1000, "upper": 0.00010850727267097682 }, "corrected_matched_h0_passed": false, "diagnostic_windows": { "count": 8, "start": 500 }, "expanded_documents": 470, "expanded_ppl_ratio": 1.0014123009914193, "expanded_ppl_ratio_lower": 1.0012669492990858, "expanded_ppl_ratio_upper": 1.0015544143634656, "expanded_random": 0.1205, "expanded_typed": 0.994, "expanded_untyped": 0.192, "expanded_wrong_event": 0.1205, "expanded_wrong_role": 0.0025, "expanded_zero": 0.1205, "frontier_late_ppl_ratio": 1.0010175258666096, "frontier_ppl_ratio": 1.0003239584965344, "frontier_throughput_ratio": 0.9780706254021283, "frontier_typed": 0.9945, "frontier_untyped": 0.186, "initialization": "fresh_seeded_grouped_adapter", "interaction_audit_sha256": "746093b123e1839c38d78e3ce7bbe157a34b9b206fc095e423885a74eaae9822", "interaction_pairs": 6903, "interaction_triples": 128, "interaction_window": 508, "invalid_programs": 0, "local_graph_groups": 14, "local_groups": 82, "localization_and_typed_path_passed": true, "program": "STRATA-HEADQUOTIENT-v1.1-REP4-FRESH", "registered_result_passed": false, "scoped_correct": 0.995, "scoped_untyped": 0.197, "seed": 20260791, "selected_groups": 96, "selected_layers": { "17": 4, "18": 12, "19": 7, "2": 5, "20": 7, "21": 11, "22": 14, "23": 14, "4": 10, "5": 12 }, "selection_plan_sha256": "73b103008ff57ee18f2c5ff353c5266c9829b12a592f02c7b779dde3a749bdac" } ], "selected_set_similarity": [ { "intersection": 91, "jaccard": 0.900990099009901, "left": "STRATA-HEADQUOTIENT-v1.1", "right": "STRATA-HEADQUOTIENT-v1.1-REP3-FRESH", "union": 101 }, { "intersection": 93, "jaccard": 0.9393939393939394, "left": "STRATA-HEADQUOTIENT-v1.1", "right": "STRATA-HEADQUOTIENT-v1.1-REP4-FRESH", "union": 99 }, { "intersection": 89, "jaccard": 0.8640776699029126, "left": "STRATA-HEADQUOTIENT-v1.1-REP3-FRESH", "right": "STRATA-HEADQUOTIENT-v1.1-REP4-FRESH", "union": 103 } ]}44 unmodified lines4546474849505152535451 unmodified lines10610710810911011111211311411544 unmodified linesExportedHeadQuotientAttention,GraphProgram,GroupedGraphReadAdapter,HeadMode,HeadQuotientAttention,HeadQuotientBlock,HeadQuotientLM,HeadQuotientOutput,ScopedGraphRead,StaticProgramGraphReadAdapter,51 unmodified lines"GroupedGraphReadAdapter","ExportedHeadQuotientAttention","GraphProgram","HeadMode","HeadQuotientAttention","HeadQuotientBlock","HeadQuotientLM","HeadQuotientOutput","ScopedGraphRead","StaticProgramGraphReadAdapter",44 unmodified lines45464748495051525354555651 unmodified lines10810911011111211311411511611711811944 unmodified linesExportedHeadQuotientAttention,GraphProgram,GroupedGraphReadAdapter,HeadKVCache,HeadMode,HeadQuotientAttention,HeadQuotientBlock,HeadQuotientLM,HeadQuotientIncrementalOutput,HeadQuotientOutput,ScopedGraphRead,StaticProgramGraphReadAdapter,51 unmodified lines"GroupedGraphReadAdapter","ExportedHeadQuotientAttention","GraphProgram","HeadKVCache","HeadMode","HeadQuotientAttention","HeadQuotientBlock","HeadQuotientLM","HeadQuotientIncrementalOutput","HeadQuotientOutput","ScopedGraphRead","StaticProgramGraphReadAdapter",
141 unmodified lines142143144145146147104 unmodified lines252253254255256257111 unmodified lines369370371372373374390 unmodified lines76576676776876977014 unmodified lines78578678778878979068 unmodified lines85986086186286386432 unmodified lines897898899900901902903904905141 unmodified linesraise ValueError("NO_GRAPH_READ cannot be requested as an executed program")def sparsemax(logits: torch.Tensor, dim: int = -1) -> torch.Tensor:"""Sparse simplex projection used for program assignment."""104 unmodified lines)return self.source.merge(result) * attention_mask.to(hidden.dtype).unsqueeze(-1)def export_static(self) -> "ExportedHeadQuotientAttention":return ExportedHeadQuotientAttention(self)111 unmodified linesmerged = result.transpose(1, 2).contiguous().view(batch, seq, self.config.d_model)return self.out(merged) * attention_mask.to(hidden.dtype).unsqueeze(-1)class GroupedGraphReadAdapter(nn.Module):"""Give every candidate group a bounded low-rank typed graph read."""390 unmodified lineshidden = hidden + self.dropout(self.ffn(self.ffn_norm(hidden)))return hidden, relativedef export_static(self) -> int:if isinstance(self.attention, ExportedHeadQuotientAttention):return self.attention.physically_removed_groups14 unmodified linesmaximum_graph_update: torch.Tensorclass HeadQuotientLM(nn.Module):"""Dense LM with independently configurable global KV groups."""68 unmodified linesrelative = torch.maximum(relative, current)return hidden, attention_mask, relativedef forward(self,input_ids: torch.Tensor,32 unmodified lines"GraphProgram","ExportedHeadQuotientAttention","HeadMode","HeadQuotientAttention","HeadQuotientBlock","HeadQuotientLM","HeadQuotientOutput","ScopedGraphRead","sparsemax",141 unmodified lines142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250104 unmodified lines355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418111 unmodified lines530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600390 unmodified lines99199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102014 unmodified lines103510361037103810391040104110421043104410451046104768 unmodified lines11161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117832 unmodified lines12111212121312141215121612171218121912201221141 unmodified linesraise ValueError("NO_GRAPH_READ cannot be requested as an executed program")@dataclass(slots=True)class HeadKVCache:"""Preallocated inference cache for one global/local attention split."""global_key: torch.Tensorglobal_value: torch.Tensorlocal_key: torch.Tensorlocal_value: torch.Tensorcapacity: intposition: intlocal_length: intlocal_cursor: int@propertydef maximum_length(self) -> int:return self.capacitydef _allocate_cache(key: torch.Tensor,value: torch.Tensor,*,maximum_length: int,local_window: int,global_indices: torch.Tensor,local_indices: torch.Tensor,) -> HeadKVCache:batch, _heads, sequence, width = key.shapeif maximum_length < sequence:raise ValueError("maximum cache length is shorter than the prefill")global_key = key.new_empty(batch, global_indices.numel(), maximum_length, width)global_value = value.new_empty(batch, global_indices.numel(), maximum_length, width)if global_indices.numel():global_key[:, :, :sequence].copy_(key.index_select(1, global_indices))global_value[:, :, :sequence].copy_(value.index_select(1, global_indices))local_capacity = min(local_window, maximum_length)local_key = key.new_empty(batch, local_indices.numel(), local_capacity, width)local_value = value.new_empty(batch, local_indices.numel(), local_capacity, width)retained = min(sequence, local_capacity)if local_indices.numel() and retained:local_key[:, :, :retained].copy_(key.index_select(1, local_indices)[:, :, sequence - retained :])local_value[:, :, :retained].copy_(value.index_select(1, local_indices)[:, :, sequence - retained :])return HeadKVCache(global_key=global_key,global_value=global_value,local_key=local_key,local_value=local_value,capacity=maximum_length,position=sequence,local_length=retained,local_cursor=retained % max(local_capacity, 1),)def _append_and_read(query: torch.Tensor,key: torch.Tensor,value: torch.Tensor,cache: HeadKVCache,) -> torch.Tensor:"""Append one token and return exact one-query global/local attention."""if query.shape[2] != 1:raise ValueError("incremental attention accepts exactly one query token")if cache.position >= cache.maximum_length and cache.global_key.shape[1]:raise ValueError("global KV cache is full")outputs = []global_heads = cache.global_key.shape[1]local_heads = cache.local_key.shape[1]if global_heads:cache.global_key[:, :, cache.position : cache.position + 1].copy_(key[:, :global_heads])cache.global_value[:, :, cache.position : cache.position + 1].copy_(value[:, :global_heads])outputs.append(F.scaled_dot_product_attention(query[:, :global_heads],cache.global_key[:, :, : cache.position + 1],cache.global_value[:, :, : cache.position + 1],))if local_heads:local_key = key[:, global_heads:]local_value = value[:, global_heads:]cache.local_key[:, :, cache.local_cursor : cache.local_cursor + 1].copy_(local_key)cache.local_value[:, :, cache.local_cursor : cache.local_cursor + 1].copy_(local_value)cache.local_length = min(cache.local_length + 1, cache.local_key.shape[2])cache.local_cursor = (cache.local_cursor + 1) % cache.local_key.shape[2]outputs.append(F.scaled_dot_product_attention(query[:, global_heads:],cache.local_key[:, :, : cache.local_length],cache.local_value[:, :, : cache.local_length],))cache.position += 1if not outputs:return query.new_empty(query.shape[0], 0, 1, query.shape[-1])return torch.cat(outputs, dim=1)def sparsemax(logits: torch.Tensor, dim: int = -1) -> torch.Tensor:"""Sparse simplex projection used for program assignment."""104 unmodified lines)return self.source.merge(result) * attention_mask.to(hidden.dtype).unsqueeze(-1)def prefill(self,hidden: torch.Tensor,attention_mask: torch.Tensor,*,maximum_length: int,) -> tuple[torch.Tensor, HeadKVCache]:if not bool(attention_mask.all()):raise ValueError("incremental cache prefill currently requires an unpadded batch")query, key, value = self.source.split(hidden)result = torch.zeros_like(value)global_indices = ((self.modes == int(HeadMode.GLOBAL)) & self.enabled).nonzero(as_tuple=False).flatten()local_indices = ((self.modes != int(HeadMode.GLOBAL)) & self.enabled).nonzero(as_tuple=False).flatten()if global_indices.numel():result[:, global_indices] = _attention(query[:, global_indices], key[:, global_indices], value[:, global_indices],attention_mask, local_window=None,local_query_chunk=max(512, self.config.local_query_chunk),)if local_indices.numel():result[:, local_indices] = _attention(query[:, local_indices], key[:, local_indices], value[:, local_indices],attention_mask, local_window=self.config.local_window,local_query_chunk=max(512, self.config.local_query_chunk),)cache = _allocate_cache(key,value,maximum_length=maximum_length,local_window=self.config.local_window,global_indices=global_indices,local_indices=local_indices,)return self.source.merge(result), cachedef decode_step(self, hidden: torch.Tensor, cache: HeadKVCache) -> torch.Tensor:query, key, value = self.source.split(hidden)global_indices = ((self.modes == int(HeadMode.GLOBAL)) & self.enabled).nonzero(as_tuple=False).flatten()local_indices = ((self.modes != int(HeadMode.GLOBAL)) & self.enabled).nonzero(as_tuple=False).flatten()ordered = torch.cat((global_indices, local_indices))attended = _append_and_read(query.index_select(1, ordered),key.index_select(1, ordered),value.index_select(1, ordered),cache,)result = torch.zeros_like(value)result[:, ordered] = attendedreturn self.source.merge(result)def export_static(self) -> "ExportedHeadQuotientAttention":return ExportedHeadQuotientAttention(self)111 unmodified linesmerged = result.transpose(1, 2).contiguous().view(batch, seq, self.config.d_model)return self.out(merged) * attention_mask.to(hidden.dtype).unsqueeze(-1)def _project(self, hidden: torch.Tensor):global_count = int(self.global_head_indices.numel())local_count = int(self.local_head_indices.numel())global_qkv = self._split(self.packed_qkv.weight[:self.global_qkv_rows], hidden, global_count,) if global_count else tuple(hidden.new_empty(hidden.shape[0], 0, hidden.shape[1], self.config.head_dim,) for _ in range(3))local_qkv = self._split(self.packed_qkv.weight[self.global_qkv_rows:], hidden, local_count,) if local_count else tuple(hidden.new_empty(hidden.shape[0], 0, hidden.shape[1], self.config.head_dim,) for _ in range(3))return tuple(torch.cat((global_qkv[index], local_qkv[index]), dim=1)for index in range(3))def prefill(self,hidden: torch.Tensor,attention_mask: torch.Tensor,*,maximum_length: int,) -> tuple[torch.Tensor, HeadKVCache]:if not bool(attention_mask.all()):raise ValueError("incremental cache prefill currently requires an unpadded batch")query, key, value = self._project(hidden)global_count = int(self.global_head_indices.numel())result = torch.empty_like(value)if global_count:result[:, :global_count] = _attention(query[:, :global_count], key[:, :global_count], value[:, :global_count],attention_mask, local_window=None,local_query_chunk=max(512, self.config.local_query_chunk),)if self.local_head_indices.numel():result[:, global_count:] = _attention(query[:, global_count:], key[:, global_count:], value[:, global_count:],attention_mask, local_window=self.config.local_window,local_query_chunk=max(512, self.config.local_query_chunk),)cache = _allocate_cache(key,value,maximum_length=maximum_length,local_window=self.config.local_window,global_indices=torch.arange(global_count, device=key.device),local_indices=torch.arange(global_count, key.shape[1], device=key.device,),)merged = result.transpose(1, 2).contiguous().view(hidden.shape[0], hidden.shape[1], self.config.d_model,)return self.out(merged), cachedef decode_step(self, hidden: torch.Tensor, cache: HeadKVCache) -> torch.Tensor:query, key, value = self._project(hidden)attended = _append_and_read(query, key, value, cache)merged = attended.transpose(1, 2).contiguous().view(hidden.shape[0], 1, self.config.d_model,)return self.out(merged)class GroupedGraphReadAdapter(nn.Module):"""Give every candidate group a bounded low-rank typed graph read."""390 unmodified lineshidden = hidden + self.dropout(self.ffn(self.ffn_norm(hidden)))return hidden, relativedef prefill_cache(self,hidden: torch.Tensor,attention_mask: torch.Tensor,*,maximum_length: int,) -> tuple[torch.Tensor, HeadKVCache]:attention, cache = self.attention.prefill(self.attn_norm(hidden), attention_mask, maximum_length=maximum_length,)hidden = hidden + self.dropout(attention)hidden = hidden + self.dropout(self.ffn(self.ffn_norm(hidden)))return hidden, cachedef decode_step(self,hidden: torch.Tensor,cache: HeadKVCache,) -> torch.Tensor:hidden = hidden + self.dropout(self.attention.decode_step(self.attn_norm(hidden), cache))return hidden + self.dropout(self.ffn(self.ffn_norm(hidden)))def export_static(self) -> int:if isinstance(self.attention, ExportedHeadQuotientAttention):return self.attention.physically_removed_groups14 unmodified linesmaximum_graph_update: torch.Tensor@dataclass(frozen=True, slots=True)class HeadQuotientIncrementalOutput:logits: torch.Tensorhidden_states: torch.Tensorcache: tuple[HeadKVCache, ...]class HeadQuotientLM(nn.Module):"""Dense LM with independently configurable global KV groups."""68 unmodified linesrelative = torch.maximum(relative, current)return hidden, attention_mask, relative@torch.inference_mode()def prefill_cache(self,input_ids: torch.Tensor,*,maximum_length: int | None = None,) -> HeadQuotientIncrementalOutput:"""Prefill an exact graph-disabled KV cache for autoregressive decoding."""if input_ids.ndim != 2 or input_ids.shape[1] == 0:raise ValueError("prefill input must have shape [batch, nonzero sequence]")maximum_length = maximum_length or self.config.context_lengthif not input_ids.shape[1] <= maximum_length <= self.config.context_length:raise ValueError("invalid incremental maximum length")positions = torch.arange(input_ids.shape[1], device=input_ids.device)hidden = self.base_model.dropout(self.base_model.token_embeddings(input_ids)+ self.base_model.position_embeddings(positions).unsqueeze(0))attention_mask = torch.ones_like(input_ids, dtype=torch.bool)caches = []for block in self.base_model.blocks:hidden, cache = block.prefill_cache(hidden, attention_mask, maximum_length=maximum_length,)caches.append(cache)normalized = self.base_model.final_norm(hidden)logits = self.base_model.lm_head(normalized[:, -1:])return HeadQuotientIncrementalOutput(logits, normalized[:, -1:], tuple(caches))@torch.inference_mode()def decode_step(self,input_ids: torch.Tensor,cache: tuple[HeadKVCache, ...],) -> HeadQuotientIncrementalOutput:"""Decode one token using the preallocated graph-disabled cache in place."""if input_ids.ndim != 2 or input_ids.shape[1] != 1:raise ValueError("decode input must have shape [batch, 1]")if len(cache) != len(self.base_model.blocks):raise ValueError("incremental cache has the wrong number of layers")position = cache[0].positionif any(layer.position != position for layer in cache):raise ValueError("incremental layer caches are out of sync")if position >= self.config.context_length:raise ValueError("incremental decode exceeds configured context length")hidden = self.base_model.dropout(self.base_model.token_embeddings(input_ids)+ self.base_model.position_embeddings.weight[position].view(1, 1, -1))for block, layer_cache in zip(self.base_model.blocks, cache, strict=True):hidden = block.decode_step(hidden, layer_cache)normalized = self.base_model.final_norm(hidden)logits = self.base_model.lm_head(normalized)return HeadQuotientIncrementalOutput(logits, normalized, cache)def forward(self,input_ids: torch.Tensor,32 unmodified lines"GraphProgram","ExportedHeadQuotientAttention","HeadMode","HeadKVCache","HeadQuotientAttention","HeadQuotientBlock","HeadQuotientLM","HeadQuotientIncrementalOutput","HeadQuotientOutput","ScopedGraphRead","sparsemax",
CHANGELOG.mdAdded+12
CITATION.cff+2-3
README.md+14-4
VERSION+1-1
artifacts/cached_decode.jsonAdded+422
inventory.json+99-19
replications/summary.jsonAdded+229
source/src/strata/modeling/compose/__init__.py+4
source/src/strata/modeling/compose/head_quotient.py+316