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

[Inference] Refactor modeling attention layer by abstracting attention backends #5771

Merged
merged 6 commits into from
Jun 10, 2024

Conversation

char-1ee
Copy link
Contributor

@char-1ee char-1ee commented Jun 3, 2024

📌 Checklist before creating the PR

  • I have created an issue for this PR for traceability
  • The title follows the standard format: [doc/gemini/tensor/...]: A concise description
  • I have added relevant tags if possible for us to better distinguish different PRs
  • I have installed pre-commit: pip install pre-commit && pre-commit install

🚨 Issue number

Link this PR to your issue with words like fixed to automatically close the linked issue upon merge

e.g. fixed #1234, closed #1234, resolved #1234

📝 What does this PR do?

  1. Refactor inference modeling files:
    Current modeling under colossalai/inference have nested if-else conditional checks on choosing cuda/triton kernels for Attention layer computations. This PR abstracts the positional encoding and KV Cache operations into PreAttentionBackend, flash attention and flash decoding ops into AttentionBackend. Now inference modeling initializes attention backend according to configs that users give.

  2. Fix typo and naming, refactor code organizations.

Tests:
pytest_result_1
pytest_result_2

💥 Checklist before requesting a review

  • I have linked my PR to an issue (instruction)
  • My issue clearly describes the problem/feature/proposal, with diagrams/charts/table/code if possible
  • I have performed a self-review of my code
  • I have added thorough tests.
  • I have added docstrings for all the functions/methods I implemented

⭐️ Do you enjoy contributing to Colossal-AI?

  • 🌝 Yes, I do.
  • 🌚 No, I don't.

Tell us more if you don't enjoy contributing to Colossal-AI.

@char-1ee char-1ee requested a review from a team as a code owner June 3, 2024 05:52
colossalai/inference/config.py Outdated Show resolved Hide resolved
colossalai/inference/config.py Outdated Show resolved Hide resolved
colossalai/inference/core/engine.py Outdated Show resolved Hide resolved
colossalai/inference/core/engine.py Outdated Show resolved Hide resolved
colossalai/inference/modeling/models/nopadding_llama.py Outdated Show resolved Hide resolved
Signed-off-by: char-1ee <xingjianli59@gmail.com>
Signed-off-by: char-1ee <xingjianli59@gmail.com>
Signed-off-by: char-1ee <xingjianli59@gmail.com>
Signed-off-by: char-1ee <xingjianli59@gmail.com>
Signed-off-by: char-1ee <xingjianli59@gmail.com>
@char-1ee char-1ee changed the title [Inference] Refactor inference modeling [Inference] Refactor modeling attention layer by abstracting attention backends Jun 8, 2024
Signed-off-by: char-1ee <xingjianli59@gmail.com>
@char-1ee char-1ee merged commit 77a219a into hpcaitech:main Jun 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants