xai-org/x-algorithm · error · ValueError
window_ms must be >= 0, got {window_ms}
Error message
window_ms must be >= 0, got {window_ms} What it means
delays_to_labels() converts raw int64 delay values into boolean labels: delay in [-?, window_ms] via (delays >= 0) & (delays <= window_ms). A negative window_ms is nonsensical (it would make the label always false), so it is rejected up front with ValueError.
Source
Thrown at phoenix/xrex/data/conversion_labels.py:140
delays = (
delays_col.flatten()
.to_numpy(zero_copy_only=False)
.astype(np.int64)
.reshape(batch.num_rows, delays_col.type.list_size)
)
if delays.shape[1] != seq_len:
raise ValueError(f"{name}: seq len {delays.shape[1]} != multi-hot {seq_len}")
bits[:, :, idx] = np.where(
is_candidate, delays_to_labels(delays, window_ms), bits[:, :, idx]
)
inner = pa.FixedSizeListArray.from_arrays(pa.array(bits.reshape(-1)), vocab)
outer = pa.FixedSizeListArray.from_arrays(inner, seq_len)
return batch.set_column(col_idx, batch.schema.field(col_idx), outer)
def delays_to_labels(delays: np.ndarray, window_ms: int) -> np.ndarray:
if window_ms < 0:
raise ValueError(f"window_ms must be >= 0, got {window_ms}")
return (delays >= 0) & (delays <= window_ms)
View on GitHub (pinned to 24c60942c5)
Solutions
- Set window_ms to a non-negative integer (milliseconds).
- Validate/compute the window with max(0, end - start) if derived from timestamps.
- Add a config assertion before training starts.
Example fix
// before labels = delays_to_labels(delays, window_ms=duration_ms_negative) // after labels = delays_to_labels(delays, window_ms=max(0, duration_ms))
Defensive patterns
Strategy: validation
Validate before calling
if not isinstance(window_ms, int) or window_ms < 0:
raise SystemExit(f'invalid window_ms: {window_ms!r}') Type guard
def is_valid_window(w) -> bool:
return isinstance(w, int) and w >= 0 Try / catch
try:
labels = delays_to_labels(delays, window_ms)
except ValueError as e:
raise ConfigError(str(e)) from e Prevention
- Validate window_ms once in config loading with pydantic/JSON-schema constraints.
- Compute windows as max(0, end_ms - start_ms).
When it happens
Trigger: Calling delays_to_labels(delays, window_ms=-1); passing a window computed as end-start that underflowed negative; config typo making conversion_window_ms negative; fold_action_delays_into_multihot propagating a bad window_ms.
Common situations: Misconfigured hyperparameter (sign error); arithmetic producing negative deltas; CLI arg parsing '-w 3600' vs intended positive value.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- k ({k}) must be <= n ({n})
- valid_block_upper and valid_block_lower must be provided tog
- {name}_block_cnt and {name}_block_idx must both be provided
- not a partition batch file path: {batch_file_path}
- not a parquet path: {batch_file_path}
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/d365fe62c3c5877a.
Report an issue: GitHub.