Commit History
-
Sync develop into main (#52)
Unverified signature* Set up develop/main two-stage deploy: retarget dev-en to develop, add prod-en workflow develop -> dev-en Space (staging), main -> prod-en Space (release). See #26 for the release flow design. * Centralize print_*() logging functions in logging_utils.py (#29) Consolidates the named print_*() functions that #23 extracted in model_loading.py, inference.py, examples_ui.py, image_codec.py, and the qwenimage attention/pipeline modules into logging_utils.py, alongside the print_log_*() functions already there, so all logging lives in one file instead of being scattered per-module. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> * Rename dev-en's repo variable from HF_SPACE_ID to HF_SPACE_ID_DEV_EN (#30) Matches the <ENV>_<LANG> naming already used by HF_SPACE_ID_PROD_EN and HF_SPACE_ID_PROD_JA — the bare HF_SPACE_ID for dev-en was the odd one out. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> * Extract _InferTimer into a generic Timer in timing.py (#32) print_timi…8c202fb
-
Introduce a two-stage develop/main deploy flow (#27)
Unverified signature* Set up develop/main two-stage deploy: retarget dev-en to develop, add prod-en workflow develop -> dev-en Space (staging), main -> prod-en Space (release). See #26 for the release flow design. * Centralize print_*() logging functions in logging_utils.py (#29) Consolidates the named print_*() functions that #23 extracted in model_loading.py, inference.py, examples_ui.py, image_codec.py, and the qwenimage attention/pipeline modules into logging_utils.py, alongside the print_log_*() functions already there, so all logging lives in one file instead of being scattered per-module. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> * Rename dev-en's repo variable from HF_SPACE_ID to HF_SPACE_ID_DEV_EN (#30) Matches the <ENV>_<LANG> naming already used by HF_SPACE_ID_PROD_EN and HF_SPACE_ID_PROD_JA — the bare HF_SPACE_ID for dev-en was the odd one out. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> * Extract _InferTimer into a generic Timer in timing.py (#32) print_timi…6e3ec3e
-
Extract print() calls into named print_*() functions (#23)
Unverified signatureGroups the scattered logging statements across model_loading.py, inference.py, logging_utils.py, image_codec.py, examples_ui.py, and the qwenimage attention/pipeline modules into one dedicated function per message, making each log line easy to find, name, and reuse. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>98269eb -
Clean up experimental logging from the module-level .to('cuda') investigation (#25)
Unverified signatureRemoves zerogpu_timing_patch.py (pack_tensors/pack_to_cuda timing monkeypatch) and the wall-clock dispatch/entry timestamps added to measure ZeroGPU's pack/unpack cost — that question is answered (see PR #21/#24 discussion) and didn't need to keep shipping in production logs. Also drops _log_pipe_placement, whose only purpose was confirming the module-level load landed as expected during that investigation. Rewords the now-stale "EXPERIMENTAL" comments left over from before this became the shipped design. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>9598a80 -
Use CPU-only torch/torchvision wheels for the mypy CI job (#22)
Unverified signatureThe typecheck workflow's `uv sync --group dev` was resolving the default PyPI torch wheel, which pulls in every nvidia-* CUDA runtime package (cublas, cudnn, cufft, cusolver, nccl, ...) plus triton — over 2GB of downloads just to run a static type check that never touches a GPU. pyproject.toml/uv.lock aren't used by the actual Space deploy (sdk: gradio builds from requirements.txt directly — see deploy-dev-en.yml), so pinning torch/torchvision to the CPU wheel index here has no effect on the real GPU runtime. mypy and pytest both still pass against the CPU build, since type stubs and CPU-testable logic don't differ from the CUDA build. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>6d048df -
Fix OOM: stop double-allocating text_encoder (bf16 + int8) on GPU (#24)
Unverified signatureThe module-level .to('cuda') pattern from #21 moved the whole pipeline (including the bf16 text_encoder) to CUDA at startup via ZeroGPU's emulation. But inference.py's _ensure_int8_text_encoder replaces pipe.text_encoder with an int8 copy on nearly every request — and the old bf16 copy's ~15.4GB was never actually freed, because ZeroGPU's own `tensor_packs` bookkeeping (spaces/zero/torch/patching.py) holds a permanent reference to every module-level-loaded tensor for the life of the (forked) worker, independent of what our own code does with `pipe.text_encoder` afterwards. Confirmed via a live OOM on FireRed-Dev: alloc=43.46GB (~19GB transformer + ~15.4GB stranded bf16 text_encoder + ~8.75GB int8 text_encoder) against a 47.4GB MIG slice, crashing during VAE decode. Fix: don't move text_encoder to CUDA at module level at all — leave it CPU-resident (model_loading.py), so _ensure_int8_text_encoder's swap never has a GPU-resident bf16 copy to strand in the first place. Added _ensure_bf16…5f1d4d1 -
Experiment: load transformer/pipeline via module-level .to('cuda') (#21)
Unverified signatureRe-validates HF's documented ZeroGPU pattern (models placed on 'cuda' at root module level, relying on ZeroGPU's CUDA-emulation + torch.move() transfer) against the current spaces==0.51.1, per the disk-pack/unpack regression investigated in 6c0477d and left open in issue #1. - model_loading.py: transformer/pipeline now load straight onto `device` instead of CPU-then-manual-.to(device); spaces imported first per HF's "import spaces before any CUDA-touching code" requirement. - zerogpu_timing_patch.py: wraps spaces.zero.torch.patching.pack_tensors/ pack_to_cuda to print how long the CPU->disk pack (startup-only) and disk->CUDA unpack (per fresh worker) actually take. - inference.py: replaces the manual _place_pipe_on_device/_FAST_PATH_MIN_GB OOM-fallback dance with a placement-confirmation log line, since ZeroGPU's own worker_init now does that transfer before this function body runs. Adds wall-clock dispatch/entry timestamps to bound the gap from the caller's side too. …cf338bd -
Enforce strict typing on Python code with mypy (#20)
Unverified signature* Enforce strict typing on Python code with mypy Adds mypy --strict configuration scoped to the project's own code (app.py, inference.py, model_loading.py, logging_utils.py, dimensions.py, mode.py, image_codec.py, examples_ui.py, tests/), excluding qwenimage/ since it's vendored from HuggingFace diffusers rather than code we own. Fully annotates the in-scope modules and tests, and enforces the check going forward via a GitHub Actions workflow and a local pre-commit hook. Fixes #19 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Move mypy's scoped file list into pyproject.toml CI and pre-commit invoked mypy with the same long, repeated list of files on the command line. mypy already supports a `files` setting in [tool.mypy], so both call sites now just run `uv run mypy` with no args. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>698eb37 -
Split app.py into cohesive modules (#17)
Unverified signatureapp.py mixed five unrelated concerns in one 733-line file: env/model startup, base64<->PIL image codec, example/suggestion HTML building, per-request inference orchestration, and Gradio UI wiring. Split each into its own module (image_codec.py, examples_ui.py, model_loading.py, inference.py) so app.py is left as thin UI assembly + entrypoint. No behavior changes: every function/class from the original app.py is preserved verbatim in its new home (verified via a def/class-name diff), and the existing test suite still passes unchanged. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>63be854 -
Merge pull request #18 from some1galaxy/ci/deploy-dev-en-on-merge
Unverified signatureAdd GitHub Actions workflow to deploy to dev-en Space on merge to main8fbbbcf -
Drop hardcoded Space id from the error message
The workflow is meant to be Space-agnostic (target comes entirely from the HF_SPACE_ID variable) — the error message showing a specific real Space as an example undercut that. Show the <owner>/<space-name> format instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>acee921 -
Fail loudly instead of defaulting HF_SPACE_ID
A silent default means a repo that forgets to set HF_SPACE_ID would deploy to someone-in-the-world/FireRed-Dev without anyone intending that — better to error out with a clear message than guess the target. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>86beb65 -
Make the target HF Space configurable via a repo variable
HF_SPACE_ID is a repo variable (not secret) since the Space path isn't sensitive — it's already public in this repo's history and on the Space itself. Falls back to someone-in-the-world/FireRed-Dev when unset, so the workflow keeps working without any extra setup. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>bc4d94a -
Add GitHub Actions workflow to deploy to dev-en Space on merge to main
Pushes the checked-out commit to the someone-in-the-world/FireRed-Dev HF Space's main branch whenever a PR is merged (i.e. main gets a new push), using an HF_TOKEN repo secret. No --force: a non-fast-forward push means the Space diverged from GitHub and needs manual reconciliation rather than a silent overwrite. Requires an HF_TOKEN secret (HF write token for the dev-en Space) to be added under Settings > Secrets and variables > Actions before this can run successfully. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>a1ed2cd
-
Add copy-prompt button and improve mobile touch targets/layout
Fixes the per-thumbnail remove button being invisible on touch devices (it only appeared on :hover), and tightens spacing/tap-target sizing for the toolbar, sliders, and buttons below 640px. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>dbd99af
-
Convert example images 2.jpg, 3.jpeg, 4.jpg, 5.jpg to actual Git LFS objects
These files matched the examples/*.jpg and examples/*.jpeg LFS patterns in .gitattributes but were committed as raw binaries instead of LFS pointers, unlike the other example images. This left them permanently showing as modified in git status/diff. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>6482da8 -
Add notice that the Space may end without prior notice
Clarifies to users that this Space may be modified, suspended, or discontinued at any time, alongside the existing usage notices. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>3fea774
-
Reduce default GPU duration for High Detail mode from 60s to 30s
Inference has gotten faster, so the prior 60s default now overshoots actual runtime, same reasoning that dropped Fast mode's default to 15s. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>106074d -
Pad declared ZeroGPU duration with a cold-start buffer
Every @spaces.GPU call runs in a fresh worker, so the int8 text_encoder reload (up to ~30s) and full pipe-to-cuda move (up to ~14s) are paid on every request. When the UI's gpu_duration slider only budgeted for the user's expected diffusion time, ZeroGPU would kill the call mid-run with "GPU task aborted" once the declared duration was exceeded (issue #7). Since ZeroGPU bills by actual usage rather than the declared duration, padding it costs nothing but queue priority. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>8ec79ca -
Sync visible GPU duration slider default to Fast mode's 15s
templates/app.html still hardcoded the visible slider's initial value at 30, and mode_toggle.js only applied the mode's duration on a mode-button click, not on page load, so the UI kept showing 30s after 8a3b1b0 dropped the actual default to 15s. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>88ef5d4
-
Fix step-done log ordering vs text_encoder offload/pre-VAE-decode
The step-done print used a timestamp captured at callback entry but printed after the offload/pre-VAE-decode logging (which use fresh perf_counter() calls), making log lines appear out of chronological order on the final step. Print step-done immediately after computing it instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1a04070 -
Reduce default GPU duration for Fast mode from 30s to 15s
Fast mode uses lower resolution, fewer steps, and no text encoder offload, so 30s of reserved ZeroGPU time was more than actually needed. Closes #15 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>8a3b1b0 -
Add VAE decode logging: pre-decode mem snapshot, tiling prediction, peak reset
Adds three log points to support issue #6 investigation: - [startup] VAE tile threshold confirmation after enable_tiling() - [infer] whether tiling will activate for this image size - [infer] pre-VAE-decode memory snapshot + reset_peak_memory_stats() so the existing "VAE decode + postprocess done" peak reflects only VAE decode Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>a1fde2a -
Raise VAE tile threshold to HIGH_DETAIL.max_dim (2048px) to skip tiling
Tiling only activates when image size exceeds the threshold; at 768px the threshold was always triggered for high_detail outputs (up to 2048px), adding tile-split and blend overhead. FAST mode (<=768px) is unaffected. This is an investigation step to measure peak memory and decode speed with tiling disabled on high_detail — guided by issue #6. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>2f7a843 -
Bump bitsandbytes to 0.49.2 for CUDA 13.0 support
0.47.0 has no precompiled binary for CUDA 13.0 (only up to 12.9), so it failed to load its native library at import time on this Space's cu130 torch build, and the int8 text_encoder load fell back to bf16 (gracefully, per app.py's own fallback). CUDA 13.0 binaries were added starting in bitsandbytes 0.48.0. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>acdbece -
Load text_encoder as int8 (bitsandbytes) when TEXT_ENCODER_INT8_REPO is set
bitsandbytes 8bit models can't be moved between devices with `.to()` (unconditional in transformers, unlike the version-gated allowance for 4bit), so this can't reuse the transformer's cpu-load-then-.to(device) pattern. Instead the quantized text_encoder is loaded directly onto the target CUDA device on first inference call per worker, guarded so it only happens once. Also fixes a crash: high_detail mode's pre-decode text_encoder.to("cpu") offload is skipped once text_encoder is int8, since .to() would raise for it regardless of target device. Repo id comes from the TEXT_ENCODER_INT8_REPO secret; falls back to the existing bf16 text_encoder when unset. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>ae1d43b -
Skip text_encoder CPU offload in fast mode; type mode as an enum
Logged phase timing showed the text_encoder-to-CPU offload before VAE decode costs ~9.7s, while decode itself takes ~113ms. That offload was freeing memory decode never needed at fast mode's small resolution (measured peak stayed well under the MIG slice's headroom) — it exists to prevent OOM at high-detail's much larger 2048px decode, so it's kept there and only skipped for fast mode. Replaced the raw "fast"/"high_detail" string comparisons scattered across dimensions.py and app.py with a Mode enum (mode.py) that owns both behaviors (max_dim, offloads_text_encoder_before_decode) as properties on the variant. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>39867e3 -
Add per-phase timing to pipeline call and text_encoder offload
The existing vae_decode timing bucket (last_step -> pipe_end) lumps together the text_encoder CPU offload, latent unpacking, actual VAE decode, and postprocessing, making it look like decode itself is slow. Split each phase out with its own timestamped log line so the real cost can be seen directly instead of inferred.f30b43a -
Speed up fast mode: lower resolution cap, skip needless VAE tiling, fewer steps
Fast mode's 768px (was 1024px) output now stays under the VAE's tiling threshold, so it decodes in a single pass instead of a tiled decode with blend overhead that was only ever needed for high-detail's 2048px case. Also gives fast mode a lower default step count (3 vs 4), following the existing mode-scoped-default pattern already used for GPU duration. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>9fcf338
-
Log exception type/repr and traceback in infer() error path
Diagnosing "Could not parse server response. Syntax error '<'" reports on High-Detail mode: the browser is getting HTML instead of JSON back from the SSE queue, which points to Gradio failing to serialize the caught exception rather than the underlying error itself (a recent case was a ZeroGPU quota rejection, confirmed via the firered-turbo-logs dataset, whose exact exception type/attrs aren't visible from str(e) alone). This logs the concrete type/module and full traceback so the next occurrence is easier to pin down. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1f6b940 -
Correct data retention language to reflect automatic pruning
Privacy notice previously stated data was kept "until manually deleted" with no automatic deletion schedule, which contradicts the LogUploader's auto-pruning behaviour (oldest entries dropped once the configured file cap is reached). Updated both the notice bullet and Privacy Policy section to accurately describe the automatic retention limit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>17bf2e0
-
Replace vllm-flash-attn3 kernel with native SDPA cuDNN backend; wire up attn processor
The external vllm-flash-attn3 kernel had no compiled binary for compute capability 12.0 (Blackwell), crashing at construction. Switch to sdpa_kernel(SDPBackend.CUDNN_ATTENTION) which ships inside PyTorch/CUDA itself. Also wire up set_attn_processor() in app.py — previously the class was imported but never applied, leaving the transformer on its default processor the whole time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>e4b15be -
Free text encoder before VAE decode and enable VAE tiling to fix OOM
Fast-path inference keeps the full ~35GB pipeline resident on the 47.4GB MIG slice, leaving too little headroom for the VAE decoder's fp32-upcast memory spike on large (2048px) outputs. Offload the ~15GB text encoder to CPU once the last denoising step finishes (skipped when accelerate hooks already own placement), and bound decode memory with tiling regardless of output size. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>0a2678b -
Patch RMSNorm for fp8-resident weights; fix crash in prior fp8 commit
8db56cb kept the transformer's weights fp8-resident (instead of upcasting to bf16 at load) to fix the memory OOM that was forcing this Space onto the slow enable_model_cpu_offload path. It patched nn.Linear to upcast its weight just-in-time for the matmul, but this model also uses RMSNorm extensively (attn.norm_q/norm_k/norm_added_q/norm_added_k in every transformer block, plus self.txt_norm) with real learnable weights — confirmed via the checkpoint's safetensors headers, which show 100% of tensors across all 3 shards as F8_E4M3, including norm gains and biases, no mixed precision. diffusers 0.39.0's RMSNorm.forward only upcasts its weight for float16/bfloat16, not float8. Left unpatched, `hidden_states * self.weight` multiplies a bf16 activation by an fp8 weight directly, which PyTorch does not support via type promotion. Verified this reproduces exactly: RuntimeError: Promotion for Float8 Types is not supported, attempted to promote Float and Float8_e4m3fn This adds _fp8_upca…c0f3a61 -
Keep transformer weights fp8-resident instead of upcasting at load
The Rapid-AIO-V23 checkpoint already ships natively in fp8_e4m3fn (~19GB for 20B params), but from_pretrained's torch_dtype=bf16 was casting every tensor up to bf16 at load time (~38GB), which is why the pipeline (~35-40GB transformer + ~14GB text encoder) never comfortably fit this Space's 47GB MIG slice and needed the slow enable_model_cpu_offload fallback (_FAST_PATH_MIN_GB=60, gating out the 47GB slice entirely). This keeps torch_dtype=torch.float8_e4m3fn on the transformer load (a diffusers-supported path — see modeling_utils.py's explicit float8 handling) so weights stay fp8 in memory, and patches every fp8-resident nn.Linear to upcast its own weight to the input's dtype just before the matmul. nn.Linear has no fp8 GEMM kernel on this GPU, so this is not a compute speedup — it's the same bf16 upcast the old code did, just deferred from load-time (all layers at once) to call-time (one layer's weight transiently bf16 at a time), so resident GPU memory drops from ~38GB to ~19GB for…8db56cb -
Refactor _infer_gpu into single-responsibility helper functions
Split the monolithic function into _log_infer_start, _log_gpu_properties, _place_pipe_on_device, _instrument_first_touch, _make_step_callback, and _log_infer_error. _infer_gpu itself is now just the orchestration of these steps, with no behavior change.d9d1b60 -
Fix misleading "includes compile" log label; add first-touch instrumentation
No torch.compile exists in this codebase — the step-1 slowdown every inference is cold-start from enable_model_cpu_offload re-running on every fresh ZeroGPU worker (slice too small for the full-GPU fast path). Added self-removing forward-pre-hooks on text_encoder/transformer/vae to break that cost down by module in the logs.be0f671 -
Pin accelerate and peft to release versions instead of git HEAD
Both were installed via unpinned git+https://..., so every fresh build silently pulled whatever was on GitHub main that day — the same class of drift that caused today's diffusers/huggingface-hub conflict. This Space went 5 weeks without a rebuild before today's AWS-outage-forced restart pulled a month of accumulated upstream changes at once; pinning accelerate/peft closes off that same failure mode for accelerate/peft specifically. Pinned to the latest released versions (accelerate==1.14.0, which the unpinned build had already drifted past to 1.15.0.dev0; peft==0.19.1, past 0.19.2.dev0). Verified via a real pip dry-run resolve alongside diffusers==0.39.0 and transformers==4.57.1 that this combination resolves cleanly with no conflicts. Neither package is imported directly anywhere in this repo (they're consumed internally by diffusers' ModelMixin/PeftAdapterMixin/QwenImageLoraLoaderMixin), and diffusers 0.39.0 only requires accelerate>=0.31.0 and peft>=0.17.0, so both releases are co…6d80426 -
Revert NF4 quantization: this checkpoint's weights are stored fp8-native
Space startup crashed: RuntimeError: Blockwise 4bit quantization only supports 16/32-bit floats, but got torch.float8_e4m3fn. The transformer safetensors index reports ~19GB total for a 20B-param model (~1 byte/param), confirming prithivMLmods/Qwen-Image-Edit-Rapid- AIO-V23 already ships as fp8, not bf16. bitsandbytes' 4-bit quantizer requires a 16/32-bit source tensor to quantize from and cannot operate on fp8-stored weights directly — and since nothing in this vendored qwenimage code has fp8 compute kernels, the weights still need to be upcast to bf16 for the forward pass to work at all, which is exactly what the pre-quantization code already did. So NF4-on-load isn't a drop-in fix here; doing it properly would mean manually materializing the model in bf16 first and then hand-converting nn.Linear modules to Linear4bit, which needs real GPU verification to get right. Reverting app.py to the pre-quantization state (926cf86) to restore a working Space. The requirements.txt fix pinning…1093d66 -
Pin diffusers to 0.39.0 release to fix hub dependency conflict
The Space build failed: diffusers' git HEAD (0.40.0.dev0) recently raised its huggingface-hub floor to >=1.23.0, which has zero overlap with transformers==4.57.1's huggingface-hub<1.0 ceiling — pip's resolver had no valid huggingface-hub version to pick. This was a latent conflict from tracking diffusers' unpinned main branch, not something introduced by the last commit's bitsandbytes addition. Verified against a real pip resolve that every diffusers symbol this app actually imports (AttentionMixin, attention_dispatch, CacheMixin, AutoencoderKLQwenImage, etc. — the app vendors its own pipeline/ transformer classes locally) exists in 0.39.0, and that pinning to 0.39.0 resolves cleanly alongside transformers==4.57.1, bitsandbytes, and accelerate/peft still on git HEAD. Preferred over bumping transformers to its new 5.x line, which would risk breaking API changes with no way to test end-to-end here. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>d86fc4a -
Quantize transformer to NF4 via bitsandbytes to fix root-cause OOM
The last several commits kept rearranging when the ~54GB bf16 pipeline (20B transformer + Qwen2.5-VL-7B text encoder) touches the GPU, but that footprint never comfortably fit the 47GB 2g.48gb MIG slice regardless of ordering. NF4-quantizing the transformer (the biggest contributor) drops it from ~40GB to ~11GB, bringing full-pipeline GPU residency down to ~25-30GB with real headroom, so the fast pipe.to(device) path should now succeed every time instead of needing the OOM/cpu-offload dance. bitsandbytes rejects device_map="cpu" for a fresh (non-prequantized) config, so the transformer now loads straight onto cuda:0 at startup (paying the "ZeroGPU disk packing" cost once at boot) instead of the CPU-first pattern still used for the rest of the pipeline. Removed the now-obsolete _FAST_PATH_MIN_GB size gate in _infer_gpu since the quantized pipeline should fit regardless of the exact slice size. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>e809108 -
Gate full-GPU fast path on slice size; it OOMs on this Space's 47GB MIG
Verified on the FireRed-Dev logs: the previous commit's full pipe.to(device) attempt OOM'd on the 2g.48gb (47.4GB) MIG slice this Space actually gets (peaked at 46.82GB), wasting ~40s on the failed attempt + cleanup before falling back to cpu offload — strictly worse than the offload-only baseline. Only attempt the fast path when the allocation has real headroom (>=60GB); otherwise go straight to enable_model_cpu_offload as before. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>926cf86 -
Try full pipeline GPU residency before falling back to cpu offload
Each ZeroGPU call runs in a fresh worker (offload hooks are always unset at entry), so enable_model_cpu_offload bought no cross-call reuse — it just replaced one bulk pipe.to(device) transfer with several slower, hook-managed component transfers, adding ~55s of pure data movement to a ~62s call per the FireRed-Dev logs. Try the fast full-GPU path first and only fall back to offload on an actual CUDA OOM (small MIG slices). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>994c9a0 -
Use sequential CPU offload instead of moving full pipeline to GPU at once
pipe.to(device) staged all ~37GB of weights (transformer + text_encoder + vae) onto GPU simultaneously, which OOM'd on smaller MIG slices (e.g. the 47GB 2g.48gb partition ZeroGPU sometimes hands out). enable_model_cpu_offload uses the pipeline's declared model_cpu_offload_seq to keep only the active component resident on GPU at a time. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>a104380 -
Use cudaMallocAsync allocator to fix MIG GPU CUDACachingAllocator crash
PyTorch's default CUDA Caching Allocator makes NVML memory queries (nvmlDeviceGetMemoryInfo) that fail on MIG GPU instances running as non-root, causing: NVML_SUCCESS == r INTERNAL ASSERT FAILED at CUDACachingAllocator.cpp:1165. The cudaMallocAsync backend avoids these NVML queries entirely. Set via PYTORCH_CUDA_ALLOC_CONF at module level (before any CUDA init) so it is inherited by ZeroGPU's subprocess. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>5ed2ecb -
Add startup environment diagnostics (_log_env)
Prints GPU name/VRAM/compute cap, CUDA version, cuDNN version, system RAM, and key library versions (spaces, diffusers, transformers, gradio, accelerate, peft, torchvision) at startup. Exceptions always print the error message — no silent pass. This would have instantly identified spaces==0.51.0 as the culprit during the July 17 outage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>9acf075 -
Load model on CPU at startup to bypass slow ZeroGPU disk packing
spaces 0.51.0 (released 2026-07-10) switched to disk-based tensor packing (~19s pack + ~19s unpack per inference), breaking the ~7s inference that worked with spaces 0.50.4's pinned-memory approach. HuggingFace force-injects spaces==0.51.0 so pinning requirements.txt doesn't help. Instead: - Load transformer and pipeline on CPU at startup (ZeroGPU has nothing to pack since no tensors are on GPU) - pipe.to(device) inside @spaces.GPU: ~3-4s PCIe transfer vs ~19s disk - pipe.to("cpu") in finally block so ZeroGPU has nothing to repack Also reverts bad spaces==0.50.4 pin (build error) and raises GPU duration defaults to accommodate the explicit model-move time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>6c0477d -
Pin spaces==0.50.4 to restore fast ZeroGPU inference
spaces 0.51.0 (released 2026-07-10) changed tensor packing behavior, causing inference to jump from 3-8s to 22-75s after the Space restarted post-AWS outage on 2026-07-17. Pinning to the version that was working. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>2668631
-
Set default GPU duration for high-detail mode to 40s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>96b6246
-
Set default GPU duration for high-detail mode to 30s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>9f5cd46