It sounds like your dog thinks you're trying to play. If you watch dogs (especially young dogs) play with each other, you'll see them bow and twist rapidly, which is probably similar to your stretching.
You have a few options: two different approaches to training or the environmental method.
It might be possible for you to just not exercise around your dog. If you can, it may well be easiest to just stretch and exercise in a different room behind a closed door. That would solve the problem easily. However, it might not be an option or the best option depending on your home.
Training - Ignore
The next option is to just ignore your dog when he does this. With consistency, he will learn that your stretching or exercise doesn't mean you're going to play with him. It will work best if you make a routine and stick to it. For example, maybe you exercise after you return from a walk with him, first thing in the morning, or before bed.
While you're training him, you don't have to put up with it for very long, but it's important that no part of the process involves him. You can't give him treats afterward or acknowledge him at all. When you're done exercising, do another activity (like showering, getting dressed, or sitting down) for at least 5 minutes before paying him any attention at all.
Training - Redirection
The last option is to explicitly train a new behavior during your exercise time. Does your dog know how to sit and stay? How about lie down? Basically, you'd start teaching him that he lays down on a bed while you exercise, and when he's done he can have attention and treats.
To do this, start by making sure he is excellent at lying down and staying until you release him. Don't introduce any exercise until he has mastered this normally.
Next, have him lie down and stay while you do 15 seconds of stretching at a time. Release and reward him after each interval. Try to use different poses/stretches. Once he can do 15 seconds with one pose consistently, slowly lengthen the time you ask him to stay. 30 seconds, 1 minute, 2 minutes. Use timers if you need to, and make sure to give lots of praise, treats, and a quick game between sets.
Over time, you'll build up to a full 20-30 minutes and he'll be content to lay down and watch instead of getting up in your face.