your code to set the $_SESSION['UPS_MaxRate'] session would need to look at the quantity being used, and divide by that items quantity.
In reality this sort of custom coding is beyond the scope of what we can help you with in this forum, I would suggest signing up for a premiere support appointment to get assistance with this.