-
Notifications
You must be signed in to change notification settings - Fork 375
SpecDec Bench Tweaks #939
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
SpecDec Bench Tweaks #939
Changes from 5 commits
0dd6a30
3bbf4c0
e06d926
6c5c507
3c328bf
6da6828
9c78b75
8815a70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
|
|
||
| # SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from datasets import load_dataset | ||
|
|
||
| from .base import Dataset, Request | ||
|
|
||
| def format_prompt(prompt: str) -> str: | ||
| return "Complete the following Python function. Only output the code, no explanations.\n\n" + prompt | ||
|
|
||
| class HumanEval(Dataset): | ||
| def __init__(self, path, num_samples=164, **kwargs): | ||
| self.data: list[Request] = [] # list of list of questions. | ||
| self.num_samples = num_samples | ||
| self._preprocess(path) | ||
|
|
||
| def _preprocess(self, path: str): | ||
| dataset = load_dataset(path, split='test') | ||
| for item in dataset: | ||
| self.data.append(Request(system_prompt=None, turns=[format_prompt(item["prompt"])])) | ||
| self.data = self.data[: self.num_samples] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,10 @@ def process_final(self, text_outputs): | |
| for request_id, turns in self.prompt_ar.items(): | ||
| self.out["Request_AR"][request_id] = {} | ||
| for turn_id, turn in turns.items(): | ||
| if len(turn) > 1 and turn[0] <= 1: | ||
| turn = turn[1:] # Skip prefill if it is 1 or less, indicating no specdec | ||
| if len(turn) > 1: | ||
| turn = turn[:-1] # Skip final acceptance due to EOS truncating speculation | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only skip if EOS is present?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's reasonable to skip anyways, since truncation for any reason (EOS, length, stop token) might misrepresent the AR since it is not aligned with the draft size per step |
||
| ar = sum(turn) / len(turn) | ||
| self.out["Request_AR"][request_id][turn_id] = ar | ||
| all_ar.append(ar) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.