Skip to content

Latest commit

 

History

History
768 lines (572 loc) · 34.9 KB

README.md

File metadata and controls

768 lines (572 loc) · 34.9 KB

SparkCache package

The sparkcache package implements persistent, rank-local context storage for vLLM's KV-Connector-V1 interface. The scheduler chooses reusable prefixes; each worker reads and writes only its physical rank's state.

Request flow

  1. The scheduler hashes each eligible prompt boundary once.
  2. Workers report structurally valid entries and their process generation.
  3. The scheduler chooses the longest entry present on every expected rank.
  4. Each worker authenticates its local manifest and payload objects.
  5. Workers place state only after every required check succeeds.
  6. Any rejection becomes a normal cache miss and prompt recomputation.
  7. A completed prefill publishes immutable objects before its manifest.

Row-oriented storage may also publish authenticated aliases that point to an earlier exact manifest. A broken alias does not affect the exact manifest.

Startup inventory

Each worker sends at most 512 discovered manifest digests through vLLM's one-time connector handshake before API readiness. The scheduler exposes an entry only when every physical rank reports the same digest.

Larger inventories continue through bounded delta and checkpoint reports after the engine starts. Entries outside the startup subset recompute until their all-rank reports arrive.

Configure the connector

Pass SparkCache through vLLM's --kv-transfer-config. Omitting the connector configuration leaves SparkCache unloaded.

{
  "kv_connector": "SparkContextCacheConnector",
  "kv_connector_module_path": "sparkcache.spark_context_cache_connector",
  "kv_role": "kv_both",
  "kv_load_failure_policy": "recompute",
  "kv_connector_extra_config": {
    "spark_cache_root": "/cache/sparkcache/deployment-name",
    "spark_cache_model_profile": "profile-name",
    "spark_cache_target_checkpoint_sha256": "<64 lowercase hex characters>",
    "spark_cache_draft_policy": "colocated_target",
    "spark_cache_access_mode": "read-write",
    "spark_cache_publication_schema": "snapshot-v1",
    "spark_cache_shared_prefix_lease_ttl_seconds": 15,
    "spark_cache_max_bytes": 214748364800,
    "spark_cache_low_watermark_bytes": 193273528320,
    "spark_cache_ttl_seconds": 0,
    "spark_cache_clear_once": ""
  }
}

The checkpoint digest identifies immutable checkpoint contents, not a mutable path or tag. A separately loaded drafter uses policy separate and supplies its own checkpoint digest.

The profile is part of cache identity. An unknown profile or unsupported parallel geometry stops connector startup before any stored entry is used.

Restore and publication controls

spark_cache_access_mode selects how the connector uses persistent storage:

Mode Restore stored prefixes Publish completed prefixes
read-write Yes Yes
restore-only Yes No
store-only No Yes
disabled No No

read-write is the default and preserves the behavior of deployments that do not set a mode.

restore-only is useful when serving prompts with uncertain reuse. Existing entries remain available, but completed requests do not capture or publish model state. An unavailable or rejected entry is computed normally.

The independent spark_cache_store and spark_cache_restore booleans remain supported. Each explicitly supplied boolean overrides its side of the selected mode.

The equivalent environment variables are SPARK_CONTEXT_CACHE_ACCESS_MODE, SPARK_CONTEXT_CACHE_STORE, and SPARK_CONTEXT_CACHE_RESTORE.

Access controls do not participate in cache identity. Switching between read-write and restore-only can reuse compatible stored entries without a namespace change.

Publication options

spark_cache_publication_schema chooses the persistent layout. It defaults to snapshot-v1.

Setting Storage layout Behavior
snapshot-v1 Rows or opaque manager pages Publish a complete aligned snapshot.
tail-cow-v1 Rows Publish immutable row tails and authenticated descriptor chains.
tail-cow-v1 Opaque manager pages Publish changed pages over a bounded nested base graph.
tail-cow-v2 Opaque manager pages only Publish changed pages as an ordered, authenticated stage list rooted at one immutable base snapshot.

The connector maps the operator setting tail-cow-v2 to the cache-identity wire value page-tail-cow-v2.

The v2 manifest keeps one base root plus a flat list of delta stages instead of nesting each result under the following extension.

Every stage binds its base digest, token boundary, block geometry, payload digest, and immutable object descriptors.

