Skip to content

P7: AllocationResolver — one resolver decides domain and scope - #1153

Merged
michalharakal merged 1 commit into
feature/1142-delete-dead-placementfrom
feature/1143-allocation-resolver
Aug 26, 2026
Merged

michalharakal merged 1 commit into
feature/1142-delete-dead-placementfrom
feature/1143-allocation-resolver

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Closes #1143 (parent #1133). Stacked on #1152 — merge that first; GitHub retargets this one to develop when the base branch goes.

The P7 answer, implemented: placement joins WeightForm as a resolved decision.

  • AllocationResolver.resolve(weight, profile, platform) — a pure function of what will be held (the resolved form), what the profile says (domainFor gets its first real consumer), and what the platform can do (StorageCapabilities, injectable so a test can resolve for a platform it is not running on).
  • PlanTensor.allocation stops hardcoding MMAP_FILE/MODEL: mapping now requires the form to ask MAPPED, the platform to be able to map, and the bytes to really be the file's bytes — a dequantized or feed-ordered weight is a load-time copy and cannot be paged from a file it no longer matches. Everything else falls to the profile's heap/off-heap threshold over residentBytes.
  • AllocationResolver.explain() renders each decision with its reason ("form asks MAPPED but this platform cannot map files"), recomputed from resolve so it can never drift from what was actually decided.
  • Consumers carry and obey; they never decide. AllocationResolverTest pins the rules; PlannerProfileTest pins the domainFor threshold edges; MemoryPlanTest updated for the resolved (no-longer-assumed) allocation.

Full pr-gate green (all legs; JS/Wasm with -Pkotlin.incremental.js.ir=false per the cache glitch).

🤖 Generated with Claude Code

Placement joins WeightForm as a resolved decision (#1133's answer):
AllocationResolver is a pure function of what will be held (the resolved
form), what the profile says (domainFor and its threshold) and what the
platform can do (StorageCapabilities, injectable so a test can resolve
for a platform it is not running on).

PlanTensor.allocation stops hardcoding MMAP_FILE/MODEL — a spec that
claimed every weight was mapped even on a platform that cannot map, and
even for a dequantized copy that no longer matches the file. Mapping now
requires all three: the form asks MAPPED, the platform can map, and the
bytes really are the file's bytes; everything else falls to the
profile's heap/off-heap threshold over the bytes actually held.

AllocationResolver.explain() renders the decision with its reason, so a
plan can say where every tensor landed and why.

Closes #1143.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@michalharakal
michalharakal merged commit a1b35a4 into feature/1142-delete-dead-placement Aug 26, 2026
2 checks passed
michalharakal added a commit that referenced this pull request Aug 26, 2026
…ad-wiring

P7: AllocationResolver + plan→load wiring (re-land #1153/#1154 onto develop)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant