First, all notes must be played from the weight of the arm or from gravity. That eliminates the tension of playing down and gives you microseconds of relaxation on the up.
Secondly, when you abduct your fingers (stretch/spread them out), they pull (vector force) on the flexor muscles in the forearm. Then when you flex your fingers, the tendon between the bone and muscle gets strained, giving you the SYMPTOM of cramps. Playing with gravity will partially eliminate this.
Don't do this but, with all five fingers together, wave "bye bye." Effortless, right? Now abduct (ab=away, duct=lead) them and wave bye bye. Feel the tension? That is because you are using two muscles to move one bone at the same time: Vector forces. It is imperative for pianist to learn how to use the correct muscles and only one muscle at a time.
Octaves are challenging but by using gravity, the pronator muscles, the bicep, and most importantly, not using muscles you don't need, is the key. Every motion should have an equal and opposite (though minimized) motion. Just watch the grace of a skilled fly fisherman. Slap a face, throw a ball, swing a bat, a tennis racquet, a fishing pole, kick a ball - they all start with opposite motions. In order for a pianist to play down, they must first play up. A pianist who first tries to play relaxed or with a still quiet hand is looking for trouble. Exaggerate, then minimize. There is no such thing as relaxation at the piano. Most of us just relax the wrong muscles and use the wrong ones. If you use the incorrect muscle AND try to relax it, you're not going to get anywhere. Just relax the incorrect muscles and use the correct ones. The incorrect muscles are the abductors and flexors - the ones we are all trained to play from.
Maybe this video will give you an idea:
The fingers don't have any muscles on them. They are moved by our forearm muscles and are opened and closed by a "pulley system" with the tendons. A pianist who focuses on playing from the fingers and hand will hurt themselves by straining the long flexor tendons causing them to inflame and press on the median nerve.
You can blame technique books such as Hanon for the rash of injuries pianists have suffered the past hundred years. Actually, you can blame teachers who didn't study biology and physics in HS. You know, those courses you don't use in real life.