Skip to content

window-union: a valid placement with no host selections divides by zero #656

Closed

Description

@Burntgogi

Problem

A valid placement that leaves no selected expert on the host makes tools/ref/window-union.py terminate with ZeroDivisionError while printing its prediction column.

Observed on unchanged main 69b66367 and on my #637 placement-input branch. This is separate from the negative/duplicate input and exception-identity fixes; those do not change the report arithmetic.

Reproduction (Python 3, no model or GPU)

python3 - <<'PY'
import importlib.util, pathlib, subprocess, sys, tempfile
spec = importlib.util.spec_from_file_location("wu", "tools/ref/window-union.py")
wu = importlib.util.module_from_spec(spec)
spec.loader.exec_module(wu)
with tempfile.TemporaryDirectory() as root:
    trace = wu._fake_set(root, "set", {0: [(3, 7)] * 8, 1: [(3, 7)] * 8}, 16, 2)
    result = subprocess.run([sys.executable, "tools/ref/window-union.py", trace,
                             "--n-l", "spread:32@0-1", "--k", "2"])
    raise SystemExit(result.returncode)
PY

The placement admits 16 experts on each of two layers, all within the valid range. The command prints host slots per row 0.0 of 4, then exits 1 with ZeroDivisionError: float division by zero.

Cause / expected behavior

report, at the pinned main unconditionally formats pu / ps; ps is zero when there are no host selections. The adjacent summary already treats undefined ratios as NaN. The report should represent the no-host-work case explicitly, rather than crash or pretend a meaningful ratio was measured. A no-host-selection case can also arise without every expert being card-resident.

The separate #637 work remains limited to its three claimed CPU-tool items. No performance or NVIDIA execution claim.

Activity

  1. Burntgogi commented on Oct 22, 2026

    @Burntgogi
    ContributorAuthor

    I will take this report-only boundary fix. I will keep the no-host-work ratio representation consistent with the existing summary contract, preserve nonzero-work results, and cover the real CLI. This is separate from the placement-input validation in #659; no GPU or model is needed.

  2. Burntgogi commented on Oct 22, 2026

    @Burntgogi
    ContributorAuthor

    Implemented in #663. Zero-host predictions use the existing nan convention; actual zero work remains 0.0. The adjacent empty-window denominator is handled as well. Numeric report regressions and actual CLI checks pass; four positive-work controls are unchanged, and the five owning T0/static checks are green. Placement parsing remains separate in #659.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions