From 323b4aaf5a65b938065c3114fd44b5e55b1af8ac Mon Sep 17 00:00:00 2001 From: Jaret Burkett Date: Mon, 17 Nov 2025 18:04:00 +0000 Subject: [PATCH 1/4] Do not copy pin memory if it fails, just move --- toolkit/memory_management/manager_modules.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/toolkit/memory_management/manager_modules.py b/toolkit/memory_management/manager_modules.py index 7dac4b59..1b158e3e 100644 --- a/toolkit/memory_management/manager_modules.py +++ b/toolkit/memory_management/manager_modules.py @@ -99,7 +99,10 @@ def _ensure_cpu_pinned(t: Optional[torch.Tensor]) -> Optional[torch.Tensor]: if t is None: return None if t.device.type != "cpu": - t = t.to("cpu", copy=True) + try: + t = t.to("cpu", copy=True) + except Exception: + t = t.to("cpu") # Don't attempt to pin quantized tensors; many backends don't support it if _is_quantized_tensor(t): return t From cd607c49022a5032b20fb1ef85433040a3f03e8b Mon Sep 17 00:00:00 2001 From: Jaret Burkett Date: Wed, 19 Nov 2025 08:28:48 -0700 Subject: [PATCH 2/4] Fix a bug that can happen if you remove a gpu from your machine. --- ui/src/components/JobsTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/components/JobsTable.tsx b/ui/src/components/JobsTable.tsx index ae3c9eb5..315ecd63 100644 --- a/ui/src/components/JobsTable.tsx +++ b/ui/src/components/JobsTable.tsx @@ -102,7 +102,7 @@ export default function JobsTable({ onlyActive = false }: JobsTableProps) { jd['Idle'] = { name: 'Idle', jobs: [] }; jobs.forEach(job => { const gpu = gpuList.find(gpu => job.gpu_ids?.split(',').includes(gpu.index.toString())) as GpuInfo; - const key = `${gpu.index}`; + const key = `${gpu?.index || '0'}`; if (['queued', 'running', 'stopping'].includes(job.status) && key in jd) { jd[key].jobs.push(job); } else { From 26e4b71b57ea8ed8a83cf0cbdc7913d3075d8f81 Mon Sep 17 00:00:00 2001 From: Jaret Burkett Date: Wed, 19 Nov 2025 08:45:05 -0700 Subject: [PATCH 3/4] Fix issue with parsing image info for sample info on some windows machines. --- ui/src/components/SampleImageViewer.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ui/src/components/SampleImageViewer.tsx b/ui/src/components/SampleImageViewer.tsx index b5fa1b01..3e0613d8 100644 --- a/ui/src/components/SampleImageViewer.tsx +++ b/ui/src/components/SampleImageViewer.tsx @@ -46,10 +46,21 @@ export default function SampleImageViewer({ const onCancel = useCallback(() => setIsOpen(false), []); const imgInfo = useMemo(() => { + // handle windows C:\\Apps\\AI-Toolkit\\AI-Toolkit\\output\\LoRA-Name\\samples\\1763563000704__000004000_0.jpg const ii = { filename: '', step: 0, promptIdx: 0 }; if (imgPath) { - const filename = imgPath.split('/').pop(); - if (!filename) return ii; + // handle windows + let filename: string | null = null; + if (imgPath.includes('\\')) { + const parts = imgPath.split('\\'); + filename = parts[parts.length - 1]; + } else { + filename = imgPath.split('/').pop() || null; + } + if (!filename) { + console.error('Filename could not be determined from imgPath:', imgPath); + return ii; + } ii.filename = filename; const parts = filename .split('.')[0] @@ -58,6 +69,8 @@ export default function SampleImageViewer({ if (parts.length === 3) { ii.step = parseInt(parts[1]); ii.promptIdx = parseInt(parts[2]); + } else { + console.error('Unexpected filename format for sample image:', filename); } } return ii; From 50e5d995459832009c1ed49c810e57a457e82235 Mon Sep 17 00:00:00 2001 From: Jaret Burkett Date: Wed, 19 Nov 2025 09:01:00 -0700 Subject: [PATCH 4/4] Fix issue where text encoder was not fully unloaded in some instances --- toolkit/unloader.py | 1 + 1 file changed, 1 insertion(+) diff --git a/toolkit/unloader.py b/toolkit/unloader.py index 09ce1ba9..31f75e17 100644 --- a/toolkit/unloader.py +++ b/toolkit/unloader.py @@ -47,6 +47,7 @@ def unload_text_encoder(model: "BaseModel"): if hasattr(pipe, "text_encoder"): te = FakeTextEncoder(device=model.device_torch, dtype=model.torch_dtype) text_encoder_list.append(te) + pipe.text_encoder.to('cpu') pipe.text_encoder = te i = 2