IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Python function

balanced_packing

balanced_packing()​

max.pipelines.lib.eplb_rebalance.balanced_packing(weight, num_packs)

source

Pack n weighted objects into num_packs packs evenly.

Each pack contains exactly n / num_packs objects, with weights balanced as much as possible by greedy assignment.

Parameters:

  • weight (ndarray[tuple[Any, ...], dtype[float64]]) – [X, n] weight per item.
  • num_packs (int) – number of packs.

Returns:

[X, n] int64 — pack assignment per item. rank_in_pack: [X, n] int64 — position within the pack.

Return type:

pack_index