Created
March 18, 2026 19:09
-
-
Save erictune/5b6ca020fa0bbfb9f8ea59ae7aa533f9 to your computer and use it in GitHub Desktop.
Show why mostallocated is better because it never reduces future choices.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| capacity=8 | |
| sizes = [1,2,4,8] | |
| # Look at all "interesting" two node scenarios where there is an incoming pod P. | |
| # Node are called A and B. | |
| # This is a list of (node_a_allocatable, node_b_allocatable, pod_p_limit) | |
| # A is always the less allocated node. | |
| # P is feasible on both A or B. (Ignore scenarios where there is no choice to make.) | |
| # P has a size in `sizes' | |
| scenarios = [(a,b,p) for a in range(9) for b in range(a+1,9) for p in sizes if a+p <= capacity] | |
| # scenarios = [(0, 1, 1), (0, 1, 2), ..., (0, 2, 1), ..., (6, 8, 2), (7, 8, 1)] | |
| # For a node with `allocated' GPUs already allocated, what is the largest next pod request that could fit. | |
| def max_next_pod(allocated): | |
| return max([0]+[s for s in sizes if allocated +s < capacity]) | |
| picking_a_better=0 | |
| picking_b_better=0 | |
| tie=0 | |
| for (a, b, p) in scenarios: | |
| # If we pick A for P, what is the largest pod after that we can fit on either node? | |
| new_a = a + p | |
| biggest_next_pod_after_pick_a = max(max_next_pod(new_a), max_next_pod(b)) | |
| # If we pick B for P instead, ... | |
| new_b = b + p | |
| biggest_next_pod_after_pick_b = max(max_next_pod(a), max_next_pod(new_b)) | |
| # Which is better? | |
| if biggest_next_pod_after_pick_a == biggest_next_pod_after_pick_b: | |
| tie+=1 | |
| elif biggest_next_pod_after_pick_a > biggest_next_pod_after_pick_b: | |
| picking_a_better+=1 | |
| else: | |
| picking_b_better+=1 | |
| print("picking_a_better", picking_a_better) | |
| print("picking_b_better", picking_b_better) | |
| print("tie", tie) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment