VFlash: Fast, Accurate Visual Planning via Flash Primitive Decoding
u_Unrolled
DSA for AI/ML · Module 06: Stacks and queues

Lesson 6.10 of 10 in this module Unrolled Pro

Rolling Maximum of GPU Memory Use

Peak GPU memory over the last W seconds, updated on every sample, for alerting and capacity decisions. From scanning all history back to the window edge, to a deque of the samples in the window (O(window) per sample), to a monotonic deque of (timestamp, MB) that expires by time (O(1) amortised). Then many GPUs and devices that stop reporting, several windows at once, bounded memory at high sample rates with per-bucket maxima, and why a rolling p99 needs a different tool.

about 10 min 5 Python examples 2 quick checks

Problem. A training job reports GPU memory samples (t, mb): t in seconds, increasing but irregularly spaced, mb the memory in use. After each sample, return the peak memory over the last W seconds, the window (t − W, t]. An alert fires when the peak crosses a budget.

text
W = 2.0
samples = (0.0, 1200) (0.4, 3100) (1.1, 2900) (1.5, 2400) (2.2, 2600) (3.0, 1800) (3.6, 2000)
peaks   =  1200        3100        3100        3100        3100        2900        2600

At t = 3.0 the 3,100 MB spike at t = 0.4 has left the window, and the peak drops to 2,900 (from t = 1.1).

Why it matters. Out-of-memory crashes come from peaks, not averages: one long sequence or one fragmentation spike kills a run that averages 60% use. Peak memory over a window drives alerts ("above 90% of 80 GB in the last minute"), autoscaling and batch-size decisions (lesson 5.10). Monitoring agents run this computation on every sample, on every GPU, all day, so the per-sample cost and the memory held matter.


1. Step 1: Clarify

That's the preview. Modules 00–01 are free; this lesson is part of Unrolled Pro.
Staff AI & Pro Tier Lesson

Unlock "Rolling Maximum of GPU Memory Use"

The foundations are free forever. Unrolled Pro unlocks the complete lesson, production architectures, and 55 battle-tested ML system design case studies.

Everything included with Pro:
All 234+ Deep-Dive Lessons across transformer internals, inference, RAG & agents
55 Staff-Level ML & System Design Case Studies with mathematical capacity estimates
AI Engineer Sheet & Exercises with worked solutions, self-checks, and code
100 Landmark Research Papers guided walkthroughs & progress tracking
14-Day Money-Back Guarantee — 100% full refund if you aren't satisfied
View Plans & Unlock All Lessons

From ₹167/mo (~$2/mo) · Cancel anytime · Instant activation

100% Risk-Free: 14-day no-questions-asked money-back guarantee