Restore validates the whole chain before any stage reaches request-owned GPU blocks.

Every publication schema has a distinct cache identity. Changing the setting produces a clean cache miss against entries written by another schema; it cannot alias their objects as compatible state.

Storage and integrity

ManifestStore writes and synchronizes immutable objects before it exposes an atomic manifest. Startup checks identity, geometry, descriptors, alias chains, and referenced object sizes.

Restore reads and hashes the selected payloads before releasing state. sweep_integrity() performs an explicit full-payload diagnostic.

Persistent data contains no CUDA pointers, allocator block tables, physical slot coordinates, or transport sequence numbers.

Prefix reuse

  • Exact prefixes: choose the longest aligned digest reported by every expected rank.
  • Sparse aliases: authenticate lightweight row-boundary references to already stored objects.
  • Copy-on-write tails: replace a partial terminal object and append only changed rows or pages.
  • Shared restores: let bounded followers attach to one verified GPU prefix through ordinary vLLM block references.

Verified shared GPU prefixes remain retained for spark_cache_shared_prefix_lease_ttl_seconds. The accepted range is 1–300 seconds and the default is 15 seconds.

Longer retention can serve later queued requests without another persistent restore.

The two-prefix limit and vLLM's memory-pressure eviction remain active regardless of the configured duration. The equivalent environment variable is SPARK_CONTEXT_CACHE_SHARED_PREFIX_LEASE_TTL_SECONDS.

Manager-page tail-cow-v1 graphs admit at most two nested deltas before flattening against an earlier verified base.

tail-cow-v2 retains a flat ordered stage list. A configurable limit bounds its length by publishing complete CPU-composed snapshots.

The v2 descriptor list grows with the number of stored extensions. Restore authenticates each retained stage header, then reads each layer tail that no later stage supersedes exactly once.

Each tail is checked against its header-bound SHA-256 before any byte is copied. The composed result must match the newest stage's result digest; intermediate results are neither materialized nor rehashed.

A stage header is authenticated by hashing the stage's first macro object.

Each worker process keeps an LRU cache of authenticated or published headers. The cache holds at most 16 MiB of header bytes, keyed by the first object's SHA-256 and length.

Cached headers avoid repeated first-object authentication. Surviving tail bytes are still read and verified on every restore.

An overwritten intermediate stage is authenticated by digest chaining, not by rehashing its full result.

The CUDA reader uses tail reads when every layer tail in a stage fits its arena and prefetch bounds. Otherwise it uses authenticated whole-object reads for that stage.

Both paths verify the final result before the request resumes. Cache identities, on-disk formats, and wire formats are unchanged.

The CUDA reader reads each surviving layer tail straight into its slot of the mapped placement arena and checks it there against the header-bound tail digest. The reads and checks of one batch run on a bounded thread pool.

Nothing from a batch is submitted until every tail in it passed. A failed check aborts the transaction.

The sequential SHA-256 of the composed result runs while the following batch is read. It overlaps storage and tail verification instead of following them.

A process that has not seen a history authenticates one whole first object per stage, as before. It hashes those objects concurrently on the object-read lane and retains only the header prefixes.

The debug line for each CUDA restore reports planning, final_hash, and hot_snapshot alongside the existing phases.

Flat-history restore measurements

Status: research-only. A 32-turn synthetic agent session used the same two DGX Sparks (Draupnir positions 6-7) for both builds, with TP2/DCP1, MTP3, CUDA page restore, tail-cow-v2, and snapshot interval 0.

The hardware evidence note identifies the model, checkpoint, image, request procedure, and remaining configuration.

At turn 32, the restored entry contained 31 delta stages and 186,368 tokens; the fresh request contained 187,889 prompt tokens.

Restore and commit timings use the slower rank. Time to first token (TTFT) is measured by the client for the fresh request.

Measurement Baseline 50bd6d9 Tail-read/header-cache build e389b32
restore_read 18.8 s 1.5 s
Publication commit 19.7 s 5.5 s
Turn-32 fresh-request TTFT 22.8 s 3.7 s
load_failed 0 0

A separate restart test on Draupnir positions 4-5 restored a 30-stage, 182,272-token entry. A cold process read 3,393 MB versus 1,380 MB warm (2.46 times, about 2.5 times).

Cold restore_read was 5.0-6.1 s versus 1.3-1.7 s before restart. Keeping or dropping the OS page cache gave similar cold timings. Repeating the request in the same process restored warm speed.

