We have ads which load sometimes slower, We want to hide those ads for Googlebot. We plan to hide that ad code for googlebot only and show them only to users.
Do we risk a Google penalty if we hide ads, or we are 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.