News for hackers. Stuff that matters.
Re:GPT-2: 6-Month Follow-Up by minimaxir on Tuesday August 20, 2019 @12:46PM (#20749037)
For finetuning GPT-2 on custom text, my gpt-2-simple package (https://github.com/minimaxir/gpt-2-simple) gets close to going OOM when finetuning the 345M model, even on a 16GB VRAM server GPU. Doubling the size of the model with the 774M model might cause it to not work at all, so I’ll need to test.

Of course, the default output from the model might be sufficient, although it’ll take twice as long to generate text compared to the 345M which is slow even on a GPU.

How exactly the large GPT-2 models are deployed is a mystery I really wish was open-sourced more.

Re:GPT-2: 6-Month Follow-Up by AdamDKing on Tuesday August 20, 2019 @06:17PM (#20752765)
>How exactly the large GPT-2 models are deployed is a mystery I really wish was open-sourced more.

TalkToTransformer.com uses preemptible P4 GPUs on Google Kubernetes Engine. Changing the number of workers and automatically restarting them when they're preempted is easy with Kubernetes.

To provide outputs incrementally rather than waiting for the entire sequence to be generated, I open a websocket to a a worker and have it do a few tokens at a time, sending the output back as it goes. GPT-2 tokens can end partway through a multi-byte character, so to make this work you need to send the raw UTF-8 bytes to the browser and then have it concatenate them _before_ decoding the string.

While my workers can batch requests from multiple users, the modest increase in performance is probably not worth the complexity in most cases.

Re:GPT-2: 6-Month Follow-Up by jcims on Wednesday August 21, 2019 @01:58PM (#20759630)
Any thoughts on the larger model? Doesn't seem materially better than the last one. Maybe the fine tuning exercises will show the benefit?
Re:GPT-2: 6-Month Follow-Up by gwern on Tuesday August 20, 2019 @01:02PM (#20749230)
I've already tried training with nshepperd's codebase. Sampling works, but even with the memory checkpointing and freezing the embedding and using SGD rather than Adam, it OOMs on a 1080ti's 11GB. Either additional tricks or CPU training are going to be required.
Re:GPT-2: 6-Month Follow-Up by newhaus1994 on Tuesday August 20, 2019 @05:43PM (#20752526)
I'm the lead researcher on the Middlebury Institute project looking at fine-tuning the bigger models, and I got OOM on 745M and 1.5B originally. I had to get an Azure instance with 24GB VRAM to handle it (using nshepperd's codebase). It works, but takes a while (~500 epochs takes 12 hours on a 100k word training dataset).
Re:GPT-2: 6-Month Follow-Up by gwern on Tuesday August 20, 2019 @06:37PM (#20752927)
Ouch! So 11GB is nowhere close to being enough, then. I wonder if even switching to FP16 will be adequate?
Re:GPT-2: 6-Month Follow-Up by newhaus1994 on Tuesday August 20, 2019 @07:09PM (#20753177)
Might be able to get 745M down to work on a single GPU. I'm definitely not using all 24GB, so fp16 might be able to get it down enough.
Re:GPT-2: 6-Month Follow-Up by sdan on Wednesday August 21, 2019 @03:30AM (#20755196)
How would you use fp16 to get it to work on a single GPU? And if you did, what GPU should you use?
Re:GPT-2: 6-Month Follow-Up by minimaxir on Tuesday August 20, 2019 @01:14PM (#20749373)
Figured. I'll make changes to allow sampling from the default model more easily.
Re:GPT-2: 6-Month Follow-Up by p1esk on Tuesday August 20, 2019 @01:12PM (#20749362)
Are you using FP16?
Re:GPT-2: 6-Month Follow-Up by gwern on Tuesday August 20, 2019 @01:18PM (#20749423)
No. We weren't sure if that'd be a good idea since it wasn't trained with low-precision, and 345M thankfully didn't require going that far. 744M might, though. (Another option is model parallelism since I have 2 GPUs and that might be enough, perhaps freezing more layers and training incrementally, or reducing the 1024 token window to smaller ones like 700.)
Re:GPT-2: 6-Month Follow-Up by JonathanFly on Tuesday August 20, 2019 @02:18PM (#20750156)
On the NVIDIA GPT- 2 implementation:

>What would be the largest model one could train across 2x 2080Ti?

>~800M gpt2. this is largely due to the memory required to House parameters + optimizer states. If one uses a smaller optimizer than Adam training something larger should be possible. Make sure to turn on activation checkpointing with —checkpoint-activations

https://twitter.com/TheRealRPuri/status/1161322580126470145

Re:GPT-2: 6-Month Follow-Up by gwern on Tuesday August 20, 2019 @02:39PM (#20750428)
They haven't released such models, though, and I don't know if it would be drop-in compatible with the OA GPT-2-774M checkpoint (they're training their own GPT-2s using their own webtext corpus).
Re:GPT-2: 6-Month Follow-Up by JonathanFly on Tuesday August 20, 2019 @04:03PM (#20751433)
I haven't look into at all myself, but he also said:

>We do provide training code that should work out of the box for gpt2 117M/345M

https://twitter.com/TheRealRPuri/status/1161319745259393024

Re:GPT-2: 6-Month Follow-Up by p1esk on Tuesday August 20, 2019 @04:18PM (#20751613)
It would take forever (or $$$) to train even 117M model from scratch.
Re:GPT-2: 6-Month Follow-Up by JonathanFly on Tuesday August 20, 2019 @05:02PM (#20752107)
I read that meaning you can start with the actual pre-trained GPT-2 models but I never got an answer when I specifically asked if that was the case.
Re:GPT-2: 6-Month Follow-Up by The_rationalist on Tuesday August 20, 2019 @02:14PM (#20750108)
You maybe should try tensorflow automatic mixed precision! https://github.com/zihangdai/xlnet/pull/200
Re:GPT-2: 6-Month Follow-Up by slashcom on Tuesday August 20, 2019 @01:41PM (#20749702)
fp16 saves a lot of memory and is worth doing. I've not had trouble fine tuning all these models with fp16.
Re:GPT-2: 6-Month Follow-Up by sdan on Wednesday August 21, 2019 @03:32AM (#20755208)
Have you fine tuned 774 successfully using a single GPU?
Re:GPT-2: 6-Month Follow-Up by p1esk on Tuesday August 20, 2019 @01:51PM (#20749799)
I recommend Nvidia Apex, it offers several ways to mix precision.
Re:GPT-2: 6-Month Follow-Up by the8472 on Tuesday August 20, 2019 @03:16PM (#20750852)
Possibly a stupid question, but does AMD lift such restrictions on models with its unified memory, by allowing the GPU to "page out" chunks of vram to system ram?
Re:GPT-2: 6-Month Follow-Up by p1esk on Tuesday August 20, 2019 @07:01PM (#20753120)
My guess is it would be much slower, because GPU processor would wait for data. Compare bandwidth - system RAM to GPU memory (PCIe): 16GBps vs GPU memory to GPU processor: 900GBps.
Re:GPT-2: 6-Month Follow-Up by minimaxir on Tuesday August 20, 2019 @03:26PM (#20750955)
No idea how modeling works on AMD. (most discussions are about NVidia/CUDA)
Re:GPT-2: 6-Month Follow-Up by vimy on Tuesday August 20, 2019 @07:17PM (#20753229)
Isn't that a macOS specific feature?