Repository navigation
feat(placement): memory pressure awareness instead of memory used - #2472
Open
presentyourlove wants to merge 1 commit into
Open
presentyourlove wants to merge 1 commit into
presentyourlove wants to merge 1 commit into
Conversation
…ilicon and cross-platform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR resolves item 13 in
TODO.md:Memory pressure instead of memory used.Background & Motivation
On macOS and Apple Silicon unified memory architectures, the Mach virtual memory subsystem actively retains file-backed caches, purgeable pages, and inactive allocations rather than leaving RAM empty ("Free RAM is wasted RAM"). Consequently:
macmonand standard tools report "memory used" hovering around 85%–95%, even when 30–60 GB of file cache can be immediately and painlessly reclaimed by the OS for Metal/MLX allocations.src/exo/utils/info_gatherer/macmon.py, naiveram_available = ram_total - ram_usagefalsely pegged available memory to a few gigabytes.src/exo/master/placement_utils.py, the placement engine erroneously rejected model shards larger than the tiny reported headroom (ValueError: Node has insufficient memory), or severely under-allocated layers to Apple Silicon devices in mixed clusters.Key Changes
Memory Pressure Models (
src/exo/shared/types/profiling.py):MemoryPressureLevel(str, Enum)withNORMAL(macOS level 1, comfortable headroom),WARNING(macOS level 2, compression/swap starting),CRITICAL(macOS level 4, thrashing/OOM risk), andUNKNOWN.pressure_levelandpressure_pcttoMemoryUsage.Core Memory Pressure Prober (
src/exo/utils/info_gatherer/memory_pressure.py):kern.memorystatus_vm_pressure_levelvia libcsysctlbyname(sub-microsecond execution without subprocess overhead) with CLI fallback.vm_statto distinguish unpaged wired memory from purgeable/inactive file cache.NORMALpressure:CRITICALpressure to prevent OOM kills./proc/pressure/memory) or falls back to commit-charge/psutil metrics.Collector Integration (
src/exo/utils/info_gatherer/macmon.py,src/exo/utils/info_gatherer/info_gatherer.py):MacmonMetrics.from_rawwithprobe_memory_pressure._monitor_memory_usagefor non-macmon platforms.Adaptive Layer Placement (
src/exo/master/placement_utils.py,src/exo/master/placement.py):filter_cycles_by_memory, automatically filters out cycles containing nodes underCRITICALmemory pressure._allocate_and_validate_layers, derates layer allocation weights forWARNINGnodes (0.6x) to naturally steer workloads toward healthierNORMALnodes._not_enough_memoryand allocation checks with explicit memory pressure levels.Dashboard Visualization (
dashboard/src/lib/stores/app.svelte.ts,dashboard/src/lib/components/TopologyGraph.svelte):pressureLevelandpressurePctacross frontend state pipeline.NORMAL,WARNING,CRITICAL) in node tooltips on the topology graph.Unit Tests (
src/exo/utils/info_gatherer/tests/test_memory_pressure.py,src/exo/master/tests/test_memory_pressure_placement.py):Verification
.venv/Scripts/pytest.exe src/exo/utils/info_gatherer/tests/test_memory_pressure.py src/exo/master/tests/test_memory_pressure_placement.py src/exo/master/tests/test_placement.py -v # 40 passed in 0.85s.venv/Scripts/ruff.exe check src/exo/shared/types/profiling.py src/exo/utils/info_gatherer/memory_pressure.py src/exo/utils/info_gatherer/macmon.py src/exo/master/placement_utils.py src/exo/master/placement.py src/exo/utils/info_gatherer/tests/test_memory_pressure.py src/exo/master/tests/test_memory_pressure_placement.py # All checks passed!Related Issues
TODO.md(Memory pressure instead of memory used.)