I have ads which load sometimes slower, I want to hide those ads for Googlebot. I plan to hide that ad code for googlebot only and show them only to users.
Do I risk a Google penalty if I hide ads, or am I free to do that?
What you're describing is definitely cloaking. "Cloaking refers to the practice of presenting different content or URLs to human users and search engines," according to Google. That means you'd be risking a penalty.
Ads are content. Ads can be invasive. Ads can affect the user experience on the page. Of course Google would want to see both your regular page content and your ads.
If your intention is to make your pages appear faster than they are and thus to rank better, I would instead recommend either removing your slow ads or letting search engines see your page as your human users see it.