Skip to content

Commit c9c8485

Browse files
committed
Merge branch 'release_candidate'
2 parents 68f336b + 31f2be3 commit c9c8485

5 files changed

Lines changed: 19 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 1.5.2
2+
3+
### Bug Fixes:
4+
* fix memory leak when generation fails
5+
* update doggettx cross attention optimization to not use an unreasonable amount of memory in some edge cases -- suggestion by MorkTheOrk
6+
7+
18
## 1.5.1
29

310
### Minor:

modules/call_queue.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import threading
44
import time
55

6-
from modules import shared, progress, errors
6+
from modules import shared, progress, errors, devices
77

88
queue_lock = threading.Lock()
99

@@ -75,6 +75,8 @@ def f(*args, extra_outputs_array=extra_outputs, **kwargs):
7575
error_message = f'{type(e).__name__}: {e}'
7676
res = extra_outputs_array + [f"<div class='error'>{html.escape(error_message)}</div>"]
7777

78+
devices.torch_gc()
79+
7880
shared.state.skipped = False
7981
shared.state.interrupted = False
8082
shared.state.job_count = 0

modules/errors.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def record_exception():
1414
if exception_records and exception_records[-1] == e:
1515
return
1616

17-
exception_records.append((e, tb))
17+
from modules import sysinfo
18+
exception_records.append(sysinfo.format_exception(e, tb))
1819

1920
if len(exception_records) > 5:
2021
exception_records.pop(0)

modules/sd_hijack_optimizations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ def split_cross_attention_forward(self, x, context=None, mask=None, **kwargs):
256256
raise RuntimeError(f'Not enough memory, use lower resolution (max approx. {max_res}x{max_res}). '
257257
f'Need: {mem_required / 64 / gb:0.1f}GB free, Have:{mem_free_total / gb:0.1f}GB free')
258258

259-
slice_size = q.shape[1] // steps if (q.shape[1] % steps) == 0 else q.shape[1]
259+
slice_size = q.shape[1] // steps
260260
for i in range(0, q.shape[1], slice_size):
261-
end = i + slice_size
261+
end = min(i + slice_size, q.shape[1])
262262
s1 = einsum('b i d, b j d -> b i j', q[:, i:end], k)
263263

264264
s2 = s1.softmax(dim=-1, dtype=q.dtype)

modules/sysinfo.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,15 @@ def format_traceback(tb):
109109
return [[f"{x.filename}, line {x.lineno}, {x.name}", x.line] for x in traceback.extract_tb(tb)]
110110

111111

112+
def format_exception(e, tb):
113+
return {"exception": str(e), "traceback": format_traceback(tb)}
114+
115+
112116
def get_exceptions():
113117
try:
114118
from modules import errors
115119

116-
return [{"exception": str(e), "traceback": format_traceback(tb)} for e, tb in reversed(errors.exception_records)]
120+
return list(reversed(errors.exception_records))
117121
except Exception as e:
118122
return str(e)
119123

0 commit comments

Comments
 (0)