[bugfix]: balance Flex calibration shards across resolutions

This commit is contained in:
Aryan Kumar
2026-10-29 23:45:56 -07:00
parent 13d21947b3
commit c96df0af5f
@@ -248,8 +248,12 @@ def _dp() -> tuple[int, int]:
def _shard(rows: list[Any], shard: int, num_shards: int) -> list[Any]:
"""This group's rows; striding a hash order keeps resolutions mixed (the plan alternates 480p / 768p groups)."""
import hashlib
dp_rank, dp_size = _dp()
return rows[shard * dp_size + dp_rank::num_shards * dp_size]
ordered = sorted(rows, key=lambda row: hashlib.sha256(row.id.encode()).hexdigest())
return ordered[shard * dp_size + dp_rank::num_shards * dp_size]
def _is_writer() -> bool: