Aussie AI

Downsides of AI in C++

  • Book Excerpt from "Generative AI in C++"
  • by David Spuler, Ph.D.

Downsides of AI in C++

Have you ever noticed in your life that absolutely everything has a trade-off between fast and safe? I mean, think about everything you do: driving when your kid's late for underwater ballet class, jogging with a cup of coffee, eating Weetbix without milk, using a paint stripper to blow-dry your damp clothes, I could go on. I'm not going to say that C++ is like using a microwave to boil an egg, but you know there's a few problems, right?

Most of the issues with C++ are not specific to AI applications and are well-known. There are plenty of insidious traps in C++ pointers and memory allocation to keep debuggers busy for decades to come. The C++ standardization committees have gradually addressed some of the problems, but other things are so widely used and intractable that they won't be fixed. Improved tools are probably the mainstay of improvements here.

In addition, here's a list of a few other problems in AI C++ coding:

  • 16-bit float flux. It's hard to have simple C++ support for any 16-bit floating-point types, such as FP16 (float16) or BF16 (brain float 16). The C++23 version has added standardization of various 16-bit float types, which means this concern will probably abate once all C++23 new features are widely available in compilers.
  • Non-standardized hardware acceleration. Every hardware platform is different. It's tricky to do things in C++ like figuring out whether you have a GPU available and what hardware-acceleration features your current CPU has.

But never mind, all of these things are fixable with some elbow grease. It's just a small matter of coding, for which I estimate two weeks. And we wouldn't be together having this one-way discussion if coding it was all a piece of cake. So, hooray for AI in C++!

 

Next:

Up: Table of Contents

Buy: Generative AI in C++: Coding Transformers and LLMs

Generative AI in C++ The new AI programming book by Aussie AI co-founders:
  • AI coding in C++
  • Transformer engine speedups
  • LLM models
  • Phone and desktop AI
  • Code examples
  • Research citations

Get your copy from Amazon: Generative AI in C++