Jit2024 commited on
Commit
2ec5462
·
1 Parent(s): 7fee2f2

Fix ZeroGPU RuntimeError timeout and 89% hang by adding FP8 quantization. Reduce VRAM footprint to <29GB to prevent OOM on standard 48GB L40S nodes, and restore root .to(cuda) for rapid initialization.

Browse files
Files changed (1) hide show
  1. app.py +24 -16
app.py CHANGED
@@ -120,6 +120,18 @@ pipe = QwenImageEditPlusPipeline.from_pretrained(
120
  ignore_patterns=["transformer/*"]
121
  )
122
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  # Load next-scene LoRA for cinematic progression
124
  # Note: This LoRA was trained on 2509, may need testing with 2511/v18
125
  # TODO: Re-enable after testing base 2511/v18 works correctly
@@ -238,22 +250,18 @@ def infer(
238
  print(f"Negative Prompt: '{negative_prompt}'")
239
  print(f"Seed: {seed}, Steps: {num_inference_steps}, Guidance: {true_guidance_scale}, Size: {width}x{height}")
240
 
241
- # Generate the image (move to GPU dynamically to avoid packing timeout at startup)
242
- try:
243
- pipe.to(device)
244
- images_pil = pipe(
245
- image=pil_images if len(pil_images) > 0 else None,
246
- prompt=prompt,
247
- height=height,
248
- width=width,
249
- negative_prompt=negative_prompt,
250
- num_inference_steps=num_inference_steps,
251
- generator=generator,
252
- true_cfg_scale=true_guidance_scale,
253
- num_images_per_prompt=num_images_per_prompt,
254
- ).images
255
- finally:
256
- pipe.to("cpu")
257
 
258
  # Anonymous diagnostics — fire-and-forget, must not block or fail generation.
259
  try:
 
120
  ignore_patterns=["transformer/*"]
121
  )
122
 
123
+ # Apply FP8 quantization to halve the VRAM footprint (57GB -> 29GB)
124
+ # to prevent ZeroGPU OOM (89% hang) on standard 48GB L40S nodes.
125
+ from torchao.quantization import quantize_, Float8DynamicActivationFloat8WeightConfig
126
+ quantize_(pipe.transformer, Float8DynamicActivationFloat8WeightConfig())
127
+ if hasattr(pipe, "text_encoder") and pipe.text_encoder is not None:
128
+ try:
129
+ quantize_(pipe.text_encoder, Float8DynamicActivationFloat8WeightConfig())
130
+ except Exception:
131
+ pass # Text encoder might not support this specific FP8 quant scheme
132
+
133
+ pipe = pipe.to(device)
134
+
135
  # Load next-scene LoRA for cinematic progression
136
  # Note: This LoRA was trained on 2509, may need testing with 2511/v18
137
  # TODO: Re-enable after testing base 2511/v18 works correctly
 
250
  print(f"Negative Prompt: '{negative_prompt}'")
251
  print(f"Seed: {seed}, Steps: {num_inference_steps}, Guidance: {true_guidance_scale}, Size: {width}x{height}")
252
 
253
+ # Generate the image
254
+ images_pil = pipe(
255
+ image=pil_images if len(pil_images) > 0 else None,
256
+ prompt=prompt,
257
+ height=height,
258
+ width=width,
259
+ negative_prompt=negative_prompt,
260
+ num_inference_steps=num_inference_steps,
261
+ generator=generator,
262
+ true_cfg_scale=true_guidance_scale,
263
+ num_images_per_prompt=num_images_per_prompt,
264
+ ).images
 
 
 
 
265
 
266
  # Anonymous diagnostics — fire-and-forget, must not block or fail generation.
267
  try: