BOM does not convert rate of Material based on UOM

My Raw materials are bought and tracked in Kg but my finished products are tracked in gm. However in the BOM for the product, the material cost is calculated by multiplying the amount required in grams X the valuation rate of the Raw material which is in kg. How do I get it to convert the rate?

My raw material has both UOM kg and gram.

Is this just a bug?

UOMs
1.000 kg = 1000 gram