Skip to content

Feature Election contribution#3876

Open
christofilojohn wants to merge 196 commits intoNVIDIA:mainfrom
christofilojohn:main
Open

Feature Election contribution#3876
christofilojohn wants to merge 196 commits intoNVIDIA:mainfrom
christofilojohn:main

Conversation

@christofilojohn
Copy link

Fixes
Implemented all the changes you requested on file format, tests etc. black-check, isort-check, flake8 pass.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Quick tests passed locally by running ./runtest.sh.
  • In-line docstrings updated.
  • Documentation updated.

christofilojohn and others added 30 commits November 2, 2025 13:10
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Removed leftover testing code

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

13 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

13 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@chesterxgchen
Copy link
Collaborator

/build

christofilojohn and others added 3 commits March 13, 2026 18:20
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…ting on training data

Might further simplify in the future
christofilojohn and others added 3 commits March 13, 2026 18:34
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
executor.py: _handle_apply_mask now sets self.global_feature_mask = mask before slicing X_train/X_val, so the executor's state stays consistent with the data that's actually loaded.
controller.py: _aggregate_weights condition simplified from if total_samples > 0 and weighted_weights is not None: to just if total_samples > 0:, removing the dead check (weighted_weights is initialised as {} and is never None).
job.py: n_repeated default (both in the function signature and the argparse default) corrected from 30 to 10, matching prepare_data.py and client.py. Previously, running job.py and prepare_data.py with all defaults would generate inconsistent datasets.
feature_election.py: remaining_X removed from the unpacking at the start of the stratified split loop — it was assigned X and never touched again, leaving a confusing dangling reference.
feature_election.py — NumPy >= 2.0 JSON serialization (save_results): reduction_ratio and freedom_degree in election_stats are wrapped with float(), tuning_history tuples are cast to (float, float), and the election_stats dict comprehension now handles np.floating scalars alongside np.ndarray. The top-level freedom_degree in save_results is also cast to float since it can be np.float64 after auto-tuning sets it from np.clip(...).
controller.py — NumPy >= 2.0 JSON serialization (stop_controller): self.freedom_degree is wrapped with float() before writing to feature_election_results.json at workflow teardown. Without this, auto-tuned runs would silently fail to save results.
feature_election.py — Missing stratification in simulate_election train/val split: Now mirrors the _safe_train_test_split pattern from prepare_data.py — tries stratify=y_np first, falls back to a plain random split if any class has fewer than 2 samples. This is especially important for Dirichlet-split data where class distributions can be highly skewed.

controller.py — FedAvg denominator corruption on weight mismatch
total_samples += n ran unconditionally even when a client's weights were skipped due to a shape or key mismatch. This meant the final division v / total_samples under-weighted all valid clients. The fix validates every key for a client before doing any accumulation, and only counts that client's samples if all keys passed.
feature_election.py — eval_metric silently ignored
FeatureElection.__init__ had no eval_metric parameter, so both simulate_election (executor creation) and create_flare_job (generated client config) hardcoded "f1". Any user passing eval_metric="accuracy" to quick_election or FeatureElection would have it silently discarded. The fix adds eval_metric to __init__ (with validation), stores it as self.eval_metric, wires it through simulate_election and create_flare_job, and persists/restores it in save_results/load_results.
christofilojohn and others added 2 commits March 13, 2026 18:57
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@chesterxgchen
Copy link
Collaborator

/build

@chesterxgchen
Copy link
Collaborator

@greptileai

@chesterxgchen
Copy link
Collaborator

/build

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