From 95bba36b2414437007ad4132741fd3ee2131709b Mon Sep 17 00:00:00 2001 From: TroyHernandez Date: Tue, 11 Aug 2026 06:54:22 -0500 Subject: [PATCH] recommend(): 0.5 GB tolerance so nameplate min_vram tiers are reachable Fixes #56. min_vram thresholds are nameplate card sizes but vram_gb is free VRAM; an 8 GB card reports ~7.5-7.9 free, so the flux-family 8 GB tiers (and every other nameplate-valued threshold) silently dropped to the CPU tier on exactly the cards they target. --- DESCRIPTION | 2 +- NEWS.md | 9 +++++++++ R/recommend.R | 7 ++++++- inst/tinytest/test_recommend.R | 11 +++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 548c464..d59960d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: diffuseR Title: Functional Interface to Diffusion Models in R -Version: 0.2.2.1 +Version: 0.2.2.2 Authors@R: c( person("Troy", "Hernandez", email = "troy@cornball.ai", role = c("aut", "cre"), comment = c(ORCID = "0009-0005-4248-604X")), diff --git a/NEWS.md b/NEWS.md index e345f0c..ec7f263 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,12 @@ +# diffuseR 0.2.2.2 + +* `recommend()` tier selection now applies a 0.5 GB tolerance to the + `min_vram` thresholds (#56). The thresholds are nameplate card sizes, + but detection reports free VRAM and no card reports its nameplate as + free, so every nameplate-valued tier (the flux-family 8 GB tiers, the + SDXL 12 GB tier, the flux2 bf16 16 GB tier) was unreachable on + exactly the card it targets and silently dropped to the CPU tier. + # diffuseR 0.2.2.1 * `txt2img()` and `img2img()` now `match.arg()` their `model_name`, so diff --git a/R/recommend.R b/R/recommend.R index 7f2f427..e91a051 100644 --- a/R/recommend.R +++ b/R/recommend.R @@ -93,7 +93,12 @@ recommend <- function(model = c("sd21", "sdxl", "flux1", "flux2", "zimage", chosen <- NULL want <- NULL # first VRAM-eligible tier blocked by a missing read cap for (tier in tiers) { - if (vram_gb < tier$min_vram) { + # min_vram values are nameplate card sizes (8, 12, 16...), but + # vram_gb is FREE VRAM, and no card reports its nameplate as + # free (an 8 GB card shows ~7.5-7.9). Without the 0.5 GB + # tolerance every nameplate-valued tier is unreachable on + # exactly the card it targets (#56). + if (vram_gb < tier$min_vram - 0.5) { next } need <- tier$needs diff --git a/inst/tinytest/test_recommend.R b/inst/tinytest/test_recommend.R index ac8f318..41c2881 100644 --- a/inst/tinytest/test_recommend.R +++ b/inst/tinytest/test_recommend.R @@ -19,6 +19,17 @@ expect_true(all(c("precision", "devices", "offload", "max_pixels", names(r))) expect_true(is.integer(r$max_pixels) || is.numeric(r$max_pixels)) +# --- nameplate tiers reachable on their own cards (#56) -------------------------- + +# min_vram thresholds are nameplate sizes, but detection reports free +# VRAM: a real 8 GB card shows ~7.5-7.9 free. The 0.5 GB tolerance keeps +# the 8 GB tier selectable there; below the tolerance drops to CPU. +r8 <- recommend("flux2", vram_gb = 7.6, st_caps = cran) +expect_equal(r8$devices$transformer, "cuda") +expect_equal(r8$precision, "nf4") +r7 <- recommend("flux2", vram_gb = 7.4, st_caps = cran) +expect_true(all(unlist(r7$devices) == "cpu")) + # --- floors: nf4 for the quantized families, fp16 for SD ------------------------- # No GPU: everything runs on CPU at its floor precision, no fork nag.