GPU State Reuse and Eviction
Skill navigation
Load linked skills only when their trigger applies. Do not duplicate their full workflow here.
Core principle
Reuse state only when it is unambiguously identified, currently valid, authorized for the consumer, and economically beneficial. Prove safety before ranking value.
Compare expected avoided work with footprint, lookup, validation, movement, maintenance, invalidation, and interference. A high hit rate does not prove a positive end-to-end result.
Treat logical invalidation, logical eviction, physical residency eviction, and physical release as distinct events. This skill owns the first two; placement and backing specialists own the latter two.
Reuse contract and audit
Define one reuse contract for every candidate state or reusable subrange.
| Group |
Record |
| Candidate |
Logical role, producer, consumers, reuse granule, avoided work, no-reuse fallback |
| Identity |
Semantic inputs, normalized parameters, dimensions, precision contract, partition coordinates, semantic version, collision handling |
| Validity |
Dependency versions, captured epochs, epoch authority, completion state, invalidation events, check/use ordering |
| Ownership |
Owner, namespace, isolation domain, authorized readers and writers, lifetime authority, accounting scope |
| Sharing |
Allowed scope, immutability or snapshot guarantee, writable-consumer behavior, copy-on-write requirement |
| Partial reuse |
Coverage representation, granule identity, per-granule validity, composition rule, missing-part fallback |
| Economics |
Decision horizon, reuse probability, saved work, footprint, lookup, movement, maintenance, interference |
| Evidence |
Source, workload scope, measured or inferred status, uncertainty, falsifying observation |
Define identity semantically
Make identity keys represent logical equivalence, not storage location.
- Include every input, mode, version, layout, precision, position, or partition field that can change the result.
- Exclude addresses, allocation identifiers, physical tiers, and incidental timestamps unless they change semantics.
- Classify fields as identity, validity evidence, authorization, or metadata.
- Justify canonicalization; differently encoded values are not automatically equivalent.
- Define collision detection or use a representation with an accepted collision contract.
- Reject reuse when a required identity field is unknown.
Do not combine identity and authorization. Two objects can be semantically equal yet forbidden to share across owners or isolation domains.
Define validity and mutation epochs
Write validity as an explicit predicate:
valid(candidate, consumer, now) = identity_match
and dependencies_match
and production_complete
and epoch_current
and authorization_allows
and coverage_compatible
Capture authoritative dependency epochs when state is produced. Define reset, wrap, and concurrent-update behavior.
Invalidate on semantic change, dependency mutation, revoked access, incomplete production, or incompatible partial coverage.
Age and expiration may guide retention, but they are not correctness predicates.
Require a snapshot, lease, ordering edge, or equivalent guarantee between validation and use. Hand the concrete synchronization mechanism to gpu-memory-scheduling or the runtime specialist.
Control sharing and copy-on-write
Permit shared reads only within an authorized scope and under an immutable or stable-snapshot contract.
Require a writable consumer to obtain a distinct logical version before mutation. Record whether copy-on-write is legal, what it copies, and how much it costs; delegate its physical timing and placement.
Do not infer physical deduplication from logical sharing. Separate saved logical work from saved physical bytes.
Model partial and sparse reuse
Define the smallest reuse granule whose identity, validity, and composition are independently checkable.
For a reusable subset A:
saved_work(A) = baseline_cost
- [remaining_work(A) + lookup_cost(A) + compose_cost(A)]
Do not estimate partial value as coverage * full_saved_work unless measurement supports linearity.
Require a correct fallback for missing, stale, unauthorized, or incompatible granules.
Decision workflow
- Declare the target metric, representative workload, decision horizon, and capacity budget.
- Enumerate reuse candidates and choose a justified granule.
- Complete identity, validity, epoch, ownership, sharing, and coverage contracts.
- Reject semantically unsafe or unauthorized candidates before economic ranking.
- Measure or bound avoided work and every material cost.
- Compare full, partial, and no reuse without assuming linear value.
- Rank admission and retention against competing eligible state.
- Define invalidation and logical eviction independently of physical residency.
- Record uncertainty, fallback behavior, and the measurement that would falsify the policy.
- Hand state mutation semantics, physical placement, and action timing to their specialists.
Separate admission, retention, and eviction
- Admission asks whether a newly produced candidate should enter the logical retained set.
- Retention asks whether an admitted candidate remains valuable over the next decision horizon.
- Invalidation removes eligibility because correctness or authorization no longer holds.
- Logical eviction removes a still-valid candidate because another use of the budget has greater expected value.
- Residency eviction moves or removes one physical copy without necessarily deleting logical retention.
Do not use one policy rule for all five decisions.
Value model
For candidate i over horizon H, estimate:
E_saved(i) = sum_r P(request_r
and identity_match
and valid
and authorized)
* work_avoided(i, r)
C(i) = E[lookup + validation + movement + maintenance + invalidation]
For retained set S:
J(S, H) = sum_i_in_S [E_saved(i) - C(i)] - interference(S, H)
Constrain effective footprint:
sum_i_in_S footprint(i) <= logical_budget
Include payload, metadata, indexes, duplicate versions, and charged overhead in footprint(i) when the policy is accountable for them.
Admit or keep a candidate only when its marginal value is positive under the stated uncertainty rule:
delta_admit(i) = J(S union {i}) - J(S)
delta_keep(i) = J(S) - J(S without {i})
Use value density only when additivity and granularity assumptions are justified. Interference can be nonlinear.
Do not count footprint both as a hard constraint and a priced cost unless the formulation intentionally uses both.
Reject recency-only, frequency-only, age-only, largest-first, smallest-first, or admit-everything policies unless measured workload evidence supports them.
When objective weights are absent, return a Pareto set or an unresolved ranking rather than inventing a default.
Specialist handoffs
| This skill owns |
Handoff |
| Logical eligibility, identity, validity, authorization, admission, retention, invalidation, and logical eviction |
Keep here |
| Growth, mutation, snapshot, branch, rollback, and cleanup semantics |
gpu-persistent-state |
| Physical backing, remapping, old-access revocation, sanitization, and release |
gpu-virtual-memory-fragmentation |
| Physical placement, residency, migration, replication, and residency eviction |
gpu-memory-tiering-migration |
| Lookup/mutation ordering, copy timing, invalidation propagation, and reclamation timing |
gpu-memory-scheduling |
| Reuse changes precision, approximation, ordering, determinism, or value semantics |
gpu-numerical-safety |
| Baseline, reuse distribution, saved-work and interference measurements |
gpu-performance-evidence |
| Correctness, isolation, and end-to-end acceptance |
gpu-optimization-validation |
Pass the selected logical set, value curves, validity events, isolation constraints, uncertainty, and fallback requirements. Do not prescribe a physical mechanism.
Failure modes and counterexamples
- Under-specified identity returns incorrect state.
- Over-specified identity destroys useful reuse.
- Stale or ambiguous epochs permit invalid reuse.
- Validation followed by an unordered mutation creates a race.
- Identical computation keys are treated as authorization.
- Shared mutable aliases bypass copy-on-write.
- Age-based validity accepts stale state.
- Hit-rate-only ranking retains cheap-to-recreate state.
- Payload-only accounting hides metadata and index costs.
- Partial reuse costs more to locate and compose than it saves.
- Admission churn creates repeated movement and invalidation work.
- Logical eviction is reported as immediate physical memory release.
- Device residency is treated as a prerequisite for logical retention.
- A local saved-work estimate fails to improve the target metric.
- A familiar eviction algorithm replaces an evidence-backed value function.
Reuse decision record
Record:
- candidate, granule, workload, decision horizon, and target metric;
- complete identity field list and deliberate exclusions;
- validity predicate, dependencies, epochs, and authorities;
- invalidation events and validation-to-use ordering requirement;
- owner, isolation scope, readers, writers, and sharing contract;
- copy-on-write requirement and delegated physical semantics;
- full or partial coverage contract;
- baseline work and exactly what reuse avoids;
- every benefit and cost term with source and uncertainty;
- logical budget, footprint, interference, and alternatives;
- formula, result, sensitivity, and rejected defaults;
- admission, retention, invalidation, or logical-eviction decision;
- fallback, handoffs, falsifier, and rollback condition.
Acceptance gate
Keep a reuse or logical-eviction policy only when:
- identity is complete and collision-safe under the accepted contract;
- validity is mechanically checkable;
- mutation epochs have an authoritative source;
- validation-to-use ordering is guaranteed or explicitly handed off;
- ownership and isolation permit the proposed sharing;
- writable sharing has a safe copy-on-write contract;
- partial reuse preserves correctness and has positive marginal value;
- every material cost and the no-reuse alternative are included;
- the decision remains positive under conservative uncertainty;
- no default eviction rule substitutes for workload evidence;
- logical eviction makes no unsupported physical-residency claim;
- end-to-end validation shows no unacceptable correctness, isolation, footprint, latency, or throughput regression.
1---2name: gpu-state-reuse-eviction3description: Load this skill and follow it when identifying reusable GPU state, defining identity and validity, sharing or copy-on-write, admission, retention, invalidation, or eviction under capacity and performance constraints.4---56# GPU State Reuse and Eviction78## Skill navigation910- Parent router: [gpu-code-optimizer](../gpu-code-optimizer/SKILL.md)11- Evidence: [gpu-performance-evidence](../gpu-performance-evidence/SKILL.md)12- State semantics: [gpu-persistent-state](../gpu-persistent-state/SKILL.md)13- Physical backing and release: [gpu-virtual-memory-fragmentation](../gpu-virtual-memory-fragmentation/SKILL.md)14- Physical residency: [gpu-memory-tiering-migration](../gpu-memory-tiering-migration/SKILL.md)15- Ordering: [gpu-memory-scheduling](../gpu-memory-scheduling/SKILL.md)16- Semantic and numerical safety: [gpu-numerical-safety](../gpu-numerical-safety/SKILL.md)17- Validation: [gpu-optimization-validation](../gpu-optimization-validation/SKILL.md)1819Load linked skills only when their trigger applies. Do not duplicate their full workflow here.2021## Core principle2223Reuse state only when it is unambiguously identified, currently valid, authorized for the consumer, and economically beneficial. Prove safety before ranking value.2425Compare expected avoided work with footprint, lookup, validation, movement, maintenance, invalidation, and interference. A high hit rate does not prove a positive end-to-end result.2627Treat logical invalidation, logical eviction, physical residency eviction, and physical release as distinct events. This skill owns the first two; placement and backing specialists own the latter two.2829## Reuse contract and audit3031Define one reuse contract for every candidate state or reusable subrange.3233| Group | Record |34|---|---|35| Candidate | Logical role, producer, consumers, reuse granule, avoided work, no-reuse fallback |36| Identity | Semantic inputs, normalized parameters, dimensions, precision contract, partition coordinates, semantic version, collision handling |37| Validity | Dependency versions, captured epochs, epoch authority, completion state, invalidation events, check/use ordering |38| Ownership | Owner, namespace, isolation domain, authorized readers and writers, lifetime authority, accounting scope |39| Sharing | Allowed scope, immutability or snapshot guarantee, writable-consumer behavior, copy-on-write requirement |40| Partial reuse | Coverage representation, granule identity, per-granule validity, composition rule, missing-part fallback |41| Economics | Decision horizon, reuse probability, saved work, footprint, lookup, movement, maintenance, interference |42| Evidence | Source, workload scope, measured or inferred status, uncertainty, falsifying observation |4344### Define identity semantically4546Make identity keys represent logical equivalence, not storage location.4748- Include every input, mode, version, layout, precision, position, or partition field that can change the result.49- Exclude addresses, allocation identifiers, physical tiers, and incidental timestamps unless they change semantics.50- Classify fields as identity, validity evidence, authorization, or metadata.51- Justify canonicalization; differently encoded values are not automatically equivalent.52- Define collision detection or use a representation with an accepted collision contract.53- Reject reuse when a required identity field is unknown.5455Do not combine identity and authorization. Two objects can be semantically equal yet forbidden to share across owners or isolation domains.5657### Define validity and mutation epochs5859Write validity as an explicit predicate:6061```text62valid(candidate, consumer, now) = identity_match63 and dependencies_match64 and production_complete65 and epoch_current66 and authorization_allows67 and coverage_compatible68```6970Capture authoritative dependency epochs when state is produced. Define reset, wrap, and concurrent-update behavior.7172Invalidate on semantic change, dependency mutation, revoked access, incomplete production, or incompatible partial coverage.7374Age and expiration may guide retention, but they are not correctness predicates.7576Require a snapshot, lease, ordering edge, or equivalent guarantee between validation and use. Hand the concrete synchronization mechanism to `gpu-memory-scheduling` or the runtime specialist.7778### Control sharing and copy-on-write7980Permit shared reads only within an authorized scope and under an immutable or stable-snapshot contract.8182Require a writable consumer to obtain a distinct logical version before mutation. Record whether copy-on-write is legal, what it copies, and how much it costs; delegate its physical timing and placement.8384Do not infer physical deduplication from logical sharing. Separate saved logical work from saved physical bytes.8586### Model partial and sparse reuse8788Define the smallest reuse granule whose identity, validity, and composition are independently checkable.8990For a reusable subset `A`:9192```text93saved_work(A) = baseline_cost94 - [remaining_work(A) + lookup_cost(A) + compose_cost(A)]95```9697Do not estimate partial value as `coverage * full_saved_work` unless measurement supports linearity.9899Require a correct fallback for missing, stale, unauthorized, or incompatible granules.100101## Decision workflow1021031. Declare the target metric, representative workload, decision horizon, and capacity budget.1042. Enumerate reuse candidates and choose a justified granule.1053. Complete identity, validity, epoch, ownership, sharing, and coverage contracts.1064. Reject semantically unsafe or unauthorized candidates before economic ranking.1075. Measure or bound avoided work and every material cost.1086. Compare full, partial, and no reuse without assuming linear value.1097. Rank admission and retention against competing eligible state.1108. Define invalidation and logical eviction independently of physical residency.1119. Record uncertainty, fallback behavior, and the measurement that would falsify the policy.11210. Hand state mutation semantics, physical placement, and action timing to their specialists.113114### Separate admission, retention, and eviction115116- **Admission** asks whether a newly produced candidate should enter the logical retained set.117- **Retention** asks whether an admitted candidate remains valuable over the next decision horizon.118- **Invalidation** removes eligibility because correctness or authorization no longer holds.119- **Logical eviction** removes a still-valid candidate because another use of the budget has greater expected value.120- **Residency eviction** moves or removes one physical copy without necessarily deleting logical retention.121122Do not use one policy rule for all five decisions.123124## Value model125126For candidate `i` over horizon `H`, estimate:127128```text129E_saved(i) = sum_r P(request_r130 and identity_match131 and valid132 and authorized)133 * work_avoided(i, r)134135C(i) = E[lookup + validation + movement + maintenance + invalidation]136```137138For retained set `S`:139140```text141J(S, H) = sum_i_in_S [E_saved(i) - C(i)] - interference(S, H)142```143144Constrain effective footprint:145146```text147sum_i_in_S footprint(i) <= logical_budget148```149150Include payload, metadata, indexes, duplicate versions, and charged overhead in `footprint(i)` when the policy is accountable for them.151152Admit or keep a candidate only when its marginal value is positive under the stated uncertainty rule:153154```text155delta_admit(i) = J(S union {i}) - J(S)156delta_keep(i) = J(S) - J(S without {i})157```158159Use value density only when additivity and granularity assumptions are justified. Interference can be nonlinear.160161Do not count footprint both as a hard constraint and a priced cost unless the formulation intentionally uses both.162163Reject recency-only, frequency-only, age-only, largest-first, smallest-first, or admit-everything policies unless measured workload evidence supports them.164165When objective weights are absent, return a Pareto set or an unresolved ranking rather than inventing a default.166167## Specialist handoffs168169| This skill owns | Handoff |170|---|---|171| Logical eligibility, identity, validity, authorization, admission, retention, invalidation, and logical eviction | Keep here |172| Growth, mutation, snapshot, branch, rollback, and cleanup semantics | `gpu-persistent-state` |173| Physical backing, remapping, old-access revocation, sanitization, and release | `gpu-virtual-memory-fragmentation` |174| Physical placement, residency, migration, replication, and residency eviction | `gpu-memory-tiering-migration` |175| Lookup/mutation ordering, copy timing, invalidation propagation, and reclamation timing | `gpu-memory-scheduling` |176| Reuse changes precision, approximation, ordering, determinism, or value semantics | `gpu-numerical-safety` |177| Baseline, reuse distribution, saved-work and interference measurements | `gpu-performance-evidence` |178| Correctness, isolation, and end-to-end acceptance | `gpu-optimization-validation` |179180Pass the selected logical set, value curves, validity events, isolation constraints, uncertainty, and fallback requirements. Do not prescribe a physical mechanism.181182## Failure modes and counterexamples183184- Under-specified identity returns incorrect state.185- Over-specified identity destroys useful reuse.186- Stale or ambiguous epochs permit invalid reuse.187- Validation followed by an unordered mutation creates a race.188- Identical computation keys are treated as authorization.189- Shared mutable aliases bypass copy-on-write.190- Age-based validity accepts stale state.191- Hit-rate-only ranking retains cheap-to-recreate state.192- Payload-only accounting hides metadata and index costs.193- Partial reuse costs more to locate and compose than it saves.194- Admission churn creates repeated movement and invalidation work.195- Logical eviction is reported as immediate physical memory release.196- Device residency is treated as a prerequisite for logical retention.197- A local saved-work estimate fails to improve the target metric.198- A familiar eviction algorithm replaces an evidence-backed value function.199200## Reuse decision record201202Record:203204- candidate, granule, workload, decision horizon, and target metric;205- complete identity field list and deliberate exclusions;206- validity predicate, dependencies, epochs, and authorities;207- invalidation events and validation-to-use ordering requirement;208- owner, isolation scope, readers, writers, and sharing contract;209- copy-on-write requirement and delegated physical semantics;210- full or partial coverage contract;211- baseline work and exactly what reuse avoids;212- every benefit and cost term with source and uncertainty;213- logical budget, footprint, interference, and alternatives;214- formula, result, sensitivity, and rejected defaults;215- admission, retention, invalidation, or logical-eviction decision;216- fallback, handoffs, falsifier, and rollback condition.217218## Acceptance gate219220Keep a reuse or logical-eviction policy only when:221222- identity is complete and collision-safe under the accepted contract;223- validity is mechanically checkable;224- mutation epochs have an authoritative source;225- validation-to-use ordering is guaranteed or explicitly handed off;226- ownership and isolation permit the proposed sharing;227- writable sharing has a safe copy-on-write contract;228- partial reuse preserves correctness and has positive marginal value;229- every material cost and the no-reuse alternative are included;230- the decision remains positive under conservative uncertainty;231- no default eviction rule substitutes for workload evidence;232- logical eviction makes no unsupported physical-residency claim;233- end-to-end validation shows no unacceptable correctness, isolation, footprint, latency, or throughput regression.