Aussie AI
Tuning Trade-offs
-
Book Excerpt from "Generative AI in C++"
-
by David Spuler, Ph.D.
Tuning Trade-offs
Tuning a program is not always a clear-cut gain. There are numerous other quantities that efficiency may affect:
- Model accuracy versus speed.
- Space versus time-efficiency.
- Robustness of a program.
- Readability and maintainability of a program.
- Portability of a program.
Accuracy of the LLM is the main trade-off in many of the optimizations. This book contains numerous ways to optimize a Transformer engine, some of which 100% retain accuracy (e.g. vectorization), whereas others are effectively approximations of the original model (e.g. quantization).
There is almost always a trade-off between time and space when making programs run faster. Many of the algorithm improvements sacrifice space for extra speed, such as caching and precalculation.
Changing a program for efficiency can introduce extra bugs into a program (although you could argue that it might remove bugs, too). If a piece of code has already been debugged, improving its efficiency may not be worth the risk to the robustness of a program.
Many of the program transformations used for efficiency can reduce the readability of a program. Naturally, this also makes it more difficult for a program to be maintained, and since the major cost in a program’s development cycle is usually maintenance, improving efficiency may not be worth it in the long run.
Perhaps surprisingly, the efficiency of a program can usually be increased significantly without affecting portability. There are some efficiency techniques in this book that use machine-specific methods, such as hardware-acceleration, but there are many generic methods that work across all C++ code.
Almost all of the dangers of improving efficiency are dangers for the programmer. On the other hand, the users of a program will be well pleased by extra responsiveness, and this alone makes efficiency improvement a worthwhile exercise.
• Next: • Up: Table of Contents |
The new AI programming book by Aussie AI co-founders:
Get your copy from Amazon: Generative AI in C++ |