fix(p1g): garde-fou VRAM adapté à la mémoire unifiée (DGX GB10)
Some checks failed
tests / Lint (ruff + black) (push) Failing after 1m44s
tests / Tests unitaires (sans GPU) (push) Failing after 1m49s
tests / Tests sécurité (critique) (push) Has been skipped

resolve_device('auto') renvoyait 'cpu' sur le GB10 : le plafond max_total_gb=6
(pensé pour la RTX 12 Go dédiés) voyait used≈99 Go car la mémoire UNIFIÉE compte
la RAM système. Au-dessus de DEFAULT_LARGE_VRAM_GB=24 (grosse carte / mémoire
unifiée), le plafond n'est plus appliqué ; seul free >= min_free_gb décide.
RTX (<=24 Go) inchangée.

Détecté au bench GB10 2026-06-08 (auto->cpu, OCR 10x plus lent). +2 tests (17/17).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dom
2026-06-08 17:43:12 +02:00
parent 6d34b3cb68
commit 0ee54157e5
2 changed files with 38 additions and 3 deletions

View File

@@ -105,6 +105,26 @@ def test_resolve_auto_cuda_when_under_total_cap(monkeypatch):
max_total_gb=6.0) == "cuda"
# ── mémoire unifiée / grosse carte (DGX GB10) : plafond inapplicable ─────────
def test_resolve_auto_cuda_on_unified_memory_ignores_total_cap(monkeypatch):
"""Mémoire unifiée GB10 : total=121, free=22 → used=99 > cap 6, MAIS total
> seuil grosse mémoire (24) → plafond ignoré, free 22 ≥ min 2 → CUDA.
Sans ce comportement, le DGX tomberait à tort sur CPU (régression observée
au bench GB10 2026-06-08)."""
monkeypatch.delenv("RPA_VISION_DEVICE", raising=False)
with _mock_cuda(available=True, free_gb=22.0, total_gb=121.0):
assert device_policy.resolve_device("auto", min_free_gb=2.0,
max_total_gb=6.0) == "cuda"
def test_resolve_auto_cpu_on_large_memory_when_free_too_low(monkeypatch):
"""Grosse mémoire mais free < min → CPU (free reste le garde-fou réel)."""
monkeypatch.delenv("RPA_VISION_DEVICE", raising=False)
with _mock_cuda(available=True, free_gb=1.0, total_gb=121.0):
assert device_policy.resolve_device("auto", min_free_gb=2.0) == "cpu"
# ── override env RPA_VISION_DEVICE ──────────────────────────────────────────
def test_env_override_cpu_forces_cpu_even_in_auto(monkeypatch):