These measurements cover one session per arm and one same-pair comparison, with the GPU prefix cache reset before measured requests.

Digest checks passed and no loads failed. Output-token equality and independent bit-for-bit restore correctness were not evaluated.

The results demonstrate reduced restore and publication work under these conditions. They do not qualify serving or guarantee performance for other models and topologies.

SparkCache CUDA restore

CUDA restore is optional. It requires an absolute libspark_cache_placement path, its SHA-256, and a compatible arena size.

SparkCache authenticates objects, checks logical positions, places bytes into request-owned GPU blocks, and resumes the request only after CUDA completion. Any error discards those private blocks and recomputes the prompt.

The optional spark_cache_cuda_restore_arena_budget_bytes setting bounds restore arena allocation per worker rank. Its environment equivalent is SPARK_CONTEXT_CACHE_CUDA_RESTORE_ARENA_BUDGET_BYTES.

The default, 0, keeps the configured lane count. A positive budget must fit at least one lane's two arenas.

The connector caps page restore lanes at the smaller of spark_cache_load_threads (maximum eight) and the number of complete arena pairs the budget permits. Row restore uses one lane.

For example, 256 MiB arenas and a 1 GiB budget permit two page restore lanes, allocating 1 GiB instead of the 4 GiB required by eight lanes. Arenas are allocated at startup.

This budget covers restore arenas; capture rings, authenticated host objects, GPU KV blocks, and placement metadata have separate allocations.

Adjusting the budget preserves cache identities and on-disk compatibility. Concurrent restore throughput requires deployment testing.

See native/README.md for the ABI and memory-ordering rules. Deployment profiles record the model layouts tested with this path.

SparkCache CUDA publication

Asynchronous manager-page capture is implemented and disabled by default.

It records producer readiness on the model-runner stream, gathers complete request-owned pages on a low-priority CUDA stream, and hands a claimed mapped ring view to the durable writer.

Ring saturation skips optional publication without waiting. Preemption synchronizes only the affected capture before its source pages can be reused.

Enablement requires an attested libspark_cache_snapshot library, bounded slot sizes, and the exact vLLM ownership contract described in native/MANAGER_PAGE_CAPTURE_CONTRACT.md.

The asynchronous ring can feed complete snapshot-v1 publication or either manager-page tail schema.

With tail-cow-v2, SparkCache selects only pages whose bytes cannot be reused from the authenticated base.

Complete immutable full-attention pages are reused. Partial terminal pages and mutable recurrent or sliding-window state are captured again.

The background publisher reads and verifies the base once, constructs the authenticated delta directly from the bounded sparse ring view, and computes the logical result digest incrementally.

The publisher does not reconstruct a complete Python snapshot or compare every result page with the base. Ring pressure or an unverifiable base skips publication without delaying unrelated serving.

The required page-tail settings are profile-specific:

{
  "spark_cache_access_mode": "read-write",
  "spark_cache_publication_schema": "tail-cow-v2",
  "spark_cache_async_page_capture": true,
  "spark_cache_async_page_capture_library": "/absolute/libspark_cache_snapshot.so",
  "spark_cache_async_page_capture_library_sha256": "<64 lowercase hex characters>",
  "spark_cache_async_page_capture_slot_bytes": 3221225472,
  "spark_cache_async_page_capture_slot_count": 2,
  "spark_cache_max_delayed_stores": 16,
  "spark_cache_async_page_capture_vllm_root": "/absolute/vllm/source",
  "spark_cache_async_page_capture_lease_contract": "/absolute/ownership-contract.json"
}

spark_cache_async_page_capture_slot_bytes must hold the largest selected page set for one rank.

Two slots normally allow one capture to be consumed while another completes. Three slots can absorb short writer jitter but use another slot's worth of pinned unified memory.

Saturation always skips the optional publication instead of waiting for a slot.

spark_cache_page_snapshot_interval_tokens optionally selects complete asynchronous page captures at token boundaries. It accepts a non-negative integer and defaults to 0, which disables the policy.

The environment fallback is SPARK_CONTEXT_CACHE_PAGE_SNAPSHOT_INTERVAL_TOKENS; an explicit connector setting takes precedence. For example:

"spark_cache_page_snapshot_interval_tokens": 16384

