Turn the garments inside out before laundering
Sweat, the natural oils that your body produces, dead skin — all that stuff that builds up and contributes to the rank smell that develops on your yoga workout clothes — lives in the interior of the garment, which is why turning your tops and bottoms inside out before washing is a good thing to do.
Use less detergent
The use of too much detergent can contribute to lingering odors because soap residue will remain on the yoga-fit clothing. That buildup of detergent will contribute to the development of bacteria, and that bacteria will contribute to your odor problem.
It's a good idea to take a hard look at the fill lines on liquid detergent caps or powdered detergent scoops to make note of how much detergent to measure out for small, medium, and large loads (marking those lines with a permanent marker or tape will make them much easier to see). If you use a concentrated detergent, it's especially important to be judicious when measuring. You could end up using, like, four times the amount of detergent you need.
Add an odor eliminating product to your wash
When it comes to really bad smells, detergent alone may not be enough to entirely rid your clothes of them. Enter the laundry booster, it can help to brighten whites, remove stains, or eliminate odors. In this case, we're looking for odor eliminators, of which there are a number of options.
You can use white vinegar. because it's cheap, easy to find, and it works amazingly well. If you want to use it, add a half to a full cup (depending on load size and the relative stinkiness of your gear) to the rinse cycle, which you can do by putting it into the dispenser for fabric softener at the start of the wash — the machine will dispense it at the right time.
There are options besides vinegar, however. Baking soda is one, Borax is another. A half-cup of one or the other of those can be added at the beginning of the wash cycle along with your regular detergent.
Avoid the use of fabric softeners
Fabric softeners, both in their liquid and sheet form, will leave behind a coating that, on athleticwear, is no good. That coating will build up over time and turn into a sort of unpassable shield that keeps water and detergent from penetrating the fibers to do their dirt and odor eliminating thing. Skip the fabric softener entirely when it comes to cleaning your exercise togs, or at least cut way, way back on the dosage if you can't bring yourself to entirely quit the stuff.
Skip high heat drying
Using the highest heat setting on the dryer, or even the medium heat setting, isn't great for your gym gear in general. Heat will amplify odors, so using the low- or no-heat dryer setting is optimal for drying athletic clothing. Better yet, air dry your gear — it will smell fresher, and last longer because exposure to heat can shorten the lifespan of yoga clothes by stressing the fibers.