Skip to content

fix: make benchmark-set option restore safe for unknown ids and selection bounds - #1180

Open
anhappdev wants to merge 2 commits into
masterfrom
fix/benchmark-set-option-persistence
Open

anhappdev wants to merge 2 commits into
masterfrom
fix/benchmark-set-option-persistence

Conversation

@anhappdev

@anhappdev anhappdev commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #1185, which fixed "LLM only → restart → Image Classification v2 runs" by recomputing isActive after the stored options are restored. This PR fixes the three defects #1185 left as FIXMEs, each with a test, and adds regression tests for the restart bug itself.

  • A stored option id missing from the config breaks config load. optionSets[optionMap[entry.key]!] throws, which happens whenever a tasks.pbtxt update renames or drops a visible option. Startup catches the error but never clears the stored state, so the app shows the resource-error screen on every launch until app data is wiped. Unknown ids are now logged and skipped.
  • BenchmarkOptionSet.selected was frozen at construction, so min_selected/max_selected checked a stale count: with max_selected: 1 you could never swap the chosen option. The count now tracks set and unset.
  • Applying a stored state entry by entry made the result depend on map order under a min/max bound. Each option set is now applied atomically, rejected whole if it would break its bounds.

The last two are latent: no shipped config sets either bound.

The stored state also now goes to the BenchmarkSet constructor, so it is in place before the first applyOptions(), and the UI toggle goes through the same applyOptionStateMap() path.

80 unit tests pass (10 new), no new flutter analyze issues. The benchmark-set UI/UX rework follows in its own PR.

…arks

BenchmarkStore restored the saved option state *after* each BenchmarkSet
constructor had already derived isActive from the pbtxt defaults, and never
recomputed it. The options themselves were restored, so the UI looked right,
but activeBenchmarks still reflected the defaults.

Picking "LLM only" and restarting therefore ran the two Image Classification
v2 benchmarks: image_classification ships offline+online enabled, while every
llm parameter option ships disabled.

The state is now handed to the BenchmarkSet constructor so it is in place
before the first applyOptions(), and applyOptionStateMap() always ends by
recomputing isActive, so the two can no longer drift apart.

Three related defects in the same path, each covered by a test:

- BenchmarkOptionSet.selected was fixed at construction, so min_selected /
  max_selected were enforced against a stale count. With max_selected: 1 that
  made it impossible to swap the chosen option. No shipped config sets either
  bound today, so this was latent.
- An option id in the stored state that no longer exists in the config threw
  on a null unwrap, which would break config loading after an upgrade that
  renames or drops an option. It is now logged and skipped.
- Applying a stored state entry by entry made the outcome depend on map order
  under a min/max constraint. Each option set is now applied atomically and
  rejected as a whole if it would violate its bounds.
@anhappdev
anhappdev requested a review from a team as a code owner September 22, 2026 06:08
@github-actions

Copy link
Copy Markdown

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

@freedomtan

Copy link
Copy Markdown
Contributor

Let's wait for @farook-edev's one.

@freedomtan

Copy link
Copy Markdown
Contributor

let's rebase this after the #1185 merged.

anhappdev pushed a commit that referenced this pull request Oct 7, 2026
This PR adds missing line to properly apply benchmark set options after
loading them from preferences (on app reopening)

it supersedes #1180

it includes FIXME notes for a couple other bugs that aren't affecting
the app currently, but will if we use min/max or incorrect option ID
logic.
…ption-persistence

Resolve the conflict with #1185 in favour of this branch: applyOptionStateMap keeps the grouped, null-safe restore, and both FIXMEs from #1185 are dropped since this branch fixes what they describe.
@anhappdev anhappdev changed the title fix: apply stored benchmark-set options before deriving active benchmarks fix: make benchmark-set option restore safe for unknown ids and selection bounds Oct 7, 2026
@sonarqubecloud

sonarqubecloud Bot commented Oct 7, 2026

Copy link
Copy Markdown

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.

2 participants