A dependent publication captures complete state when its result span and selected base span fall into different interval buckets, measured from token zero. The choice happens before sparse capture, without reading history.

For interval 16,384, base 14,336 to result 16,384 selects full capture; base 16,384 to result 18,432 remains sparse. This is a token cadence, not a universal bound on history depth for arbitrary prompt increments.

spark_cache_payload_integrity selects how stored KV and recurrent payloads are checked. Its environment fallback is SPARK_CONTEXT_CACHE_PAYLOAD_INTEGRITY.

Value Payload check Schema Default for
fast CRC32 per object and layer tail, checked while copying page-tail-cow-v3-fast tail-cow-v2 publication
none none; lengths and geometry only page-tail-cow-v3-none —
sha256 SHA-256 per object and composed result the content-addressed schemas every other schema

Keys, cache identity, manifests and stage headers stay SHA-256 in every mode. fast detects torn writes and media corruption, not deliberate tampering. Use sha256 for cache roots other parties can write.

The v3 schemas have their own cache identity. Entries written in one mode miss cleanly in another, and readers without the v3 schemas miss them.

spark_cache_page_delta_stage_limit_count bounds the stages in a tail-cow-v2 entry. The default 0 sets no limit; a positive value caps the stage count. Its environment fallback is SPARK_CONTEXT_CACHE_PAGE_DELTA_STAGE_LIMIT_COUNT.

Appending beyond the limit publishes a full snapshot of the result. The background saver composes the verified base with this turn's captured tail on the CPU. It requires no full GPU capture and cannot overflow the capture slot.

The snapshot includes the result boundary's recurrent state. It uses the same format and readers as a periodic full capture; preceding published boundaries remain restorable. The policy does not affect tail-cow-v1.

Four stages bound metadata traversal and overwritten recurrent history while allowing several sparse writes between snapshots. This is an implemented default, not a hardware-qualified optimum; full rewrites increase SSD traffic.

Sparse publication retains the verified base digest through encoding. For a delta base, that digest belongs to the newest stage's result. Caller-supplied base bytes must match that authenticated digest before use.

The saver reuses at most 64 open macro-object handles during base reconstruction and closes them before encoding. Every consumed tail still passes its checksum; no payload bytes or file handles are cached between publications.

Publication still reconstructs the base and hashes the full result. Its cost therefore grows with retained tokens even with bounded stages. The existing whole-snapshot SHA-256 cannot be updated from only a captured tail.

For full attention, each compaction rewrites all retained tokens rather than only the appended tokens. Recurrent state is written once per publication. See the model deployment evidence for the measured geometry and byte costs.

spark_cache_hot_snapshot_bytes is a process-local memory budget for complete page snapshots the worker has itself hashed (research-only). The default 0 disables it. Its environment fallback is SPARK_CONTEXT_CACHE_HOT_SNAPSHOT_BYTES.

With a budget, the saver keeps the result it composes for each publication. The Python reader keeps each result it composes. The CUDA reader keeps each result whose final digest it verified.

An entry is keyed by the digest the authenticated metadata binds for that boundary and by the encoded length. It is inserted only after this process computed that digest over exactly those bytes.

The bound digest is a snapshot manifest's snapshot_sha256, or the result_snapshot_sha256 of the newest stage header, whose first object hashed to its manifest-bound content address.

A publication whose base is resident encodes its delta without reading or hashing the base. A restore whose result is resident places it from memory without reading any object.

The budget is host memory of the worker process. On unified-memory hosts it competes with the GPU. The oldest entries are evicted first.

Cache identities, on-disk formats, and wire formats are unchanged. A reader without the budget reads every byte from objects as before.

Full captures keep the same cache identity and format. Before selecting one, the worker calculates its exact raw page bytes from the registered layout.

If they exceed the capture slot, it retains and pins the offered committed base and captures only the delta. This check prevents repeated oversized full-capture submissions as the session grows.

If the base cannot be retained, ordinary full-capture admission still applies; no unprotected tail is captured.

The counter publication_periodic_full_capture_selected counts selections, including attempts later rejected by a busy ring.

publication_full_capture_slot_fallback counts periodic selections diverted to base retention because the full page body exceeds the slot.

Performance status: research-only. A CPU fixture used 25 extensions of 2,048 tokens, eight appended attention layers, and four overwritten recurrent layers. Payload widths and macro-object size were scaled down by eight.

With a full snapshot every eight extensions, staged writes increased from 160.36 to 238.21 MiB, about 49%, with no deduplication savings. Source preparation was excluded from commit timing; no GPU work was executed.

This CPU measurement does not establish GPU capture interference, eviction behavior, or a causal end-to-end serving improvement from the interval policy.

The delayed-store limit reserves at most 16 request lifetimes by default. When the limit is full, SparkCache omits another optional store plan before worker capture begins, so vLLM can release that request's pages normally.

Capacity and cleanup

spark_cache_max_bytes is the high watermark for one cache root. Crossing it evicts least-recently-used manifests down to spark_cache_low_watermark_bytes, which defaults to 90% of the high watermark.

Choose capacity and the high-to-low watermark gap from the reusable working set, largest admitted publication, and measured publication and reclamation rates.

A larger gap amortizes maintenance across more writes, but each pass evicts more data and can increase future misses. Compare those costs with observed publication age and maintenance activity before changing the gap.

Deletion pacing

Status: implemented; serving performance with these controls is research-only. Both settings default to 0, preserving unrestricted passes:

  • spark_cache_maintenance_max_deletions caps filesystem unlink attempts per pass, including failed attempts, across manifests, aliases, debris, descriptor segments, and payload objects. Its environment fallback is SPARK_CONTEXT_CACHE_MAINTENANCE_MAX_DELETIONS.
  • spark_cache_maintenance_interval_ms sets a minimum cooldown after a pass finishes or fails. Forced post-commit calls also respect it; skipped calls do not extend it. Its environment fallback is SPARK_CONTEXT_CACHE_MAINTENANCE_INTERVAL_MS.

Explicit connector settings take precedence over environment values. A test configuration can select 128 deletion attempts and 1000 milliseconds; these values are not a qualified serving-performance recommendation.

With a deletion budget, existing orphan payloads and debris are reclaimed before additional roots are selected.

A pass can stop above the low watermark or the capacity maximum; optional store admission remains blocked while capacity is unsatisfied.

A process-local pressure target retains the low watermark across passes, even after usage falls below the high watermark. Restarting the process loses this target; a later high-watermark crossing establishes it again.

Background retries complete deferred cleanup without making serving wait. Root-directory durability barriers still precede object removal, and protected publication roots retain their complete object graphs.

This is not a scan-size or wall-clock bound. Each admitted pass authenticates the complete reference inventory and reconciles survivors.

Status: implemented. A completed pass also returns metadata-qualified surviving roots while the exclusive filesystem guard is held.

The connector uses this inventory to reconcile offers without rereading every root or restatting shared chunks once per reference.

Qualification checks logical file sizes, not allocated disk space. Exact roots shadow aliases even when invalid; aliases are eligible only for token-row storage.

Protected roots and their referenced objects retain the same deletion rules.

The inventory is not retained between passes. Failed or busy passes use independent metadata probes.

If the offered-digest inventory changes during a pass or probe, reconciliation defers withdrawals to a stable pass, preserving concurrent publication of the same digest.

The connector counter capacity_stale_inventory_snapshots and worker capacity-report field maintenance_stale_inventory_snapshots count these deferrals.

Restore still authenticates payload bytes; metadata qualification cannot establish their integrity or turn an invalid restore into a hit.

One filesystem operation or durability barrier can take arbitrarily long. Smaller deletion budgets can increase total scan work.

Cooldown trades reclamation throughput for gaps between that work. A larger watermark gap does not remove this cost.

MaintenanceReport.deletion_attempts counts admitted unlink attempts; work_pending reports cleanup deferred by the budget or orphan-first policy; skipped_cooldown reports a pass skipped before inventory work.

Connector counters capacity_deletion_attempts, capacity_budget_exhausted, and capacity_skipped_cooldown expose the same activity. Capacity log records include deletion_attempts and work_pending.

Prometheus gauges vllm:sparkcache_maintenance_deletion_attempts, vllm:sparkcache_maintenance_budget_exhausted, and vllm:sparkcache_maintenance_skipped_cooldown sum reported cumulative counts across ranks.

They reset with workers and reflect the last worker reports, not independent scrape-time measurements.

spark_cache_ttl_seconds expires manifests by recency; zero disables TTL. Maintenance preserves shared objects referenced by surviving manifests.

