If you have a pool of candidates that are equally qualified and you prefer hiring some one based on their gender, sexual orientation or ethnicity that is discrimination regardless of how you look at it.
When you tie financial incentive you are even more likely to create discrimination since if a candidate is merely qualified but not the most qualified out of a pool you are likely to choose them in order to meet the hiring policy especially if your income is dependant on it.
Lastly I've seen some diversity goals in some companies and sorry but these goals are unrealistic, when women make up 15-18% of the students in computer science, engineering and similar degrees there is absolutly no way to meet a goal of 50%/50% split between men and women as engineers without drastically reducing the diversity in other companies.
If the 30%+ goal for women in MSFT is going to be cross department MSFT would effectively have to poach women from other companies and hire across multiple graduation years which either would leave a larger percentage of male engineers unemployed or make other companies less diverse.
If women were 50% of STEM graduates and we still had an issue of diversity in tech that would be a different story, but currently most large tech companies have a higher percentage of women including in engineering than the national average in their relevant degrees and vocational education.
Women make up less than 20% of most STEM programmes especially those related to computer sciences, women make up less than 20% of most coding bootcamps, so exactly where would these magic diversity quotas are supposed to come from?