Is MP always a VRAM saver / performance enhancer?

Want to understand the training process better? Got tips for which model to use and when? This is the place for you


Forum rules

Read the FAQs and search the forum before posting a new topic.

This forum is for discussing tips and understanding the process involved with Training a Faceswap model.

If you have found a bug are having issues with the Training process not working, then you should post in the Training Support forum.

Please mark any answers that fixed your problems so others can find the solutions.

Locked
User avatar
couleurs
Posts: 9
Joined: Fri Jan 13, 2023 3:09 am
Has thanked: 10 times
Been thanked: 6 times

Is MP always a VRAM saver / performance enhancer?

Post by couleurs »

There appears to be a complex relationship between model structure and how MP will behave.

Some models run significantly faster or with higher batch sizes, but others don't really see any improvement at all.
And in the worst case, I even built a model that somehow allowed me to run a batch size (4) on FP that OOMed on MP :?

Is it possible to determine how model structure will affect the MP/FP ratio of performance or VRAM use? (without building/running the model, I mean)

I'm at a loss to explain why MP would run slower or with more VRAM than FP in some configurations... has anyone else experienced this? I'm running a 3060, so should support MP fully afaik

User avatar
bryanlyon
Site Admin
Posts: 793
Joined: Fri Jul 12, 2019 12:49 am
Answers: 44
Location: San Francisco
Has thanked: 4 times
Been thanked: 218 times
Contact:

Re: Is MP always a VRAM saver / performance enhancer?

Post by bryanlyon »

Mixed precision will ALWAYS use less VRAM. It however, will not always be faster. That does depend on your GPU and system.

If you're on Windows a LOT of things can use your VRAM, even just opening the start menu takes some. In the end, it's very possible that your web browser reserved some memory and caused your MP to OOM.

User avatar
couleurs
Posts: 9
Joined: Fri Jan 13, 2023 3:09 am
Has thanked: 10 times
Been thanked: 6 times

Re: Is MP always a VRAM saver / performance enhancer?

Post by couleurs »

bryanlyon wrote: Fri Jan 13, 2023 6:44 am

Mixed precision will ALWAYS use less VRAM. It however, will not always be faster. That does depend on your GPU and system.

Thank you for the clarification

bryanlyon wrote: Fri Jan 13, 2023 6:44 am

If you're on Windows a LOT of things can use your VRAM, even just opening the start menu takes some. In the end, it's very possible that your web browser reserved some memory and caused your MP to OOM.

I'll make sure to close everything and check idle VRAM to see if I can confirm the inverted MP vs FP usage behavior, but you're probably right ;)

For estimating the %VRAM saved for any given model going FP->MP, am I correct in reasoning that it's roughly
(16bits/32bits = 0.5) * (#params in MP-compatible layers) / (#params in total layers)
or are there other factors - in the model, not GPU/OS/system-level - that affect it?

User avatar
bryanlyon
Site Admin
Posts: 793
Joined: Fri Jul 12, 2019 12:49 am
Answers: 44
Location: San Francisco
Has thanked: 4 times
Been thanked: 218 times
Contact:

Re: Is MP always a VRAM saver / performance enhancer?

Post by bryanlyon »

Mixed precision is not a simple 1/2 the vram saved unfortunately. It uses "mixed" precision which means some parts are kept in fp32 and some are in fp16. In fact, recent versions of Tensorflow have even done some stuff into TF32 which is a weird Nvidia-only 19bit float replacement (see https://blogs.nvidia.com/blog/2020/05/1 ... on-format/ )

In the end even version can change the savings. But it will NEVER make it larger.

Locked