Skip to content

Fix: Issue 349 open flag recognition#352

Open
idevasena wants to merge 2 commits intomlcommons:mainfrom
idevasena:fix/issue-349-open-flag-recognition
Open

Fix: Issue 349 open flag recognition#352
idevasena wants to merge 2 commits intomlcommons:mainfrom
idevasena:fix/issue-349-open-flag-recognition

Conversation

@idevasena
Copy link
Copy Markdown
Contributor

Problem

Running mlpstorage training run --open ... produces the warning "Running the benchmark without verification for open or closed configurations" and --open-allowed parameter overrides (e.g. dataset.num_files_train=425000) are rejected, which later causes an assert num_subfolders == len(filenames) crash inside DLIO.

Root cause

Two linked bugs:

  1. mlpstorage_py/cli/common_args.py (lines 211–224)--open was defined with action="store_false", dest="closed", so passing --open produced the exact same Namespace as passing nothing at all (args.closed=False, no args.open attribute). There was no way for downstream code to distinguish the two cases.

  2. mlpstorage_py/benchmarks/base.py line 789 — the guard if not self.args.closed and not hasattr(self.args, "open") used hasattr on an attribute that was never created, making it equivalent to if not self.args.closed:. That routed --open into the "no verification" warning branch and skipped formal verification entirely. The DLIO crash is the downstream symptom of the override never being accepted.

Fix

  • cli/common_args.py: --open now has its own dest="open" with action="store_true". Both flags are independent booleans, both default False, still mutually exclusive.
  • benchmarks/base.py: verify_benchmark() uses getattr for both flags; "no verification" warning now fires only when neither flag is passed. The OPEN-allowed branch is correctly gated on open_mode rather than the ambiguous self.args.closed == False.
  • benchmarks/kvcache.py: verification now triggers for --open as well as --closed.

Tests

New file: mlpstorage_py/tests/test_open_closed_flag_recognition.py — 11 regression tests pinning:

Legacy tests/unit/test_benchmarks_base.py fixtures updated to match the new Namespace shape. Notably, test_allows_open_with_open_flag now actually exercises --open (setting args.open=True) rather than accidentally accepting closed=False as a proxy.

Test results

pytest mlpstorage_py/tests/: 112 passed → 123 passed on clean main .
Zero new regressions.

Fixes #349

Devasena Inupakutika added 2 commits April 27, 2026 02:21
The `--open` flag was silently ignored because of two intertwined bugs:

1. CLI parser: `--open` was defined with `action="store_false", dest="closed"`,
   which meant passing `--open` produced the exact same Namespace as passing
   nothing (`args.closed=False`, no `args.open` attribute). Callers had no
   way to tell the two cases apart.

2. verify_benchmark() in benchmarks/base.py: the guard
   `if not self.args.closed and not hasattr(self.args, "open"):`
   used hasattr on an attribute that was never created, so it was equivalent
   to `if not self.args.closed:`. Running with `--open` therefore routed
   through the 'Running the benchmark without verification for open or closed
   configurations' warning branch and skipped formal verification entirely.

As a downstream consequence, overrides legitimate under OPEN (e.g.
`dataset.num_files_train=425000` in mlcommons#349) were never accepted and the run
crashed inside DLIO on a `num_subfolders == len(filenames)` assertion.

Fix:

* common_args.py: give `--open` its own `dest="open"` with
  `action="store_true"`. `--open` and `--closed` are now independent
  booleans, both default False, still mutually exclusive.
* benchmarks/base.py: use `getattr(self.args, 'open'/'closed', False)`; the
  'no verification' warning now fires only when *neither* flag is passed.
  The OPEN-allowed branch is now correctly gated on `open_mode` rather than
  the ambiguous `self.args.closed == False`.
* benchmarks/kvcache.py: verification now triggers for `--open` too, not
  just `--closed`.
* Adds mlpstorage_py/tests/test_open_closed_flag_recognition.py — 11 tests
  pinning (a) CLI parser produces distinguishable `open`/`closed`/neither
  namespaces, (b) verify_benchmark routes each case correctly, (c) kvcache
  guard fires for both submission flags.
…tics

Follow-up to the mlcommons#349 fix. These tests currently cannot execute on main
because they import `mlpstorage.benchmarks.base` instead of
`mlpstorage_py.benchmarks.base` (broader package-rename migration that
lives outside this PR). But once that import issue is resolved, the test
logic should already be correct for the post-fix behavior:

* The `benchmark` fixture now sets `open=False` alongside `closed=True`
  so the Namespace matches what the fixed argparse definition produces.
* `test_exits_for_open_when_closed_required` — explicit `open=False`.
* `test_allows_open_with_open_flag` — now sets `open=True` (rather than
  just `closed=False`, which the pre-fix code accepted only by accident).
* `test_returns_true_with_closed_false_no_open_attr` renamed to
  `test_returns_true_with_neither_flag_set` and updated: both `closed`
  and `open` are explicitly `False`, matching the new parser defaults.
* `test_full_workflow` fixture gets `open=False` for consistency.

No test expectations are weakened; the only semantic change is
`test_allows_open_with_open_flag`, which now actually exercises --open.
@idevasena idevasena requested a review from a team April 27, 2026 03:04
@github-actions
Copy link
Copy Markdown

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

Copy link
Copy Markdown
Contributor

@FileSystemGuy FileSystemGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review: @russfellows

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.

Running training with --open doesn't seem to be recognized

2 participants