feat(memory): AllocationSpec + ScopeKind replace the never-consumed StorageSpec (SKEEP-003 P0, S0.3) - #1053
Merged
michalharakal merged 1 commit intoAug 22, 2026
Conversation
…torageSpec (SKEEP-003 P0) Milestone M0 (#1001), SKEEP-003 prerequisite "StorageSpec becomes the allocation spec". - sk.ainet.lang.memory.AllocationSpec(format, elementCount, domain = HOST_HEAP, scope = AMBIENT, mutable = true, alignment = 64): bytes / bytesOrNull from the encoding, AllocationSpec.of(format, shape, ...), validation (count >= 0, power-of-two alignment). The input of the M0 MemoryPlan line items and, from M1, of Storage.allocate(spec, scope). - enum ScopeKind { MODEL, FORWARD, AMBIENT } — the lifetime classes of SKEEP-003 §4.5, declared now; M1's Scope exposes kind: ScopeKind. - StorageSpec and its companion factories @deprecated(ReplaceWith AllocationSpec); zero consumers outside its own file and the S0.1 bridge test (kept on purpose, suppressed). StorageSpec.toAllocationSpec(count) is the migration path. Removed at the next major. - AllocationSpecTest; BCV lang-core jvm dump regenerated (additions + deprecation annotations). Closes #1009 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Local gate Targeted: lang-core |
michalharakal
merged commit Aug 22, 2026
c802d2e
into
feature/1008-format-and-encoding
2 checks passed
michalharakal
added a commit
that referenced
this pull request
Aug 22, 2026
…boQuant), forward slab, headroom, budget fit, suggestions (SKEEP-003 P1) Milestone M0 (#1001), PRD M0-F1..F3 / M0-A4: "will this model fit on this device at this context length?" answered from shapes and encodings only — no tensor bytes are read. - sk.ainet.lang.memory.plan: PlanTensor (name, TensorId?, Format, count, bytes; allocation = AllocationSpec mapped/MODEL/read-only), ModelGeometry, KvCacheMode (BF16, TURBOQUANT_4 via TensorEncoding.TurboQuantPolar), PlanInput (model, weights, geometry, ctx, prefill chunk 256, kv mode; unmappedWeights listed, never dropped), Budget (explicit or available − reserve: 700 MB Android/JVM, 300 MB native — decision #11), MemoryPlan (weights resident · kv @ ctx with the alternate mode · forward slab · heap headroom · total · fits · ≥ 2 suggestions with savings: --kv turboquant, --ctx N/2, smaller model; render() = the PRD §4.3 table), MemoryPlans.plan(input, budget) with the documented estimates. - io-gguf: StreamingGGUFReader.planInput(ctx, prefillChunk, kvMode, nameMap) — header only (tensor table + <arch>.block_count / embedding_length / attention.head_count(_kv) / key_length / value_length / feed_forward_length / vocab_size / context_length); ggufGeometry(); ggufFormat(type, nBytes). - Tests: MemoryPlanTest (Llama-3.2-1B-like geometry: KV bf16 @2048 = 64 MiB, TurboQuant ≈ ¼, forward slab scaling, totals/residency, does-not-fit suggestions, TurboQuant mode + available-memory budget, no geometry, unmapped, byte formatting); GgufMemoryPlanTest (synthetic header-only plan, format mapping, fixture-gated Qwen2.5-0.5B real header). - BCV: lang-core jvm dump regenerated (additions only). Includes the AllocationSpec commit of #1053 (cherry-picked: the plan's line items are AllocationSpecs); that commit drops out on rebase once Closes #1012 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SKEEP-003 slice S0.3 (milestone M0 #1001):
AllocationSpecreplaces the never-consumedStorageSpec("StorageSpec becomes the allocation spec" — SKEEP-003 prerequisite).sk.ainet.lang.memory.AllocationSpec(format: Format, elementCount, domain = HOST_HEAP, scope: ScopeKind = AMBIENT, mutable = true, alignment = 64)withbytes/bytesOrNull(from the encoding),AllocationSpec.of(format, shape, …), validation (count ≥ 0, power-of-two alignment). Pure description; it is the input of the M0MemoryPlanline items and, from M1, ofStorage.allocate(spec, scope).enum ScopeKind { MODEL, FORWARD, AMBIENT }— the lifetime classes of SKEEP-003 §4.5, declared now so plans/specs can name a lifetime; M1'sScopewill exposekind: ScopeKind(no rename later).StorageSpecand its companion factories are@Deprecated(ReplaceWith AllocationSpec)(zero consumers outside its own file and the S0.1 bridge test, which keeps exercising it deliberately —git grep StorageSpec);StorageSpec.toAllocationSpec(elementCount)is the migration path (Format(dtype, encoding), placement domain,MODELfor persistent placements elseAMBIENT, mutable only when owned). Removed at the next major.AllocationSpecTest(bytes per encoding incl. Q4_K/Q8_0/TurboQuant, defaults, validation, StorageSpec conversion, ScopeKind).Stacked on #1051 (S0.4 —
Format); retarget todevelopafter it merges.Test plan
Full local gate (
scripts/pr-gate.sh, JDK 25) on the stacked tree; results in the first comment.Closes #1009
🤖 Generated with Claude Code