Skip to content

refactor(rng): drop the always-default replacement parameter from ManagerRng.choice - #2626

Merged
TATP-233 merged 1 commit into
mainfrom
refactor/rng-choice-drop-replacement-param
Nov 19, 2026
Merged

TATP-233 merged 1 commit into
mainfrom
refactor/rng-choice-drop-replacement-param

Conversation

@TATP-233

Copy link
Copy Markdown
Collaborator

Summary

  • ManagerRng.choice drops the replacement parameter. Sampling was always with replacement — replacement=False raised NotImplementedError from the API's introduction (2026-09-30, 19a5160b) — so the parameter was a false promise that pushed discovery of the limitation to runtime.
  • Removes the NotImplementedError guard, the parameter, and the matching test assertion in tests/managers/test_rng.py. The docstring now states "sampling is always with replacement" explicitly.
  • This is contract narrowing, not a compat break: no in-repo caller (verified by full-repo grep including tests/scripts/docs) and no known downstream caller passes the argument; passing it now is a plain TypeError: unexpected keyword argument, the same failure surface as any unsupported kwarg.
  • Follow-up to the YAGNI discussion in ManagerRng.choice 的概率表校验是 host 读,阻断 sync-free step #2624; builds on the merged fix(rng): drop eager host validation in ManagerRng.choice to unblock sync-free hot paths #2625.

Linked Work

Validation

  • make test-all passed on the final local head before this PR was created or updated
  • Additional task-specific validation listed below

Commands actually run:

uv run pytest tests/managers/test_rng.py -q   # 15 passed
make check                                      # ruff/mypy/pyright clean (1 pre-existing pyright warning in untouched src/unilab/base/__init__.py)
make test-all                                   # exit 0

Impact

  • Backend impact: none
  • Platform impact: both
  • Training effect expected: no

Artifacts

  • W&B: n/a
  • benchmark result: n/a
  • video / screenshot: n/a
  • ONNX / checkpoint: n/a

Checklist

  • Added or updated tests where needed (removed the obsolete NotImplementedError assertion)
  • Updated docs if behavior or workflow changed (changelog Changed entry + docstring)
  • Linked the driving issue
  • Noted any follow-up work explicitly (none; broader YAGNI scan of the repo is tracked separately by the maintainer)

…agerRng.choice

ManagerRng.choice only ever supported sampling with replacement
(replacement=False raised NotImplementedError from the API's introduction),
so the parameter misled callers into discovering the limitation at runtime.
The narrower signature makes the with-replacement-only contract explicit and
removes the NotImplementedError guard plus its test assertion. No in-repo or
known downstream caller passed the argument.

Follow-up to #2624, building on #2625.
@TATP-233
TATP-233 merged commit 1eb8e91 into main Nov 19, 2026
11 of 12 checks passed
@TATP-233
TATP-233 deleted the refactor/rng-choice-drop-replacement-param branch November 19, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant