Node-Local Model Weight Cache With Pinned Entries

Last updated: November 29, 2026

Quick Overview

Design a size-bounded LRU cache of model weights on a GPU node's local disk where models backing a live replica are pinned and cannot be evicted. put(model, size) must evict least recently used unpinned models to make room, or refuse without evicting anything if the model cannot fit.

Baseten
Software Engineering Fundamentals
Software Engineer
Baseten
November 29, 2026
Software Engineer
Technical Screen
Software Engineering Fundamentals
Medium

0

0

0 solved


Design a size-bounded LRU cache of model weights on a GPU node's local disk where models backing a live replica are pinned and cannot be evicted. put(model, size) must evict least recently used unpinned models to make room, or refuse without evicting anything if the model cannot fit.

Weight loading dominates cold starts for large models, which is why Baseten caches weights across storage tiers and on nodes. This question checks an LRU keyed by bytes instead of item count, plus the safety rule that you never evict weights a running replica still needs.

What the Interviewer Expects
  • Uses an ordered map so lookups, touches and evictions are O(1) amortized
  • Accounts capacity in GB, not entry count
  • Skips pinned entries during eviction and supports pin reference counts
  • Checks feasibility before evicting so a failed put does not destroy useful cache
  • Handles re-inserting an existing model as a touch
Key Topics to Cover
LRU cache
OrderedDict
reference counting
eviction policy
cold starts
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • Two replicas on the node start the same 140 GB model at once. How do you avoid downloading it twice?
  • How would you prefer evicting large cold models over small warm ones (size-aware eviction)?
  • What metrics tell you the cache is too small?
  • How do partial downloads get cleaned up after a node crash?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

Operations: get(model) returns hit or miss and refreshes recency; put(model, size_gb) inserts and returns the evicted list, or None if impossible; pin/unpin mark models that live replicas de...

High-Level Design

An OrderedDict gives LRU order with O(1) move-to-end. A separate pin-count dict lets two replicas pin the same model. Before evicting, compute how much space unpinned entries could free; if even evi...


Submit Your Answer
Markdown supported

Related Questions