Commit graph

6,673 commits

Author SHA1 Message Date
Daniel Han
89e5f69d90 Don't prefetch dense shards for a prequant load; surface resolved provenance
- _dense_quant_prefetch_needed widened the transformer/ prefetch to pull the base
  repo's full dense bf16 shards even when a prequant checkpoint is configured
  (candidate.prequant), contradicting its own docstring. That both defeats the
  prequant download savings and can hard-fail begin_load on a disk-full (no GGUF
  fallback there). Only widen for a real dense build (candidate is not None and
  not candidate.prequant).
- DiffusionStatusResponse declared no 'resolved' field, so Pydantic's default
  extra='ignore' silently dropped the per-control auto-policy provenance the
  backend records (build_resolved_record / state.resolved) -- the plumbing never
  reached any client. Declare the field so it round-trips.
2026-07-06 11:52:32 +00:00
pre-commit-ci[bot]
e6bd256ad6 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-06 10:50:45 +00:00
Daniel Han
311d9da637 diffusion: disk-gate the dense-quant prefetch, keep Speed=off bit-exact
- _dense_quant_prefetch_needed widened the prefetch to pull the base repo's bf16 transformer/ shards
  whenever a dense-quant scheme could resolve, with no disk check. On the offload path that can fill
  the cache volume mid-download and hard-fail the load in a spot unload/cancel cannot preempt, instead
  of the disk guard falling back to running the GGUF as-is (the Dtype hint's documented disk fallback).
  Defer to resolve_dense_quant_candidate, the same disk-aware resolver load_pipeline re-plans against,
  so the prefetch widens only when the dense build would really run.
- An explicit Speed=off (bit-exact) load with an unset dtype was promoted to auto-quant by the Dtype
  default, silently engaging int8/fp8 + compile and breaking the bit-exact request (an auto DEFAULT
  overriding an EXPLICIT control). Suppress the auto-dtype default when speed is explicitly off, in both
  load_pipeline and the prefetch.
2026-07-06 10:50:09 +00:00
pre-commit-ci[bot]
7c72910487 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-06 08:49:31 +00:00
Daniel Han
092fc91e08 diffusion: don't double-count the prefetched transformer in the dense re-plan
The dense-quant re-plan passes transformer_resident_override_mib (the bf16 build
peak) AND computes companions via _companion_cache_bytes(base), which sums every
flat blob in the HF cache. Because the dense path prefetches the base transformer/
shards into that same cache before load_pipeline runs, the transformer is counted
twice, inflating the footprint (~44 GB instead of ~20 GB in the reproduction) and
wrongly forcing offload for models that fit resident -- the case this path exists
to enable. Add companion_override_mib and pass the auto-policy's own text-encoder
plus VAE estimate on the re-plan so the cache (with its prefetched transformer) is
not read for this artifact.
2026-07-06 08:48:13 +00:00
Daniel Han
23ade68c51 Merge remote-tracking branch 'origin/diffusion-train-perf2' into diffusion-auto-policy 2026-07-05 11:52:32 +00:00
Daniel Han
d6ce610324 Merge remote-tracking branch 'origin/diffusion-krea2' into diffusion-train-perf2 2026-07-05 11:52:30 +00:00
Daniel Han
099357cf40 Merge remote-tracking branch 'origin/diffusion-train-tab-2' into diffusion-krea2 2026-07-05 11:52:29 +00:00
Daniel Han
303d38cf98 Merge remote-tracking branch 'origin/diffusion-train-precision' into diffusion-train-tab-2 2026-07-05 11:52:28 +00:00
Daniel Han
78a6ad3fff Merge remote-tracking branch 'origin/diffusion-train-perf' into diffusion-train-precision 2026-07-05 11:52:27 +00:00
Daniel Han
59bf54e975 Merge remote-tracking branch 'origin/image-generation' into diffusion-train-perf 2026-07-05 11:52:25 +00:00
pre-commit-ci[bot]
a45b4b2ec3 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 11:44:30 +00:00
pre-commit-ci[bot]
83bc33d04a [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 11:43:58 +00:00
pre-commit-ci[bot]
293b770c78 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 11:43:23 +00:00
pre-commit-ci[bot]
9caab52bfd [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 11:42:50 +00:00
pre-commit-ci[bot]
1a72a06b1d [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 11:42:17 +00:00
pre-commit-ci[bot]
d6703962d3 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 11:41:43 +00:00
pre-commit-ci[bot]
e800675128 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 11:40:35 +00:00
Daniel Han
a20049bfc0 Merge branch 'diffusion-train-perf2' into diffusion-auto-policy 2026-07-05 11:39:30 +00:00
Daniel Han
66387c1533 Merge branch 'diffusion-krea2' into diffusion-train-perf2 2026-07-05 11:39:16 +00:00
Daniel Han
f543af6d27 Merge branch 'diffusion-train-tab-2' into diffusion-krea2 2026-07-05 11:39:15 +00:00
Daniel Han
5979d68a03 Merge branch 'diffusion-train-precision' into diffusion-train-tab-2 2026-07-05 11:39:14 +00:00
Daniel Han
2d466df322 Merge branch 'diffusion-train-perf' into diffusion-train-precision 2026-07-05 11:39:12 +00:00
Daniel Han
b88d0d49b8 Merge branch 'image-generation' into diffusion-train-perf 2026-07-05 11:39:11 +00:00
Daniel Han
fc1e099124 Harden ControlNet loads, thumbnail cache keys, API training guard, and picker roving keys
Review follow-ups on the image-generation PR:

- ControlNet: resolve_controlnet accepts a bare owner/name repo without the
  non-GGUF base trust gate, and _controlnet_pipe hands it straight to
  from_pretrained. A malicious pickle .bin would deserialize on load, so run
  the same Hugging Face malware preflight (evaluate_file_security) the chat and
  export loaders use before any remote ControlNet load; local dirs are exempt.
- Dataset thumbnails: key the cache on the full filename instead of the stem so
  sample.png and sample.jpg no longer collide on one .thumbs file (which could
  serve or delete the wrong image); the delete cleanup globs the same key.
- Diffusion training start: mirror start_training's API-key guard so an API
  client cannot start training (which frees VRAM by unloading chat) while an
  inference request is streaming; it now returns 409 before any GPU is freed.
- Model picker: include the curated safetensors row keys in the recommended
  roving key list so arrow-key navigation reaches those rows instead of hitting
  the duplicate option-missing id.

Tests: ControlNet malware gate (remote blocked before from_pretrained, local
skipped), thumbnail same-stem cache separation, API-key diffusion-start 409
before GPU free. Full diffusion suites green.
2026-07-05 11:36:58 +00:00
Daniel Han
7883a16f30 Merge branch 'diffusion-train-perf2' into diffusion-auto-policy 2026-07-05 08:55:41 +00:00
Daniel Han
d329e5db37 Merge branch 'diffusion-krea2' into diffusion-train-perf2 2026-07-05 08:55:40 +00:00
Daniel Han
369a792b04 Merge branch 'diffusion-train-tab-2' into diffusion-krea2 2026-07-05 08:55:39 +00:00
Daniel Han
1f8315c698 Merge branch 'diffusion-train-precision' into diffusion-train-tab-2 2026-07-05 08:55:38 +00:00
Daniel Han
dd6be63d1a Merge branch 'diffusion-train-perf' into diffusion-train-precision 2026-07-05 08:55:37 +00:00
pre-commit-ci[bot]
f9e290a824 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 07:59:57 +00:00
pre-commit-ci[bot]
1c40fa855f [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 07:59:24 +00:00
pre-commit-ci[bot]
d0f7dad7ec [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 07:58:51 +00:00
pre-commit-ci[bot]
b1fdefb43d [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 07:57:51 +00:00
pre-commit-ci[bot]
f343eadcd7 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 07:57:16 +00:00
Daniel Han
8dce79ff51 Merge branch 'diffusion-train-perf2' into diffusion-auto-policy 2026-07-05 07:57:01 +00:00
Daniel Han
466f853f14 Merge branch 'diffusion-krea2' into diffusion-train-perf2 2026-07-05 07:56:51 +00:00
Daniel Han
4b93558ad4 Merge branch 'diffusion-train-tab-2' into diffusion-krea2 2026-07-05 07:56:47 +00:00
pre-commit-ci[bot]
bc38ca397e [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 07:56:43 +00:00
Daniel Han
69f32b9586 Merge branch 'diffusion-train-precision' into diffusion-train-tab-2 2026-07-05 07:56:20 +00:00
Daniel Han
3925aea07f Merge branch 'diffusion-train-perf' into diffusion-train-precision 2026-07-05 07:56:14 +00:00
Daniel Han
8c00f81a5d Size-gate the automatic diffusion latent cache
The latent cache holds two fp32 posterior tensors per crop/flip variant per
image, pinned on CUDA hosts, so datasets with thousands of images can exhaust
host or pinned memory with no fallback. Estimate the cache size from the first
real encoded latent and fall back to per-step VAE encoding when it exceeds a
4 GiB budget. UNSLOTH_DIFFUSION_FORCE_LATENT_CACHE bypasses the gate; the
existing UNSLOTH_DIFFUSION_NO_LATENT_CACHE opt-out is unchanged.
2026-07-05 07:53:12 +00:00
Daniel Han
da3a79468e Use permutation-cycle index sampling in diffusion trainers and guard non-object run records
Replace the with-replacement per-batch index draw in the SDXL and DiT LoRA
trainers with a shared PermutationBatchSampler that visits every image once per
cycle before repeating, so short runs cover the whole dataset. The sampler
reshuffles from the run's rng so the index stream stays seed-deterministic.

Guard the diffusion run detail route against a valid-JSON non-object record,
which previously raised TypeError and returned a 500; it now 404s like the list
path's shape check.

Add regression tests for both.
2026-07-05 07:49:30 +00:00
Daniel Han
45e6dc8a12 Merge branch 'diffusion-train-perf2' into diffusion-auto-policy 2026-07-05 07:41:34 +00:00
Daniel Han
715d4965c8 Merge branch 'diffusion-krea2' into diffusion-train-perf2 2026-07-05 07:41:32 +00:00
Daniel Han
866e03d4ce Merge branch 'diffusion-train-tab-2' into diffusion-krea2 2026-07-05 07:41:31 +00:00
Daniel Han
882b5354c4 Merge branch 'diffusion-train-precision' into diffusion-train-tab-2 2026-07-05 07:41:30 +00:00
Daniel Han
8c4cdcd385 Merge branch 'diffusion-train-perf' into diffusion-train-precision 2026-07-05 07:41:29 +00:00
Daniel Han
3977f1a71d Merge branch 'image-generation' into diffusion-train-perf 2026-07-05 07:41:28 +00:00
Daniel Han
f313cfd7e5 Security audit: baseline the new huggingface-hub Sandboxes findings
The latest huggingface-hub release added the Sandboxes feature. Its
bootstrap (_sandbox.py) fetches the static sbx-server binary into /tmp with
an Authorization header and marks it executable, which is exactly the
staged-dropper pattern the scanner hunts, and three while True polling loops
in _sandbox.py / hf_api.py / utils/_http.py match the beaconing heuristic.
All four verified against the official huggingface/huggingface_hub
repository: the snippet is the documented sandbox server injection and the
loops are deadline-style job and sandbox polling. Entries generated with
--write-baseline and reviewed line by line; scan_packages.py huggingface-hub
now exits 0 with the four findings suppressed.
2026-07-05 07:40:45 +00:00