An admitted asynchronous publication can protect its base and result roots until post-commit reconciliation. Only one such publication runs per rank. Protected bytes still count against capacity.

Other roots remain eligible for eviction. Capacity may temporarily remain unsatisfied while a protected publication finishes; the single inflight admission prevents another protected publication from accumulating.

Success releases that protection before post-commit cleanup. Failure, preemption, and shutdown completion release it too. An unsatisfied capacity budget prevents another base reservation.

If the worker no longer offers the selected base, or maintenance is busy, capture switches to a complete snapshot without waiting. The existing ring size and admission limits still apply; an oversized snapshot is skipped.

To clear one cache root once, set spark_cache_clear_once to a deliberate token:

"spark_cache_clear_once": "storage-layout-reset-2026-08-31"

SparkCache removes only directories it owns, then writes a completion marker. Reusing the token does nothing. A different token requests another clear.

The root must be absolute, narrow, and free of symlinked components. A lock or filesystem failure disables caching for that connector while serving continues.

Diagnostics

Each asynchronous restore emits compact INFO lines with restored tokens, latency, effective token rate, bytes, and phase timings. A sparkcache-restore-timing/v1 JSON record with the complete phase breakdown is available at DEBUG.

Asynchronous publication emits a sparkcache: capture INFO line when the progress thread observes GPU-to-host copy completion. It reports rank, digest, tokens, observed elapsed time, effective token rate, and copied bytes.

The separate commit log reports durable-storage time. The two records separate capture interference from background storage work.

Each completed store also emits one compact sparkcache: publish line.

Scheduler aggregate telemetry is split into sparkcache: capacity, sparkcache: publications, and sparkcache: writes lines.

While capture owns finished-request pages, a sparkcache: capture aggregate line reports delayed requests, request-rank ownership records, retained manager pages, and the oldest ownership age.

The line disappears after every rank reports its terminal completion.

sparkcache: publication_work reports pending saver admissions, their oldest age, and ranks performing capacity maintenance. Admission age includes capture, queue time, commit, and post-commit reconciliation.

Each worker admits at most one saver publication. The pending rank-slot gauge sums these admissions across physical ranks; it is not a count of unique user requests. Age is the maximum reported across ranks.

The maintenance flag covers the scan and survivor reconciliation, including failure cleanup. Metrics sample it without taking the capacity lock or reading the filesystem.

Completed, failed, and aborted publications clear their age. A timed-out shutdown with a live saver remains pending instead of falsely reporting idle.

The same ownership state is available from the vLLM Prometheus endpoint:

Gauge Meaning
vllm:sparkcache_capture_delayed_requests Maximum delayed request count on any physical rank.
vllm:sparkcache_capture_delayed_rank_slots Request ownership records summed across physical ranks.
vllm:sparkcache_capture_retained_manager_pages Physical manager pages retained across ranks.
vllm:sparkcache_capture_oldest_delayed_seconds Age of the oldest retained request ownership.
vllm:sparkcache_capture_ownership_uncertain_ranks Ranks that cannot prove whether capture still owns source pages.
vllm:sparkcache_publication_pending_rank_slots Pending saver admissions summed across physical ranks.
vllm:sparkcache_publication_oldest_pending_seconds Maximum admission age at the last worker reports.
vllm:sparkcache_maintenance_active_ranks Ranks reporting an active scan or survivor reconciliation.

These gauges describe the last worker reports received through the existing statistics channel. Reports may stop refreshing while the engine is idle; scraping Prometheus again does not make a cached age a live clock.

Use report freshness when correlating idle-probe slowdowns with pending work.

Restore and store admission decisions are exported as cumulative counters summed across physical ranks. They explain why a span was not restored or published without enabling per-request tracing:

Counter Meaning
vllm:sparkcache_restore_hits External restores admitted by the scheduler.
vllm:sparkcache_restore_skip_local_prefix Lookups refused because the request already held locally cached prefix blocks.
vllm:sparkcache_restore_skip_oversize Lookups whose aligned span exceeded the maximum span.
vllm:sparkcache_restore_skip_backlog Lookups refused because pending restores reached the configured limit.
vllm:sparkcache_quorum_incomplete Lookups with no fully quorum-covered candidate manifest.
vllm:sparkcache_multimodal_bypass Requests skipped because a multimodal feature could not be proven.
vllm:sparkcache_store_skipped_delayed_limit Store plans dropped because delayed capture jobs reached the configured limit.
vllm:sparkcache_load_verified Worker restores whose bytes verified.
vllm:sparkcache_load_failed Worker restores that failed verification and degraded to recompute.
vllm:sparkcache_attribution_requests_complete Requests whose attribution summary completed cleanly (requires SPARK_CONTEXT_CACHE_TRACE_REUSE=1).
vllm:sparkcache_attribution_requests_incomplete Requests whose attribution summary was incomplete (requires SPARK_CONTEXT_CACHE_TRACE_REUSE=1).

