gemma_pytorch icon indicating copy to clipboard operation
gemma_pytorch copied to clipboard

Memory saving loading weight for non-quant models

Open KaneGreen opened this issue 11 months ago • 5 comments

Trying to fix #51 And this also increase the speed of loading weights. (in my computer, about 1min vs 2min) Tested on 1.1-7b-it and 7b-it model.

but:

  1. This method is not suitable for the int8 data type, so the original loading method is still used when using the quant model.
  2. The new loading method will automatically reset the requires_grad of nn.Parameter in Linear and Embedding to True after the loading is completed. (I don't know why some nn.Parameters in model.py have requires_grad as False and others as default True) But I think, this shouldn't affect since forward function of GemmaForCausalLM has @torch.no_grad().

KaneGreen avatar Apr 05 '24 05:04 KaneGreen

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Apr 05 '24 05:04 google-cla[bot]

@pengchongjin @michaelmoynihan Any idea on this PR?

KaneGreen avatar Apr 13 '24 08:04 KaneGreen

Thanks, @KaneGreen ! Coould you please sign the CLA in order to pass the pre-check?

pengchongjin avatar Apr 15 '24 18:04 pengchongjin

@pengchongjin I've signed that. But it doesn't update. Any way to re-run this check?

KaneGreen avatar Apr 16 '24 00:04 KaneGreen

@pengchongjin CLA has been signed

KaneGreen avatar Apr 17 '24 12:04 KaneGreen