tensor2tensor icon indicating copy to clipboard operation
tensor2tensor copied to clipboard

Can FP16 speed-up translation?

Open davidecaroselli opened this issue 8 years ago • 5 comments

Description

We are trying to transform a regular FP32 transformer-big model into a much smaller FP16 one. We successfully down-scaled all values so that now our model on disk is (roughly) half the size.

The problem is that, when we run the decoding, the GPU RAM used is exactly the same of the FP32 model and also the decoding time is the same. I suspect that, for some reason, the model is somehow re-converted back to FP32 on the fly by tensor2tensor/tensorflow right after the loading, and we a re still translating with a 32-bit model.

Is there something obvious that I'm missing?

Thanks for the help.

Environment information

OS: Ubuntu 16.04

$ pip freeze | grep tensor
tensor2tensor==1.6.3
tensorboard==1.8.0
tensorflow-gpu==1.8.0

$ python -V
Python 2.7.12

davidecaroselli avatar Nov 14 '18 14:11 davidecaroselli

Both the training and decoding process can be accelerated by FP16, I have tried on Titan V by Fairseq system. As you said, I think you should check if your device support the FP16 accelerated , only Volta 100 and Titan V can achieve good support. By the way, I don't now how to use FP16 to train my model on GPU device , if you now, it's appreciate to tell me how

libeineu avatar Nov 28 '18 01:11 libeineu

Unfortunately no luck with t2t, no idea how to train in fp16, and we were unable to even decode with fp16 (as I said in the first post, everything seems to be re-converted backto fp32).

On fairseq on the contrary we observed some improvements, however we had no success into "porting" those ideas on t2t.

davidecaroselli avatar Dec 01 '18 16:12 davidecaroselli

Yeah, the same as mine, I found it will gain 2.6-2.9 faster training with FP16 Transformer Big using Fairseq, it seems that the bigger structure you train , the faster speed you will gain. And I saw it really support FP16 training on TPU device, so it may be feasible on GPU with some details to fix!!!

libeineu avatar Dec 03 '18 02:12 libeineu

Hi, is there any progress for it ? We also wanna accelerate the decoding speed by FP16.

Chris19920210 avatar Dec 06 '18 03:12 Chris19920210

mark

aeloyq avatar Dec 10 '18 07:12 aeloyq