it seems that on my cluster, this issue can be mitigated somewhat by using the SLURM option
#SBATCH --disable-turbomode
when submitting the job. This disables the frequency to get boosted when the temperature is low enough, i.e. for small load of the node.
The cpu frequency is still not completely stable, but the naive scaling is now nearly perfect.
1 => 1.0
2 => 1.9997469597122512
24 => 23.952572231631184
48 => 47.6049161324683
correcting for the still slightly different cpu frequency ratios, I get as close to perfect scaling as is reasonable.
1 => 1.0
2 => 1.99889
24 => 23.8487
48 => 47.874
Thanks again to everyone for their help. I can finally get back to improving the scaling of my original code (which of course should now also be quite a bit better)