Counters reset with the workers, like the other statistics-channel gauges. The existing streaming-publication handoff count remains separate from saver admissions and capture ownership.

Exact process-local totals are available from ManifestStore.publication_telemetry_snapshot() using schema sparkcache-publication-telemetry/v1.

Counter Meaning
logical_payload_bytes Encoded state represented by committed roots. A row tail or page delta counts only its extension.
reused_base_bytes Encoded base payload referenced without staging it again.
unique_object_bytes Complete immutable files newly linked or repaired, including metadata roots.
committed_unique_object_bytes Newly retained immutable bytes reachable from committed roots.
uncommitted_unique_object_bytes Immutable bytes left unreachable after an aborted or failed attempt.
staged_write_bytes Payload bytes submitted to temporary-file writes, including later deduplication.
deduplicated_bytes Identical immutable bytes already present at their content-addressed paths.
aborted_staged_write_bytes Bytes staged by publications explicitly abandoned before commit.
failed_staged_write_bytes Bytes staged by publications that ended with an error.

The counters describe host-side operations. They do not report filesystem allocation, NVMe Data Units Written, controller write amplification, or NAND writes.

Request reuse attribution

Status: implemented with an optional scheduler callback. A runtime without that callback cannot produce exact request attribution from connector offers.

Set SPARK_CONTEXT_CACHE_TRACE_REUSE=1 before startup. An instrumented scheduler emits one request_cache_attribution event in sparkcache-reuse-trace/v1 at request cleanup. No request IDs are added to Prometheus labels.

Field Meaning
local_tokens_reused GPU-resident prompt tokens consumed by accepted target execution, including resident shared leases.
external_tokens_reused Prompt tokens consumed after a successful all-rank persistent restore and the scheduler's final-token adjustment.
prompt_tokens_computed Prompt intervals completed by accepted target execution, accumulated across preemption attempts.
preemptions Request preemption generation observed by the scheduler.
attribution_complete True only for normal completion with observed prompt completion and no missing or invalid accounting boundary.

Counts cover accepted target-prompt work across attempts. They can exceed the original prompt length after preemption. They exclude output tokens, draft execution, replay inside kernels, and rejected worker output.

An offered restore earns no credit. A verified restore aborted before target execution earns no reused-token credit. A follower consuming a resident GPU lease records local reuse, even if a different request restored that lease.

The restored state span and external prompt tokens reused are distinct. A restore can write an already-local prefix, and a full prompt hit still needs the final prompt token recomputed for sampling logits.

Incomplete observations remain labeled incomplete. Their token fields are not added to the connector's attribution_completed_* aggregate counters. Request cleanup releases the ledger even when logging fails.

Telemetry is observational. It cannot change publication, restore, cache identity, or serving decisions.

Timing is diagnostic only. Missing timing data does not change whether a stored entry may be used.

Package map

Module Purpose
spark_context_cache_connector.py Scheduler decisions, worker I/O, all-rank agreement, and vLLM callbacks
spark_context_cache_config.py Validated settings, topology, and cache identity
spark_context_cache_profiles.py Storage layout, record schema, geometry, and profile checks
persistent_context_cache/cache_manifest.py Publication, lookup, restore, invalidation, and maintenance
spark_context_cache_cuda_placement.py Attested C++/CUDA placement transaction
spark_context_cache_cuda_restore.py Bounded reading, verification, and placement
streaming/ Default-off streaming publication research
replication/ Carrier-independent replication research

sparkcache.spark_context_cache_store is the stable manifest-store import.

Profiles and tests

Model names, checkpoints, topology, launch commands, measurements, and live test records live under ../deploy/.

python -m pytest sparkcache -q
python -m ruff check sparkcache

The Python suite is GPU-free. CUDA execution requires a compatible build from native/CMakeLists.txt.