in optimum/amd/brevitas/accelerate_utils.py [0:0]
def allocate_params(module):
"""
This function calls the pre_forward function of the _hf_hook, making sure parameters are on
the selected device, rather than on the meta device.
"""
if module._hf_hook.offload is False:
return
# When quantizing and retrieving parameters (e.g., during GPTQ), we want to recurse through
# all the submodules
for m in module.modules():
if hasattr(m, "_hf_hook"):
m._hf_hook.pre_forward(m)