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

Fix input_ids always on cpu issue #270

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/lemonade/tools/humaneval.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def run(
k_samples,
timeout,
model_results_dir,
state.device,
first_n_samples,
)

Expand Down Expand Up @@ -153,6 +154,7 @@ def _evaluate_model(
k_samples: int,
timeout: float,
results_dir: str,
device: str,
first_n_samples: Optional[int] = TOTAL_PROBLEMS,
) -> Dict[str, float]:
"""
Expand Down Expand Up @@ -198,7 +200,9 @@ def _evaluate_model(
expected = dataset[task_id]["canonical_solution"]

# Generate completion
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this change going to break the OGA tools? I don't know if OGA's input_ids support the .to() method or not.

We should add a test that loads an OGA model and passes it to humaneval (opened issue #271).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I am not sure, need to test

Copy link
Collaborator

@jeremyfowers jeremyfowers Jan 18, 2025

Choose a reason for hiding this comment

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

I just opened PR #272 which adds a test for OGA that invokes humaneval: https://github.com/onnx/turnkeyml/actions/runs/12839092461/workflow?pr=272

You can try that if you want to make sure OGA will still work.

device
)
completion = model.generate(
input_ids,
max_new_tokens=512,
Expand Down
4 changes: 3 additions & 1 deletion src/lemonade/tools/mmlu.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ def run(
prompt = _gen_prompt(dev_df, subject, ntrain) + _format_example(
test_df, i, include_answer=False
)
input_ids = tokenizer(prompt, return_tensors="pt").input_ids
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(
state.device
)

response_text = _generate_response(tokenizer, model, input_ids)
try:
Expand Down
Loading