Repository navigation
[RL] First-fit flat-token packing across DP ranks - #3938
Conversation
|
the numbers would be much higher for thinking=True. Right now, our average response is ~40, so we cant really tell |
|
|
||
| def _cost_imbalance(self, packed_rows: list[dict]) -> float: | ||
| """Mean over microbatches of (max rank cost / mean rank cost), where a rank's cost is the | ||
| block-diagonal attention cost sum(seq_len**2) of its rows. |
There was a problem hiding this comment.
IIUC this PR only cares about DP ranks load balancedness, but not across PP ranks?
After #3856 (comment) and the PR, we should do microbatching in torchtitan when PP is enabled. In fact, we should think if it's possible to share batcher / utils between RL and supervised training.
Also check #3926 (comment)
There was a problem hiding this comment.
Current load balance is done in each row: We pack as balance as possible between each row. When split into microbatchs, you could directly chunk all packed rows without thinking about load balance again. The chunk happens in _build_microbatch_grid
Now the batcher sits on controller, and has the global view of the data packing and microbatch split. If PP is enabled, we can also split the packed_rows in _build_microbatch_grid() into microbatches of local_batch_size * dp_degree * pp_degree
In fact, we should think if it's possible to share batcher / utils between RL and supervised training
Agreed, we can start by sharing utils. And discussed with @felipemello1 , he pointed out the trainer dataloader is SPMD-ed, while the RL's batcher sit with global view and handles the load balancing, so they are naturally different
| best = 0 # fresh microbatch: every row empty, row 0 is lowest-cost | ||
| rows[best].append(training_sample) | ||
| row_len[best] += length | ||
| row_cost[best] += length * length |
There was a problem hiding this comment.
This is assuming quadratic full attention, but we are seeing
- linear attention
- sliding window attention, interleaved with full attention (but I guess this is fine because the sliding window layers shouldn't affect batching decision too much)
There was a problem hiding this comment.
That is true, the assumption is based on full attention. We should let user set the cost model given a seq_length.
ddf65c8 to
a71b70d
Compare
| local_batch_size: int = 8 | ||
| """Per-DP-rank microbatch size (rows per forward pass). If the number of tokens in the | ||
| rollouts exceed the number of rows*seq_len, a new microbatch is started. | ||
| If it is less, the remaining rows are padded to this size.""" | ||
| """Number of max-length sequences in each DP rank's token budget. | ||
|
|
||
| The model input is flat with shape ``[local_batch_size * seq_len]``. | ||
| """ | ||
|
|
||
| seq_len: int = 2048 | ||
| """Tokens per row (packed sequence length).""" | ||
| """Maximum length of one packed sequence.""" |
There was a problem hiding this comment.
@acisseJZhong pending refactor to remove BatchConfig
| for microbatch_assignments in assignments: | ||
| rank_costs = [ | ||
| sum( | ||
| self._sequence_costs( |
There was a problem hiding this comment.
didn't read too careful -- this function is called once during _assign_training_samples_to_microbatches, do we need to run it again for metrics logging?
a71b70d to
14a4be9
Compare
14a4be9 to
6a504cb
Compare
There was a problem hiding this comment.
Without considering attention load balancing across DP / CP, this sounds exactly the classic bin-packing problem. See https://en.wikipedia.org/wiki/Bin_packing_problem
Previously it was using
- Next Fit (NF): Try to put an item in your current active bag. If it does not fit, close that bag and start a new one.
This PR is changing it to
- First Fit Decreasing (FFD): Sort your items from largest to smallest. Place each item into the first available bag that has enough room. This method is fast and usually very close to the true minimum.
There's other simple heuristic like
- Best Fit (BF): Place the item in the bag that leaves the least amount of empty space leftover.
The problem itself is NP-hard, but could you do a brief survey and see what makes sense as a default good heuristic here? To clarify, I don't think we should spend too much energy on this version, because with load balancing concerns it sounds a more complex optimization problem.
cc @acisseJZhong @jinsooihm
There was a problem hiding this comment.
I'm sorry for the back-and-forth. Thought more about the problem.
There are two optimizations for the batcher: to not waste compute and to reduce load imbalance among microbatches (which helps when different DP ranks run different data, or when different PP microbatches are pipelined).
Reduce padding would help both, but that's only part of the picture.
Another (bigger) part is still load imbalance caused by attention layers. Here I'm not considering EP imbalance.
For attention, today's mixture would almost always be 1 full quadratic attention : ~3 sliding-window attention / linear attention. In this case, I'd assume
- claim/assumption 1: The imbalance of linear / sliding window doesn't seem to matter much compared with full quadratic, because of n^2 vs. 3n assuming documents are long.
- assumption 2: The load imbalance across CP currently is handled independently (@fegin has CP load balancer that works with fixed DP microbatches; linear attention CP seems scaling linearly without issue according to @drisspg).
Assuming intra-microbatch load balance is solved (which is strong assumption, but can be improved later), then to solve inter-microbatch load balance, we mostly only need to look at the full quadratic attention cost -- this is suggesting your initial direction should be what we pursue, namely the joint optimization
- reduce padding as much as possible
- use full quadratic attention as cost function (assuming CP's time is mostly spent on computation, and communication is not exposed much).
There was a problem hiding this comment.
For the bin-packing problem: Yes this a bin-packing problem and we set the cost model = length of the sequence. And in bin-packing problem (RL batcher), the number of bins is not fixed (in RL batcher, the number of microbatches is decided by how many rows we packed into). We want to minimize the number of bins because we want to minimize the padding.
- We don't have fixed number of bins because we define number of samples need to be consumed per RL train step, instead of define per RL step by consuming a global batch in trainer
- So RL is NOT only solving "inter-microbatch" load balancing problem
But in a "load balancing problem" not necessary need "non-fixed bin numbers". eg, the intra-microbatch load balancing problem usually given the microbatch_size so we fixed the number of bins, but try to balance sum_over_sequences(cost_function(sequence_length)): https://en.wikipedia.org/wiki/Largest_differencing_method
Thanks for make this super-crystal clear, I agree the batcher here have a mixed purpose of both now. And I don't know if I could make it jointly optimized for both goal at the same time, so I think using a reasonable (not optimal) algorithm is fine. Prime-RL and slime they converged to the same algorithm (so let's use this too)
- FFD packing: decide the total number of bins
- Round the bin count up to a multiple of the DP degree
- Estimate the workload of each packed bin = Sum(L^2)
- Karmarkar-Karp assign bins to different DP ranks, load balancing cross DP ranks
There was a problem hiding this comment.
What we need load balance:
- DP / PP / CP
- DP: all the concurrent running DP microbatch need to be load-balanced, nothing do to with spmd gradient accumlation (outer)
- Microbatch is direct goal to balance
- PP: need to handle inner gradient acc
- CP: Given DP split, Split in CP
There was a problem hiding this comment.
Could you say more -- are you trying to make bucket 1, bucket 2, bucket 3, ... balanced compared with each other in terms of sum(bucket workload), or are you trying to make rows with in each bucket balanced?
The former one. Yes this is not enough.. Let me update it and give another try:
The grid is updated to be: [number_of_outer_microbatchs(G)][PP_microbatchs(M)][DP_degree(D)]
The optimization goal is: We have total (GMD) rows already assigned,
- First and top goal: balance between intra-D group (all the rows with in the same D group)
- Second: balance between intra-M group
- Intra-G balance is not a goal
The updated algorithm is:
-
FFD to pack into flattened rows: each row have length Sum(L) <= T (L denotes each sequence's length)
-
Decide G for RL by G = ceil(num_rows / (D * M)), then round the total number of rows to a multiple of D*M by padding empty rows. So num_rows = G * D * M after padding.
-
Move some sequence from the row with largest workload to the padded empty row. <- This is heuristic
-
Recalculate each row’s workload:
W(row) = Σ L²
-
Sort all rows by workload in descending order.
-
Reshape directly into:[G][M][D]
with D as the innermost dimension:
grid[g][m][d] = sorted_rows[(g × M + m) × D + d]
Therefore:
- Adjacent D rows execute concurrently across DP replicas and have similar workloads.
- Adjacent M DP groups form one PP schedule and have similar workloads, reducing pipeline bubbles.
- Workload is not balanced across G; heavy outer groups and light outer groups execute sequentially.
-
Optionally rotate assignments within each D group so the same DP rank does not always receive the slightly heavier row.
There was a problem hiding this comment.
I think it makes sense.
In 6, maybe another possible heuristic is to zig zag assign?
Like if G, M = 2 and we had rows 10, 8, 6, 4, it would be better to do
10, 4 on rank 0 and 8, 6 on rank 1 than 10, 6 on rank 0 and 8, 4 on rank 1.
There was a problem hiding this comment.
@wwwjn regarding your 6
- intra D you are doing round-robin. It makes sense as you probably couldn't do any better because row has the most granular unit
- intra M it's still round-robin so you are not exploiting the inter-row freedom?
Assuming DP4, PP2 (2 microbatches), let's say there are 8 microbatches and the workload could be look like 0 -> 7.
Yours produces:
0, 1, 2, 3
4, 5, 6, 7
Jin Soo suggests we may do
0, 1, 2, 3
7, 6, 5, 4
The benefit is that sum(PP0 + PP1) across DP ranks can be reduced from 10 to 7. This is assuming reshard_after_forward=False.
There was a problem hiding this comment.
I see, thank you both for pointing out! Round-robin in both D and M dim doesn't make sense.
Jin Soo suggests we may do
0, 1, 2, 3
7, 6, 5, 4
I was thinking the load needs to be balanced cross PP microbatches, otherwise there are more PP bubbles. Eg in the above case, DP rank0 has PP microbatches 0 and 7, which means DP rank0 has huge PP bubbles
But I also agree the end-to-end step time of sum(PP0 + PP1) is smaller across all DP ranks, which is more important than bubbles
There was a problem hiding this comment.
I update the original step6 to be following:
- Sort all bins by workload in descending order.
- Partition the sorted bins into consecutive D-wide groups, so the D inputs executed concurrently have similar workloads.
- Reverse every other D-wide group. In a
[G][M][D]layout, this zig-zag pairs heavier and lighter PP microbatches on each replica.
6a504cb to
cb56d55
Compare
cb56d55 to
6462372
Compare
|
|
||
| # Step 3: prefer balanced LPT splits over fully padded bins. | ||
| self._expand_bins_by_splitting(bins, target_num_bins=target_num_bins) | ||
|
|
There was a problem hiding this comment.
I do not have a solution in mind for now, but just a note:
If we have bins
| bin 1 | bin 2 | bin 3 |
|---|---|---|
| 10, 10, 10, 10 | 10, 10, 10, 10 | 10, 10, 10, 10 |
and target_num_bins=4,
this will result in
| bin 1 | bin 2 | bin 3 | bin 4 |
|---|---|---|---|
| 10, 10, 10, 10 | 10, 10, 10, 10 | 10, 10 | 10, 10 |
but a better balance can be achieved by
| bin 1 | bin 2 | bin 3 | bin 4 |
|---|---|---|---|
| 10, 10, 10 | 10, 10, 10 | 10, 10, 10 | 10, 10, 10 |
There was a problem hiding this comment.
So there could be some choice to be made on splitting by considering only max candidate or some top candidates.
Other heuristic could be after we figure out target_num_bins from FFD, we do LPT on target_num_bins many empty bins?
There was a problem hiding this comment.
Yeah _expand_bins_by_splitting this is heuristic
Other heuristic could be after we figure out target_num_bins from FFD, we do LPT on target_num_bins many empty bins
I was thinking the same, but one caveat that I'm worried about is if do LPT again, we need to make sure all the items can still be packed into target_num_bins. Sometime if would failed when we re-pack using LPT into target_num_bins. A better alternative is we can always try to LPT into target_num_bins; if there's samples can not fit, we can fallback to this "split-heaviest-bin" idea.
eg, items = eight 3s and nine 2s
FFD uses 7 bins:
4 bins: [3, 3]
3 bins: [2, 2, 2]
Suppose DP rounding gives target_num_bins = 8. LPT across eight bins does:
[3], [3], [3], [3], [3], [3], [3], [3]
Then distributes eight 2s evenly:
[3,2], [3,2], [3,2], [3,2],
[3,2], [3,2], [3,2], [3,2]
Every bin now has only one token left, so the ninth 2 cannot fit, even though FFD packed everything into only seven bins.
There was a problem hiding this comment.
instead of splitting the single heaviest bin each time, you could do
- while you still need new bins to be filled
- create a new bin
- while the new bin is not full
- put a document from current heaviest bin into it (unless the current heaviest bin only had 1 document thus would be emptied)
You can use a heap to maintain this structure so dynamically taking current heaviest is cheap.
Caveat: be careful not to introduce dead loop.
| assert not cell.padding_mask[cell.loss_mask].any() | ||
|
|
||
|
|
||
| def test_batcher_uses_flat_rank_capacity_and_reports_padding_reduction() -> None: |
There was a problem hiding this comment.
some of the tests should go to rl/test_batcher.py
|
|
||
| # Step 3: prefer balanced LPT splits over fully padded bins. | ||
| self._expand_bins_by_splitting(bins, target_num_bins=target_num_bins) | ||
|
|
There was a problem hiding this comment.
instead of splitting the single heaviest bin each time, you could do
- while you still need new bins to be filled
- create a new bin
- while the new bin is not full
- put a document from current heaviest bin into it (unless the current heaviest bin only had 1 document thus would be emptied)
You can use a heap to maintain this structure so dynamically taking current heaviest is cheap.
Caveat: be careful not to introduce dead loop.
|
@claude review this PR
|
|
Claude finished @tianyu-l's task in 3m 21s —— View job Review: first-fit flat-token packing across DP ranks
What the code actually doesEntry point:
Does it make sense?The parts that are right:
The two real gaps are further up the pipeline. 1. (Major) The cost model ignores tail padding, and tail padding is quadratic attention too
Worked example with S=10240 and T=61440 (the PR's multi-row shape), cost measured in
Options:
2. FFD bins are very skewed, and only D-1 bins at most get rebalanced
Once
3. Smaller points
Summary
|
|
@wwwjn claude's points sound valid to me.
|
@claude review this code again. I've addressed @tianyu-l 's concern:
|
|
Claude finished @wwwjn's task in 4m 34s —— View job Re-review: LPT + padding-aware cost + greedy rank assignment
What the code does now (from
|
| bin 0 | bin 1 | max W |
|
|---|---|---|---|
This PR's LPT (sum(L^2) key) |
[S, S], 2S tokens → W = 2S² + 4S² = 6S² |
[S, 16×S/4], 5S tokens → W = S² + S² + S² = 3S² |
6S² |
Balanced by W |
[S, S, 8×S/4] → 2S² + 0.5S² + 2S² = 4.5S² |
[S, 8×S/4] → S² + 0.5S² + 3S² = 4.5S² |
4.5S² |
- That is a 25% lower critical path with the same grid and the same padding.
- In this case the PR's LPT gives bin 0 the same cost as an empty bin (
6S²). - Smaller version:
S=10, T=20, samples[10, 5, 5, 5, 5]. LPT gives[10] | [5,5,5,5], soW = 200 | 100. FFD alone gives[10,5,5] | [5,5], soW = 150 | 150. Here the LPT path is worse than the FFD path it replaced.
Suggested fix: keep LPT, but key it on padding-aware W and place each sample in the feasible bin with the highest current W.
- Adding a document never increases
W. With paddingP = qS + r, adding a document of lengthLchangesWby2(L-S)(L-r) ≤ 0whenL > r, and by2L(L-r) ≤ 0whenL ≤ r. - So this is standard LPT for jobs that reduce cost: the bin currently in the worst state gets the next reduction.
- Break ties by fewer tokens. Otherwise the all-empty start (every bin at
k·S²) and eachL = Splacement (Δ=0) will pile everything onto bin 0. - On the first example above, a hand trace of this gives
4.5S² | 4.5S². On the second it gives150 | 100, so the max of 150 matches FFD instead of 200. - It needs about four changed lines in
_pack_with_lpt. The FFD fallback is unchanged. - Please A/B it on your DAPO replay: report the within-row
(max W - min W) / max W, the LPT fallback rate, and thesum_g max_d Wcritical path.
2. Greedy vs zig-zag: take the better of the two
assign_sorted_bins_to_dp_ranks documents correctly that greedy can lose to zig-zag (the 192 vs 191 test).
- Both cost
O(M·D)per G step, so you can compute both assignments and keep the one with the lowermax_d sum_m W. - That result is never worse than either heuristic, and it removes the "not strictly better" caveat from the docstring.
- It's cheap and optional. It only matters once PP passes
num_pp_microbatches > 1; production uses the default M=1 today.
3. Baseline code kept only for the metric (same point as last round, still open)
_pack_one_training_batch (:258) runs the whole old policy every step: _assign_with_row_packing, _assign_training_samples_to_rows, and _fill_empty_rank_assignments, roughly 100 lines (:589-691).
- It isn't quite the pre-PR policy. Main's
_build_document_limited_microbatch_gridmoved a whole row from the first multi-row cell (donor.pop())._fill_empty_rank_assignmentsmoves the shortest sample from the cell with the most tokens. Sopadding_frac_before_load_balancecompares against a slightly improved baseline, not exactly whatmainshipped. This is minor for padding, but worth knowing when quoting "before" numbers. - The
_assign_training_samples_to_rowsdocstring says "for comparison and fallback" (:613), but it is never used as a fallback. - The metric name is still
padding_frac_before_load_balance(:816). It measures the next-fit packer, so a name likepadding_frac_next_fit_baselinewould be clearer. - I'd delete all of it once the replay numbers are in the PR, which they now are. If you want to keep one comparison signal, a cheap
train_batch/lpt_fallbackcounter (0 or 1) is more useful going forward. It tells you how often the FFD+split path actually runs.
4. Smaller points
_expand_bins_by_splitting(:495) is correct and terminates. Each successful move transfers one sample into the new bin, which is not in the heap while it is being filled, and skipped donors are only retried after a move.- It is
O(len(donor)^2)per pop, because of the slice plus_attention_workload. - It also re-pushes every skipped donor after each move.
- That's fine at the current scale (hundreds of samples, fallback path only). Just don't reuse it on a hot path.
- It is
_attention_workloadruns twice per bin (:417and:421). Compute the list once and sort indices. This is trivial.- The
num_pp_microbatcheskeyword exists only for tests right now. That's reasonable prep for PP. Just make sure the trainer's consumer of[G*M][D]gets the matching reshape when PP lands. - The cost model still assumes all-full-attention layers, as discussed with Tianyu. That's acceptable. A one-line TODO near
_attention_workloadabout hybrid SWA/linear models would help future readers.
Summary
- Merge-worthy structure: FFD for the bin count, then LPT on the same grid with an FFD fallback, padding-aware sort, and per-row rank assignment.
- One substantive change I'd make before landing: key LPT on padding-aware
W, placing each sample in the highest-Wfeasible bin with a fewest-tokens tie-break. As written, LPT optimizes a different objective from the one used to sort and assign bins. It can leave bins holding truncatedL = Sdocuments as expensive as empty bins, and can even do worse than plain FFD ([10,5,5,5,5]example). - Nice to have: best-of greedy/zig-zag for M>1, delete the baseline path, and add an LPT-fallback counter.
Pack variable-length training samples directly into each DP rank token budget using longest-first token-count balancing. Remove the architecture-specific cost-model concept, preserve padding masks and document limits, and report padding before and after load balancing.
cf47c68 to
eb18cc2
Compare
|
@claude Of course, this is assuming varlen attention kernel being used, but I think it's the correct default. |
|
Claude finished @tianyu-l's task in 1m 48s —— View job Padding cost vs. the varlen padding split in
|
tail P |
today (% S) |
equal split |
|---|---|---|
| 60 (empty bin) | 600 | 600 |
| 45 | 425 | 339 |
| 30 | 300 | 150 |
| 20 | 200 | 68 |
| 5 | 25 | 5 |
A mostly-full bin's padding drops from O(S^2) to roughly P^2/k. That wasted attention compute is removed on every step. Real tokens should be unaffected, because padding only attends to padding and is excluded from the loss. That still needs checking: with --debug.seed=42 --debug.deterministic, loss and grad_norm should be bit-identical.
The change is local to the batcher:
- In
_pack_training_samples, replaceindex % self.seq_lenwith resets at the equal-split boundaries. - Update
_attention_workloadto the newpad(P). - Update the positions example in the docstring (
[0,1,0,1,0,1,2,3]stays the same whenk=1).
3. This change breaks an assumption in the current LPT key
_pack_with_lpt places each sample in the feasible bin with the highest current W (:482-493). That rule is only safe when adding a document never increases W. This holds for today's % S layout, because a document just replaces part of a padding segment.
Under the equal-split model it no longer holds. Take S=10, k=6, tail P=20, and add a document with L=10:
- New cost:
100 + pad(10) - pad(20) = 100 + 18 - 68 = +50. - So
Wgoes up.
The general rule is place the sample in the feasible bin with the smallest W after placement (break ties by fewer tokens). This works whether W goes up or down, and it reduces to classic LPT when the change in W is the same for every bin. The per-candidate cost is O(1) if you track sum(L^2) and tokens for each bin. If you keep today's % S padding, the current key is fine.
Summary
- Nothing is wrong today.
_attention_workloadalready matches the varlen split atattention.py:646: padding segments of at mostS, a reserved budget ofceil(T/S)slots, and alignment padding folded into each document. - Suggested improvement (optional): split the tail evenly across all
ceil(T/S)reserved slots.- It needs no change to core metadata and only lowers padding attention cost.
- It does require updating
_attention_workloadand switching LPT to a min-post-placement key. - It could land in this PR or as a small follow-up, with a loss-equality check.
- Varlen as the default cost model is fine: flex document masking splits on the same position resets, so the same estimate applies.
tianyu-l
left a comment
There was a problem hiding this comment.
stamp to unblock, but see if you'd like to include some more improvements suggested by claude
The new batcher groups samples into different microbatches than the row-based next-fit packing, which changes fp32 reduction order in the loss and gradient accumulation. Per-token trainer logprobs are unchanged (bit_wise/logprob_diff/max stays 0), so step 1 differs only in the last bits and later on-policy steps diverge from the resulting ulp-level weight difference. Values are taken from the A10G CI run on eb18cc2.
What
Pack RL samples across the full token capacity of each DP-rank input instead of filling context-length rows first. FFD determines how many inputs are needed; padding-aware LPT tries to balance their attention work without increasing that count.
Let
Tbe token capacity per DP-rank input,Sthe maximum context length,Dthe DP degree, andMthe number of PP microbatches per scheduling step. FFD producesBbins, andG = ceil(B / (M * D))gives a complete[G][M][D]grid. The RL trainer currently usesM=1;M>1is exercised by CPU scheduling tests.For each training batch:
Bbins, respecting both token capacity andmax_num_documents. Retain the bins as a fallback.G * M * Dgrid slots; this fixes the padding budget for both packing paths.W = sum(L^2) + q * S^2 + r^2, whereq, r = divmod(T - sum(L), S). The existing padding segments and fixed-size varlen metadata are unchanged.Wand group adjacent bins intoD-wide rows consumed concurrently.Gstep, assign heavier bins in each row to DP ranks with lower accumulatedW; reset rank totals at the next step.M=1retains the original alternating rank order. This is a heuristic, not an optimality or zig-zag dominance guarantee.LPT and its FFD fallback have the same grid size, hence the same padding fraction. The full-attention cost estimate does not model EP imbalance, PP stage-specific work, or pipeline bubbles. Per-sample alignment and rank-tail padding remain marked in
padding_mask; tail positions wrap atSwithout adding padding documents.Batcher-only replay
Replay 20 steps of recorded Qwen3-4B DAPO Math prompt/completion token IDs and logprobs from
hamishivi/DAPO-Math-17k-Processed_filteredthrough the productionTrainingSampleBuilder(drop_zero_std_reward_groups=false) and the batcher. The recorder retained only the two extreme-reward siblings of eight per prompt, so this subset is not a representative complete rollout batch. The captured run (pr4356_native_3407a0c_run2) usedS=T=10,240, four groups per step, and DP=1; DP=2 and DP=4 below are batcher-only simulations, not RL training or GPU throughput. This is a different recorded run from the one used for earlier PR measurements; all numbers below were recomputed together after rebasing onmain(07b97cbfb).Wgap (before -> after)M=1critical path,sum_g max_d W(before -> after)S=T=10,240, 4 groups/step; 160 recorded samplesS=T=4,096, 8 groups/step, 32-document cap; 320 recorded samples"Before" is the actual rebased
mainnext-fit batcher; "after" is this PR. Weighted padding counts real tokens and allocated slots across all 20 steps. For both policies,Wis the sum of squared attention-segment lengths derived from the emittedpositions(including padding segments); the mean row gap averages(max_d W - min_d W) / max_d Wover DP rows. The critical-path proxy sums each row's maximum across all steps. Each emitted current-binWalso matches the scheduler's cost model. Of the padding-fraction metrics, onlytrain_batch/padding_fracremains logged; the old online baseline metric and packing path have been removed.On the newly packed bins in a separate
M=3CPU scheduling simulation, accumulated-cost greedy assignment beats zig-zag in 10/20 steps (10 ties) and 17/20 steps (3 ties), respectively. These examples have no regressions, but greedy does not dominate zig-zag in general. Median batcher-only CPU timings were 16.38 -> 15.84 ms/step and 16.93 -> 16.90 ms/step across three repetitions; the ranges overlap, so these timings do not establish a speedup. The replay script is local and is not committed.Tests
python -m pytest tests/unit_tests/rl/test_batcher.py tests/unit_tests/rl/test_bin_scheduler.py tests/unit_tests/rl/test_async_controller.py tests/unit_tests/cpu/test_varlen_attention.py -q(51 passed; local vLLM CUDA library path resolved).pre-commit --all-filesrun was not completed.