Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: search results - evaluation and results processing #249

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

gabikadlecova
Copy link
Collaborator

Reference Issues/PRs

#230 + additional features in the search process

What does this implement/fix? Explain your changes.

  • implement parameter bins to search in a stratified way over the min-max param range
  • qol improvements in search
    • add objective names to logging (instead of objective_1, objective_2)
    • save the pareto front paths to a json
    • allow different secondary objectives (parameters, flops, latency)
    • test saving and loading of the extracted subnetwork config
  • fix devices for flops/latency to allow integration into the search
  • implement the evaluation workflow
    • use lm_eval_harness to evaluate a litgpt (sub-)network checkpoint
    • script for collecting the results in a given directory
    • script for plotting the collected results

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

@gabikadlecova gabikadlecova changed the title Search results - evaluation and results processing feat: Search results - evaluation and results processing Feb 11, 2025
pyproject.toml Outdated
@@ -21,7 +21,8 @@ dependencies = [
"torchvision>=0.18",
"boto3==1.34.147",
"botocore==1.34.147",
"deepspeed"
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe let's revert this here and rather merge the main branch once #248 is in

"runtime": runtime[-1],
}

print(observation)
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove print

Copy link
Collaborator

Choose a reason for hiding this comment

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

This file seems somewhat specific to our paper. Should we have that in a separate repo?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems also specific to our experiments. Maybe move that in a separate repo?



@dataclass
class ParamBinArgs:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't that be part of SearchArgs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can imagine that you'll use binning outside of search (e.g. for pre-selection of networks to evaluate). But I can add it to SearchArgs

@@ -19,6 +20,9 @@ def multi_objective_search(
objective_kwargs: Optional[dict[str, Any]] = None,
logger: Optional[Logger] = None,
seed: Optional[int] = None,
param_bins: Optional[ParamBins] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am wondering if it wouldn't be cleaner to have this in the search method instead of the objective? We could have a something like stratified random search that samples sub-networks uniformly across parameter count instead of uniformly from the search space. Wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, great idea

@@ -15,6 +15,7 @@ def compute_flops(
batch_size: int = 1,
Copy link
Collaborator

Choose a reason for hiding this comment

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

same nitpick as above

Comment on lines 1 to 5
import torch
import torch.profiler
from torch.profiler import record_function
from typing import Optional

Copy link
Collaborator

Choose a reason for hiding this comment

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

import sorting

Comment on lines 1 to 5
import json
import pandas as pd
from pathlib import Path
from tqdm import tqdm
from typing import Optional, Any
Copy link
Collaborator

Choose a reason for hiding this comment

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

import sorting

Comment on lines 33 to 37
def setup(
results_dir: Path,
output_path: Optional[Path] = None,
pareto_path: Optional[Path] = None,
) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above

Comment on lines 1 to 5
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
from pathlib import Path
from typing import Optional
Copy link
Collaborator

Choose a reason for hiding this comment

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

import sorting

@gabikadlecova gabikadlecova changed the title feat: Search results - evaluation and results processing feat: search results - evaluation and results processing Feb 12, 2025
Comment on lines 41 to 44
bins, _ = (
param_bins(10, 2, 1) if search_strategy == "stratified_random_search" else None
)

Copy link
Collaborator

@timurcarstensen timurcarstensen Feb 13, 2025

Choose a reason for hiding this comment

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

Suggested change
bins, _ = (
param_bins(10, 2, 1) if search_strategy == "stratified_random_search" else None
)
bins, _ = (
param_bins(10, 2, 1)
if search_strategy == "stratified_random_search"
else (None, None)
)

Copy link
Collaborator

Choose a reason for hiding this comment

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

else this will throw an error

… both litgpt-like checkpoints and whittle subnets. Fix bins in test.
Comment on lines 82 to 86
metrics["flops"] = compute_latency(model)
if measure_latency:
metrics["latency"] = compute_flops(
model, batch_size=latency_batch_size, previous_device=device
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

flops and latency functions are switched

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice catch!

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.

3 participants