Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions gptqmodel/looper/module_looper.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@ def cache_inputs(self, layers, auto_gc, calibration_data, calibration_enable_gpu
def store_input_hook(module, args, kwargs):
# Positional arguments.
layer_input = []
for inp in args:
layer_input.append(move_to(inp, device=data_device))
if len(layer_input) == 0:
# Some models put hidden_states in kwargs instead of args.
# For example, gptj ...
if kwargs.get("hidden_states") is not None:
layer_input.append(move_to(kwargs["hidden_states"], device=data_device))

if kwargs.get("hidden_states") is not None:
layer_input.append(move_to(kwargs["hidden_states"], device=data_device))
else:
# If hidden_states is not in kwargs, get it from the first positional argument
# If error occurs here, check the model's modeling code
layer_input.append(move_to(args[0], device=data_device))

layer_inputs.append(layer_input)

# Keyword arguments.
Expand Down