Skip to content

Fetch hosted prebuilt NF4 artifacts for flux2 and zimage - #58

Merged
TroyHernandez merged 7 commits into
mainfrom
feat/prebuilt-nf4
Aug 12, 2026
Merged

Fetch hosted prebuilt NF4 artifacts for flux2 and zimage#58
TroyHernandez merged 7 commits into
mainfrom
feat/prebuilt-nf4

Conversation

@TroyHernandez

Copy link
Copy Markdown
Contributor

Reverses 0.2.2's no-hosting decision, narrowly, per the rationale now in NEWS: the CRAN safetensors cannot read any of the multi-GB upstream sources (fix merged upstream as mlverse/safetensors#14, unreleased), so a stock CRAN install cannot build a quantized artifact at all. Hosting the two redistributable models (Apache-2.0, ungated) gives install.packages("diffuseR") something to generate with right away.

  • download_flux2_klein() / download_zimage_turbo() gain prebuilt = TRUE: when the resolved precision is nf4 and no local artifact exists, fetch from cornball-ai/flux2-R / cornball-ai/zimage-R (dataset repos, same naming convention as the sd21/sdxl TorchScript era), hard-linking out of the hfhub cache. Any fetch failure falls back to the source+quantize path unchanged.
  • Auto-resolution already picks nf4 on stock-CRAN machines and fp8 on float8-capable ones, so the no-argument call does the right thing on both.
  • flux1 (gated repo) and ltx (LTX-2 Community License) are deliberately absent from the spec; a test pins the hosted set to exactly flux2+zimage.
  • Artifacts are built (klein 2.1 GB / zimage 3.5 GB, all shards < 2^31 bytes, bf16 residents) and smoke-tested: klein nf4 generated a clean 512x512 in 11.3 s. Upload to HF is pending a write-scoped token.
  • Also fixes the stale Klein 13 s README timing to the 0.2.2-measured 9.1 s (fp8) and notes the prebuilt path in the model examples.

Merge after the artifacts are live on HF (the code is safe either way: unreachable repos fall back to a local build).

download_flux2_klein() and download_zimage_turbo() gain prebuilt = TRUE:
when the resolved precision is nf4 and no local artifact exists, the
artifact is fetched from the cornball-ai/<model>-R HuggingFace dataset
(hard-linked out of the hfhub cache) instead of downloading the 7.8 GB
/ 24.6 GB source and quantizing locally. Any fetch failure falls back
to the source + quantize path unchanged. Only the two redistributable
models are hosted; flux1 (gated) and ltx (license) build locally as
before. Also updates the stale Klein 13 s README timing to the 0.2.2
measured 9.1 s (fp8).
Every model download is consent-gated by contract (NEWS 0.2.0); the
prebuilt fetch was bypassing the gate. Ask before any network fetch,
skip the ask when the artifact is already fully hub-cached, and fall
through to the source path (with its own larger ask) on decline.
@TroyHernandez
TroyHernandez merged commit ea2965b into main Aug 12, 2026
2 checks passed
@TroyHernandez
TroyHernandez deleted the feat/prebuilt-nf4 branch August 12, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant