Commit graph

1,593 commits

Author SHA1 Message Date
Daniel Han
84bbc9d5a5 Merge branch 'diffusion-more-families' into video-inference 2026-07-05 11:39:46 +00:00
Daniel Han
2e3bd9b393 Merge branch 'diffusion-auto-badges' into diffusion-more-families 2026-07-05 11:39:35 +00:00
Daniel Han
af76745353 Merge branch 'diffusion-auto-install' into diffusion-auto-badges 2026-07-05 11:39:34 +00:00
Daniel Han
3c4dd8d118 Merge branch 'diffusion-fp16-accum' into diffusion-auto-install 2026-07-05 11:39:32 +00:00
Daniel Han
ac90e6cdab Merge branch 'diffusion-auto-policy' into diffusion-fp16-accum 2026-07-05 11:39:31 +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
pre-commit-ci[bot]
34ca1d7755 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 08:03:19 +00:00
pre-commit-ci[bot]
c23c0d6047 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 08:02:46 +00:00
pre-commit-ci[bot]
95b0356d6f [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 08:01:42 +00:00
pre-commit-ci[bot]
6c486cc452 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 08:01:07 +00:00
pre-commit-ci[bot]
5ff6a87336 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2026-07-05 08:00:31 +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
Daniel Han
e0235111a6 Merge branch 'diffusion-more-families' into video-inference 2026-07-05 07:57:28 +00:00
Daniel Han
d8adabb389 Merge branch 'diffusion-auto-badges' into diffusion-more-families 2026-07-05 07:57:22 +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
266c75501a Merge branch 'diffusion-auto-install' into diffusion-auto-badges 2026-07-05 07:57:16 +00:00
Daniel Han
ff7814f452 Merge branch 'diffusion-fp16-accum' into diffusion-auto-install 2026-07-05 07:57:11 +00:00
Daniel Han
c800d7cf93 Merge branch 'diffusion-auto-policy' into diffusion-fp16-accum 2026-07-05 07:57:06 +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
6485e68147 Harden video load path: early GGUF-repo rejection, family fallback parity, rollback and teardown fixes
Review follow-ups on the video inference backend:

- validate_load_request now rejects a -GGUF repo picked as a diffusers
  pipeline (no gguf_filename) up front, instead of failing minutes later
  in from_pretrained after the GPU owner was already evicted.
- New _detect_load_family helper shared by validate_load_request and
  _run_load: when the repo id alone does not carry the family, fall back
  to detecting it from the picked GGUF filename, so both paths agree.
- routes/video.py now threads base_repo into validate_load_request so an
  untrusted companion repo is refused before the arbiter handoff.
- unload() now drains _generate_lock before _teardown_state so a
  cancelled clip actually exits the denoise loop before the VRAM is
  reported free.
- load_pipeline re-checks the load token after the generate-lock barrier
  and raises if the load was superseded while waiting.
- Pre-commit global mutations (backend flags, gguf compile installs) are
  registered per load token and rolled back in _run_load's error path
  via _rollback_precommit_globals, so a failed load no longer leaks
  process-wide state.
- fp32 memory estimates now apply a 2x dtype scale on non-CPU devices
  for pipeline, single-file and companion sizes (bf16 tables assume
  2 bytes/param); GGUF quant estimates stay unscaled.

Tests: GGUF-repo-as-pipeline rejection, _detect_load_family fallback and
override semantics; fake route backend accepts base_repo. 66 passed
across test_video_backend, test_video_routes, test_video_families,
test_video_gallery.
2026-07-05 07:55:26 +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
cab60395c4 Merge branch 'diffusion-more-families' into video-inference 2026-07-05 05:36:02 +00:00
Daniel Han
ca8365da72 Merge branch 'diffusion-auto-badges' into diffusion-more-families 2026-07-05 05:36:01 +00:00
Daniel Han
49f1e352f2 Merge branch 'diffusion-auto-install' into diffusion-auto-badges 2026-07-05 05:36:00 +00:00
Daniel Han
ff22c434b4 Merge branch 'diffusion-fp16-accum' into diffusion-auto-install 2026-07-05 05:35:59 +00:00
Daniel Han
10ba804db7 Merge branch 'diffusion-auto-policy' into diffusion-fp16-accum 2026-07-05 05:35:58 +00:00
Daniel Han
a61e56b975 Merge branch 'diffusion-train-perf2' into diffusion-auto-policy 2026-07-05 05:35:56 +00:00
Daniel Han
6a9db8017b Merge branch 'diffusion-krea2' into diffusion-train-perf2 2026-07-05 05:35:55 +00:00
Daniel Han
e0786a98be Merge branch 'diffusion-train-tab-2' into diffusion-krea2 2026-07-05 05:35:54 +00:00
Daniel Han
1978b2a844 Merge branch 'diffusion-train-precision' into diffusion-train-tab-2 2026-07-05 05:35:53 +00:00
Daniel Han
1919491665 Merge branch 'diffusion-train-perf' into diffusion-train-precision 2026-07-05 05:35:52 +00:00
Daniel Han
dfe15c8141 Merge branch 'image-generation' into diffusion-train-perf 2026-07-05 05:35:50 +00:00
Daniel Han
fc35c40c18 Return 404 for malformed diffusion run records in the detail route
The run detail route built DiffusionTrainingRunDetail(**rec) unguarded, so a
valid-JSON-but-wrong-shape record (hand-edited or an older schema) would 500
instead of reading as absent. Catch ValidationError and 404, matching how the
list route skips malformed records.
2026-07-05 05:34:18 +00:00
Daniel Han
14f4e7ef7c Keep standalone chat templates in the scoped video download
tokenizer/chat_template.jinja ships as its own file in the LTX-2 and
HunyuanVideo-1.5 repos and apply_chat_template reads it at generation
time, so a scoped snapshot without it loads fine and then crashes the
first generation.
2026-07-05 05:32:24 +00:00
Daniel Han
7a05d8655b Stream every DiT through group offload, not just the primary transformer
A dual-DiT pipeline (Ideogram 4's unconditional tower) placed its second
denoiser resident under the group tier, which defeats the tier since the
pair rarely fits where one alone did not. Stream transformer_2 and
unconditional_transformer alongside the transformer and keep only the
smaller companions resident.
2026-07-05 05:30:58 +00:00