How would you optimize the latency of an inference endpoint serving a large transformer model?
Implement optimize_latency(optimizations, memory_budget) to select compatible optimizations that maximize total latency reduction under a memory budget. Each optimization may require one prerequisite, and selecting an optimization requires selecting its entire prerequisite chain. Return the maximum achievable latency reduction.
Each optimization is a dictionary with integer fields memory, reduction, and requires, where requires is another index or -1. The prerequisite graph is a forest. Return an integer.
def optimize_latency(optimizations, memory_budget):