xai-org/x-algorithm · error · ValueError

concurrent_bytes must be > 0, got {concurrent_bytes}

Error message

concurrent_bytes must be > 0, got {concurrent_bytes}

What it means

ThrottledD2HArrayHandler throttles device-to-host transfers by limiting concurrent bytes, so a non-positive limit is meaningless and rejected in __init__. The value typically derives from save_concurrent_gb converted to bytes.

Source

Thrown at phoenix/xrex/utils/checkpointing.py:121

            save_concurrent_gb,
            _CHECKPOINTER_SAVE_CONCURRENT_GB,
        )
    return _CHECKPOINTER


class NoCompressionArrayHandler(ocp.type_handlers.ArrayHandler):
    def _get_json_tspec_write(self, *args, **kwargs):
        spec = super()._get_json_tspec_write(*args, **kwargs)
        for codec in spec["metadata"]["codecs"]:
            cfg = codec["configuration"]
            cfg["codecs"] = [c for c in cfg["codecs"] if c["name"] != "zstd"]
        return spec


class ThrottledD2HArrayHandler(ocp.type_handlers.ArrayHandler):
    def __init__(self, concurrent_bytes: int, **kwargs):
        if concurrent_bytes <= 0:
            raise ValueError(f"concurrent_bytes must be > 0, got {concurrent_bytes}")
        super().__init__(**kwargs)
        self._concurrent_bytes = concurrent_bytes

    def _addressable_nbytes(self, arr: jax.Array) -> int:
        total = 0
        for shard in arr.addressable_shards:
            if self._replica_id is None or shard.replica_id == self._replica_id:
                total += int(shard.data.nbytes)
        return total

    async def serialize(self, values, infos, args=None):
        args = args or [ocp.SaveArgs()] * len(values)
        if not values:
            return []

        batches: list[tuple[list, list, list]] = []
        cur_v: list = []
        cur_i: list = []

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Set save_concurrent_gb to a positive value (e.g. 2), or pass None to disable throttling entirely
  2. Check the conversion code that turns GB into concurrent_bytes for unit errors

Example fix

# before
checkpointer = get_checkpointer(save_concurrent_gb=0)
# after
checkpointer = get_checkpointer(save_concurrent_gb=2)  # or None to disable throttle
Defensive patterns

Strategy: validation

Validate before calling

if save_concurrent_gb is not None:
    assert save_concurrent_gb > 0, 'save_concurrent_gb must be positive or None'

Prevention

When it happens

Trigger: Constructing the handler with concurrent_bytes <= 0, e.g. save_concurrent_gb=0 or a negative value, or a bytes-conversion bug producing 0.

Common situations: Config with save_concurrent_gb: 0 meant to 'disable' throttling; integer underflow/unit conversion mistakes (GB vs GiB vs bytes).

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/7c19a4c43a35a058. Report an issue: GitHub.