Weight of undergraduate grades when applying for a Ph.D I am an undergraduate student in Computer Engineering and I would like to do a Ph.D. at a well reputed university. I am facing a problem because I took some borderline pass grades in a few courses (3 of them) and I might want to retake them. This courses though are not that much relevant to the area that I currently work in (for example they might be some user interface design classes whereas my focus is on parallel computing).

I would like to ask how much do these grades matter for my applications for a Ph.D. in a reputed university (like Carnegie Mellon Univeristy (CMU) in Computer Science, but not restricted to that). And how much does these grades matter if I get into an M.Sc. course in a highly reputable university.

To be more concrete, will these grades matter if I want to continue my studies towards a Ph.D. at CMU. And how much more or less do they matter if I will be on an M.Sc. at ETH Zurich (or a similar university, where I can do really good research) when I will apply to CMU. (This is just a random example)
There can't be any sort of general answer, as the criteria used by individual schools vary quite a bit. In the end, the decisions are taken by admission committees, who do look at numbers (i.e., GPA, grades in detail, ranking of undergraduate program, ...) but should (and will!) also look at more soft measures, be it grades in "selected" courses, strength of recommendation letters, ranking of high school of origin, evidence of not just academic interest (i.e., was part of the debate club, ...). But it is probably the case that a first filter is on "hard" data (specially if the school gets many more applications than places available).

This is a question only the current members of said committees at the schools that interest you could possibly answer, and probably will never do, not even in private.