Bug
_get_perc_reserved_mem_max() in offload.py crashes when perc_reserved_mem_max arrives as a string instead of a number.
How to reproduce
Start a video generation in Wan2GP
Let it crash for any reason → error_queue.zip gets saved
Restart Wan2GP → queue is reloaded from JSON
JSON deserialization turns 0 into "0" (string)
Next generation attempt crashes immediately
Traceback
File "mmgp/offload.py", line 222, in _get_perc_reserved_mem_max
if perc_reserved_mem_max <= 0:
TypeError: '<=' not supported between instances of 'str' and 'int'
Root cause
Two issues in _get_perc_reserved_mem_max():
The parameter perc_reserved_mem_max is not cast to a numeric type before comparison
os.getenv() always returns a string when the variable is set, causing the same problem on the second comparison
Suggested fix
pythondef _get_perc_reserved_mem_max(perc_reserved_mem_max=0):
perc_reserved_mem_max = float(perc_reserved_mem_max) # fix 1
if perc_reserved_mem_max <= 0:
perc_reserved_mem_max = float(os.getenv("perc_reserved_mem_max", 0)) # fix 2
if perc_reserved_mem_max <= 0:
perc_reserved_mem_max = 0.40 if os.name == 'nt' else 0.5
return perc_reserved_mem_max
Two float() calls, minimal change, fixes both code paths.
Environment
mmgp 3.7.4
Wan2GP (latest)
Windows 10/11
Python 3.10
Bug
_get_perc_reserved_mem_max() in offload.py crashes when perc_reserved_mem_max arrives as a string instead of a number.
How to reproduce
Start a video generation in Wan2GP
Let it crash for any reason → error_queue.zip gets saved
Restart Wan2GP → queue is reloaded from JSON
JSON deserialization turns 0 into "0" (string)
Next generation attempt crashes immediately
Traceback
File "mmgp/offload.py", line 222, in _get_perc_reserved_mem_max
if perc_reserved_mem_max <= 0:
TypeError: '<=' not supported between instances of 'str' and 'int'
Root cause
Two issues in _get_perc_reserved_mem_max():
The parameter perc_reserved_mem_max is not cast to a numeric type before comparison
os.getenv() always returns a string when the variable is set, causing the same problem on the second comparison
Suggested fix
pythondef _get_perc_reserved_mem_max(perc_reserved_mem_max=0):
perc_reserved_mem_max = float(perc_reserved_mem_max) # fix 1
if perc_reserved_mem_max <= 0:
perc_reserved_mem_max = float(os.getenv("perc_reserved_mem_max", 0)) # fix 2
if perc_reserved_mem_max <= 0:
perc_reserved_mem_max = 0.40 if os.name == 'nt' else 0.5
return perc_reserved_mem_max
Two float() calls, minimal change, fixes both code paths.
Environment
mmgp 3.7.4
Wan2GP (latest)
Windows 10/11
Python 3.10