switching to a rifle with a pistol grip does take some adjustment.
like everything else - practice makes perfect and is the only way to develop muscle memory.
may wish to consider a visible level to put onto your gun (or optic) to help you get used to getting rid of any cant.
hand placement and how you hold the pistol grip play a big part in the correction - that pistol grip hanging down is a very leverage heavy point for the vertical index of your firearm..
treat it more like good hangdun fundamentals and things will fall into play a bit easier.
i know that when i fixed my grip related accuracy problems for my handgun, my long gun accuracy increased significantly. much like with a handgun - if you do everything else but your trigger pull and grip position on the gun sucks - the results you get are going to follow right along.