Google's ranking doesn't consider code validity, as far as I know. On the other hand, a page with grossly invalid code might affect the correct interpretation of semantic markup. In general though the two aren't related.
That's not to say that striving to code valid pages is a waste of time - it is not. Validating your pages is one of the most important tools in your toolbox as a web developer.