mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-23 00:18:20 +01:00
Don't override user initial wbits/groupsize
This commit is contained in:
parent
64e3b44e0f
commit
43e01282b3
31
server.py
31
server.py
@ -185,9 +185,17 @@ def download_model_wrapper(repo_id):
|
|||||||
|
|
||||||
|
|
||||||
# Update the command-line arguments based on the interface values
|
# Update the command-line arguments based on the interface values
|
||||||
def update_model_parameters(state):
|
def update_model_parameters(state, initial=False):
|
||||||
elements = ui.list_model_elements() # the names of the parameters
|
elements = ui.list_model_elements() # the names of the parameters
|
||||||
gpu_memories = []
|
gpu_memories = []
|
||||||
|
defaults = {
|
||||||
|
'wbits': 0,
|
||||||
|
'groupsize': -1,
|
||||||
|
'cpu_memory': None,
|
||||||
|
'gpu_memory': None,
|
||||||
|
'model_type': None,
|
||||||
|
'pre_layer': 0
|
||||||
|
}
|
||||||
for i, element in enumerate(elements):
|
for i, element in enumerate(elements):
|
||||||
if element not in state:
|
if element not in state:
|
||||||
continue
|
continue
|
||||||
@ -197,18 +205,20 @@ def update_model_parameters(state):
|
|||||||
gpu_memories.append(value)
|
gpu_memories.append(value)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if element == 'wbits' and value == 'None':
|
if initial and eval(f"shared.args.{element}") != defaults[element]:
|
||||||
value = 0
|
continue
|
||||||
if element == 'groupsize' and value == 'None':
|
|
||||||
value = -1
|
# Setting null defaults
|
||||||
|
if element in ['wbits', 'groupsize', 'model_type'] and value == 'None':
|
||||||
|
value = defaults[element]
|
||||||
|
elif element in ['cpu_memory'] and value == 0:
|
||||||
|
value = defaults[element]
|
||||||
|
|
||||||
|
# Making some simple conversions
|
||||||
if element in ['wbits', 'groupsize', 'pre_layer']:
|
if element in ['wbits', 'groupsize', 'pre_layer']:
|
||||||
value = int(value)
|
value = int(value)
|
||||||
if element == 'cpu_memory' and value == 0:
|
|
||||||
value = None
|
|
||||||
elif element == 'cpu_memory' and value is not None:
|
elif element == 'cpu_memory' and value is not None:
|
||||||
value = f"{value}MiB"
|
value = f"{value}MiB"
|
||||||
if element == 'model_type' and value == 'None':
|
|
||||||
value = None
|
|
||||||
|
|
||||||
exec(f"shared.args.{element} = value")
|
exec(f"shared.args.{element} = value")
|
||||||
|
|
||||||
@ -217,6 +227,7 @@ def update_model_parameters(state):
|
|||||||
if i > 0:
|
if i > 0:
|
||||||
found_positive = True
|
found_positive = True
|
||||||
break
|
break
|
||||||
|
|
||||||
if found_positive:
|
if found_positive:
|
||||||
shared.args.gpu_memory = [f"{i}MiB" for i in gpu_memories]
|
shared.args.gpu_memory = [f"{i}MiB" for i in gpu_memories]
|
||||||
else:
|
else:
|
||||||
@ -859,7 +870,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
model_settings = get_model_specific_settings(shared.model_name)
|
model_settings = get_model_specific_settings(shared.model_name)
|
||||||
shared.settings.update(model_settings) # hijacking the interface defaults
|
shared.settings.update(model_settings) # hijacking the interface defaults
|
||||||
update_model_parameters(model_settings) # hijacking the command-line arguments
|
update_model_parameters(model_settings, initial=True) # hijacking the command-line arguments
|
||||||
|
|
||||||
# Load the model
|
# Load the model
|
||||||
shared.model, shared.tokenizer = load_model(shared.model_name)
|
shared.model, shared.tokenizer = load_model(shared.model_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user