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

[Bugfix] Fix incorrect updates to num_computed_tokens in multi-step scheduling #9038

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
review comments
  • Loading branch information
Varun Sundar Rabindranath committed Oct 4, 2024
commit 76d3e24fa598c691c98b6f1bcb6c9c454c4a4715
8 changes: 5 additions & 3 deletions tests/core/test_num_computed_tokens_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,21 @@ def test_num_computed_tokens_update(num_scheduler_steps: int,
engine.step()

if not seq.is_finished():
assert seq.data.get_num_computed_tokens(
) == prompt_len + num_prompt_steps - 1

prompt_num_computed_tokens = seq.data.get_num_computed_tokens()
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: merge this call with line 58 so we only call get_num_computed_tokens once.

# Test correctness of num_computed_tokens after the prompt steps
assert prompt_num_computed_tokens == \
prompt_len + num_prompt_steps - 1

decode_step_counter = 0
while not seq.is_finished():
# Test correctness of num_computed_tokens after the decode steps
assert seq.data.get_num_computed_tokens(
) == prompt_num_computed_tokens + decode_step_counter
for _ in range(num_scheduler_steps):
Copy link
Collaborator

Choose a reason for hiding this comment

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

QQ: why do we need the for loop here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when num_scheduler_steps=n, engine.step() doesn't do all n steps. It still does only 1 step.
This for-loop is required for multi-step.

Also, multi-step doesn't provide any guarantees that output processing will happen every step. The only guarantee is that after the completion of num_scheduler_steps, all data-structures will be correct. So, we finish all the steps in a multi-step before asserting.

# decode step
engine.step()
decode_step_counter += 1

# Test correctness of num_computed_tokens after the sequence finish.
assert seq.data.get_num_computed_tokens(
) == prompt_len + num_output_tokens - 1
Loading