It is the coolest thing - when whales sleep - most often it's at the surface of the water - as they are conscious breathers.....meaning that they have to be conscious to take a breath - in order to come to the surface for air regularly unlike us humans (we breath unconsciously).
Since whales need to be conscious to take a breath - and they "Do" need to sleep - they shut down only half of their brains while sleeping - with one side in a semi-conscious state to alert them to dangers. They float near the surface described as "logging" because they look like a log floating aimlessly when they are asleep.
Below is a short - rare video clip (no sound) of a pod of 6 Sperm Whales "floating errily" in a vertical sleep state.....completely unaware of the researchers boat until one accidentally touches the side of the boat....and the whole group wakes up......very interesting to see...a rare video for sure!!
This is the way Sperm Whales generally sleep, but they have been known to catch "cat-naps" while diving as well. Most other whale species sleep horizontally at the surface just "drifting" or "logging" so as to be able to consciously take a breath when needed.
As a matter of fact that is one reason for whales being hit by large sea-going vessels......the whales have the side of their brains that are facing the ships - turned "off" in a sleep state...and with the increase of shipping - we are seeing more fatal whale strikes all the time!