The same way God "knows" people in these other verses:
Mat_7:23 And then will I declare to them, 'I never knew you;
2Ti_2:19 But God's firm foundation stands, bearing this seal: "The Lord knows those who are his,"
Amo_3:2 "You only have I known of all the families of the earth; therefore I will punish you for all your iniquities.
In these examples, for God to "know" someone doesn't merely mean that he knows about them or their actions. it refers to an intimate knowledge, a relationship.
When Jesus said "I never knew you" in Mat 7:23, he wasn't merely saying that he didn't
about their existence or
about their actions. Obviously Jesus knows everyone, even those who perish. Therefore when he "knows" someone it means to know them intimately, to be in a relationship with them. The same is true of Amos 3:2. God said "you only have I known". Obviously he meant much more than knowing their existence. God knows every family on earth, not just Israel. So what did he mean by saying "I only know you among all the families". Obviously his "knowledge" of them means to know them in a personal, intimate way.
This is what is meant by God "knowing us before" (aka, foreknowing us) in Romans 8. He set his covenantal love upon us from eternity past.
2Ti_1:9 Who hath saved us, and called us with an holy calling,
not according to our works, but according to his own purpose and grace, which was given us in Christ Jesus
before the world began,
The Bible is consistent in teaching this truth