-
Notifications
You must be signed in to change notification settings - Fork 7.7k
[feat] add small vocab table for eagle's draft model[1]. #3822
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
Changes from 9 commits
707ddff
372222f
2cc3e2b
e5b2bfa
16d71a7
5fc7af5
6c738ea
06354e5
4f9b1eb
24e0b52
99c0ad0
d7f8f9e
c012426
111ca86
1a5aad8
cd9b2a7
016d820
4faf14a
4e93386
d887668
b421309
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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -44,6 +44,18 @@ def __init__( | |||||||||||||||
| # We will capture it later | ||||||||||||||||
| backup_disable_cuda_graph = server_args.disable_cuda_graph | ||||||||||||||||
| server_args.disable_cuda_graph = True | ||||||||||||||||
|
|
||||||||||||||||
| if server_args.speculative_token_map is not None: | ||||||||||||||||
| try: | ||||||||||||||||
| self.hot_token_id = torch.load(server_args.speculative_token_map) | ||||||||||||||||
| except: | ||||||||||||||||
| raise RuntimeError( | ||||||||||||||||
| f"there is not hot_token_ids.pt file in {self.server_args.speculative_token_map}" | ||||||||||||||||
| ) | ||||||||||||||||
| server_args.json_model_override_args = ( | ||||||||||||||||
| f'{{"hot_vocab_size": {len(self.hot_token_id)}}}' | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| super().__init__( | ||||||||||||||||
| gpu_id=gpu_id, | ||||||||||||||||
| tp_rank=tp_rank, | ||||||||||||||||
|
|
@@ -66,6 +78,14 @@ def __init__( | |||||||||||||||
| # Share the embedding and lm_head | ||||||||||||||||
| if not self.speculative_algorithm.is_nextn(): | ||||||||||||||||
| embed, head = self.target_worker.model_runner.model.get_embed_and_head() | ||||||||||||||||
| if server_args.speculative_token_map is not None: | ||||||||||||||||
| head = head.clone() | ||||||||||||||||
| self.hot_token_id = torch.tensor( | ||||||||||||||||
| self.hot_token_id, dtype=torch.int32, device=head.device | ||||||||||||||||
| ) | ||||||||||||||||
| head.data = head.data[self.hot_token_id] | ||||||||||||||||
| else: | ||||||||||||||||
| self.hot_token_id = None | ||||||||||||||||
| self.model_runner.model.set_embed_and_head(embed, head) | ||||||||||||||||
| self.model_runner.server_args.disable_cuda_graph = backup_disable_cuda_graph | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -223,6 +243,11 @@ def draft_forward(self, forward_batch: ForwardBatch): | |||||||||||||||
| spec_info.topk_index, | ||||||||||||||||
| spec_info.hidden_states, | ||||||||||||||||
| ) | ||||||||||||||||
| topk_index = ( | ||||||||||||||||
| self.hot_token_id[topk_index] | ||||||||||||||||
| if self.hot_token_id is not None | ||||||||||||||||
| else topk_index | ||||||||||||||||
| ) | ||||||||||||||||
|
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.
Suggested change
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. @Zhou-sx I addressed this and created a PR to your branch. |
||||||||||||||||
|
|
||||||||||||||||
| # Return values | ||||||||||||||||
| score_list: List[torch.Tensor] = [] | ||||||||||||||||
|
|
@@ -262,6 +287,11 @@ def draft_forward(self, forward_batch: ForwardBatch): | |||||||||||||||
| ) | ||||||||||||||||
| probs = torch.softmax(logits_output.next_token_logits, dim=-1) | ||||||||||||||||
| topk_p, topk_index = fast_topk(probs, self.topk, dim=-1) | ||||||||||||||||
| topk_index = ( | ||||||||||||||||
| self.hot_token_id[topk_index] | ||||||||||||||||
| if self.hot_token_id is not None | ||||||||||||||||
| else topk_index | ||||||||||||||||
| ) | ||||||||||||||||
|
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. same here |
||||||||||||||||
| hidden_states = logits_output.hidden_states | ||||||||||||||||
|
|
||||||||||||||||
| return score_list, token_list, parents_list | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot use the generated output to accelerate the generation, similar to analyzing the test dataset beforehand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait a moment, I'll link my processing script later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know. I just introduction the method. The division of training and testing sets is completed by users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a PR to your branch @Zhou-sx.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for your modification.