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 blocks number calculation for Flat PA #269

Merged
merged 3 commits into from
Sep 18, 2024

Conversation

iboiko-habana
Copy link

Fix blocks number calculation for Flat PA via adding empty table_block (#158)

Comment on lines 926 to 932
if len(block_table) == 0:
block_number = 0
block_table = []
else:
block_number = block_table[position // self.block_size]
if block_number == _PAD_BLOCK_ID:
slot = next(dummy_slots)

Choose a reason for hiding this comment

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

Please combine those two if statements. Something like:

if len(block_table) == 0:
    block_number = _PAD_BLOCK_ID
    block_table = []
    slot = next(dummy_slots)
else:
    block_number = block_table[position // self.block_size]
    block_offset = position % self.block_size
    slot = block_number * self.block_size + block_offset

Copy link

@madamczykhabana madamczykhabana left a comment

Choose a reason for hiding this comment

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

LGTM

@madamczykhabana madamczykhabana merged commit b62fba8 into habana_main Sep 18, 2024
14 checks passed
@hlin99
Copy link

hlin99 commented Sep 19, 2024

seq_group_metadata_list.extend(
self.create_dummy_seq_group_metadata(0, 0, is_prompt)
for _ in range(batch_size_padding))

this piece of code introduces metadata certation in loop, and observe 10% perf drop. is this code change intentional?

@iboiko-habana
Copy link
Author

@hlin99 Thanks. Please re-check perf with #301

zhouyu5 pushed a commit to zhouyu5/vllm-fork that referenced this pull request Sep 20, 2024
Fix blocks number calculation for Flat PA via adding empty table_block
(HabanaAI#158)
zhouyu5 pushed a commit to zhouyu5/vllm-fork that referenced this pull request Sep 20, 2024
Fix blocks number calculation for Flat PA via adding empty table_block
(HabanaAI#158)
@hlin99
Copy link

hlin99 commented Sep 20, 2024

`` @hlin99 Thanks. Please re-check perf with #301

Unfortunately, performance has not improved, and the data looks identical before and after applying the patch. It seems that dummy creation and list extension are not the root cause of the performance drop. Instead, the issue appears to stem from changes to the dummy metadata, which are affecting subsequent calling path changes.

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