[Bugfix] t2i online fix cache configuration failure and errors in /v1/images/generation endpoint. (#499)

Signed-off-by: David Chen <530634352@qq.com>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
WeiQing ChenandHongsheng Liu authored and GitHub committed 2025-12-30 16:50:30 +08:00
1 parent 59ae174bba
commit 1753a878e0
11 files changed
+296 -50

No files matched your search

+7 -3
View File
@@ -44,6 +44,7 @@ class GPUWorker:
self.rank = rank
self.od_config = od_config
self.pipeline = None
self.device = None
self.init_device_and_model()
@@ -58,8 +59,8 @@ class GPUWorker:
os.environ["RANK"] = str(rank)
os.environ["WORLD_SIZE"] = str(world_size)
device = torch.device(f"cuda:{rank}")
torch.cuda.set_device(device)
self.device = torch.device(f"cuda:{rank}")
torch.cuda.set_device(self.device)
# hack
vllm_config = VllmConfig()
@@ -89,7 +90,7 @@ class GPUWorker:
with DeviceMemoryProfiler() as m:
self.pipeline = model_loader.load_model(
od_config=self.od_config,
load_device=f"cuda:{rank}",
load_device=str(self.device),
)
time_after_load = time.perf_counter()
@@ -129,6 +130,9 @@ class GPUWorker:
# TODO: dealing with first req for now
req = reqs[0]
if req.generator is None and req.seed is not None:
req.generator = torch.Generator(device=self.device).manual_seed(req.seed)
# Refresh cache context if needed
if self.cache_backend is not None and self.cache_backend.is_enabled():
self.cache_backend.refresh(self.pipeline, req.num_inference_steps)