Repository navigation
fix(persona/allocator): isolate test_allocate_no_keys from host VRAM detection - #1509
Conversation
…detection
`test_allocate_no_keys` was failing on Intel Mac with AMD Radeon Pro
560X. Root cause: the test fixture `test_gpu_manager()` calls
`GpuMemoryManager::detect()` which probes the real Metal device. On
this host:
AMD Radeon Pro 560X (4 GB VRAM)
- 0.5 GB metal reserve = 3.5 GB usable
- 2 GB allocator system-reserve = 2 GB usable headroom
Every local persona in catalog.json declares
`modelPreferences[0].vramBudgetGb = 3`
→ 0 local personas fit → `assert!(local_count >= 1)` blows.
The allocator's job is "given a hardware budget, decide what to
spawn." The test should hand it a known budget, not ask the OS. Adds
a deterministic fixture `test_gpu_manager_with_vram_gb(vram_gb)` that
uses `GpuMemoryManager::new_for_test`, and switches the failing test
to use it with 16 GB. `test_gpu_manager()` (the real-detect fixture)
stays for tests that genuinely care about host detection
(`test_allocate_with_anthropic_key` still uses it — it asserts on
cloud-persona allocation which doesn't depend on VRAM at all, so
detection drift doesn't break it).
Verified on Intel Mac + AMD discrete:
cargo test --lib --no-default-features \
--features livekit-webrtc,accelerate,llama/mac-cpu-only,load-dynamic-ort \
persona::allocator
→ 12 passed; 0 failed
The architectural question of whether Intel Mac + AMD discrete
should fall back to system RAM for inference budget (vs trusting
the AMD VRAM) is separate — task #52 (Governor classify_silicon
misclassifies Mac Intel as AppleM) tracks the related substrate-
side decision. This commit fixes the test isolation; the substrate
fix lands separately.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
Adversarial Review — PR #1509Verdict: REQUEST_CHANGES The diagnosis is correct, the scope discipline is right, and the failure-mode comment in Blocking findings1.
|
…1509 review) PR #1509's first revision added `test_gpu_manager_with_vram_gb` — a new fixture that reinvented `GpuMemoryManager::simulated` (gpu/memory_manager.rs:461), which is already #[cfg(test)], already uses the real production split constants (RESERVE_PCT, INFERENCE_BUDGET_PCT, TTS_BUDGET_PCT, RENDERING_BUDGET_PCT), and is already in use in the SAME test module by `test_allocate_5090_tier` and `test_allocate_m1_pro_tier`. Per [[organization-purity-as-we-migrate]] — one logical decision, one place. Replace the duplicate fixture with a direct call to `GpuMemoryManager::simulated("test:synthetic", 16 GiB)` in the test that needed it. Drop the comment that misstated production reserve % / per-subsystem ratios. Verified: full `cargo test persona::allocator` still 12 passed. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Addressed in ed38890 — dropped the duplicate fixture, switched to |
Summary
persona::allocator::tests::test_allocate_no_keyswas failing on Intel Mac + AMD Radeon Pro 560X. Root cause: the test fixturetest_gpu_manager()callsGpuMemoryManager::detect()which probes the real Metal device. AMD's 4 GB VRAM minus reserves leaves 2 GB usable; every local persona incatalog.jsonneeds 3 GB (modelPreferences[0].vramBudgetGb). Result: 0 local allocations, and thelocal_count >= 1invariant blows up.test_gpu_manager_with_vram_gb(vram_gb)— deterministic fixture usingGpuMemoryManager::new_for_test. Switchestest_allocate_no_keysto 16 GB so it actually tests allocation logic, not host detection.test_gpu_manager()(real-detect) in place for tests that genuinely care about host probing.Why this isolation
The allocator's contract is "given a hardware budget, decide what to spawn." A pure-logic test should hand it a known budget, not ask the OS — otherwise the assertion drifts with whatever GPU happens to be installed. Per [[every-error-is-an-opportunity-to-battle-harden]] the fix adds the rigging that catches the class next time: any new allocation-logic test gets the deterministic fixture for free.
What this PR does NOT fix
The architectural question — should Intel Mac with AMD discrete fall back to system RAM for inference budget? — is separate. Task #52 (Governor classify_silicon misclassifies Mac Intel as AppleM) tracks the substrate-side decision. This PR fixes the test isolation only.
Reference docs
src/workers/continuum-core/src/persona/allocator.rs— the file (no other changes)src/workers/continuum-core/src/gpu/memory_manager.rs:491—new_for_testconstructor this PR consumesTest plan
cargo test persona::allocator::tests::test_allocate_no_keys→FAILED(Should create at least one local persona)cargo test persona::allocator→ 12 passed; 0 failed🤖 Generated with Claude Code