Views
No views yet
optimum-quanto (qint8) for quantization and includes a custom Flux2KleinKVOffloadPipeline that handles sequential CPU↔GPU model offloading to stay within memory limits while preserving near-original quality.bitsandbytes does not support .to('cpu'). Not usable in this case.1#!/usr/bin/env python3
2import time
3from contextlib import contextmanager
4from PIL import Image
5from pipeline_flux2_klein_kv_offload import Flux2KleinKVOffloadPipeline
6
7@contextmanager
8def timer(label: str):
9 print(label, end='... ')
10 t0 = time.perf_counter()
11 yield
12 elapsed = time.perf_counter() - t0
13 print(str(int(elapsed)) + "s")
14
15with timer('loading'):
16 pipe = Flux2KleinKVOffloadPipeline.from_quanto("./")
17
18img = Image.open("trees.jpg").convert("RGB")
19test_prompts = [
20 "make this forest autumn",
21 "make it winter",
22 "make a real photo"
23]
24
25for prompt in test_prompts:
26 with timer(prompt):
27 fname = prompt.split()[-1] + ".png"
28 pipe(image=img, prompt=prompt, height=img.height, width=img.width).save(fname)flux.2_klein_9B_kv_quanto8$ python test.py
loading... 119s
make this forest autumn... 5s
make it winter... 5s
make a real photo... 5s


