Optimal Scheduling Algorithms for LLM Inference: Theory and Practice