Skip to content

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

Merged
char-1ee merged 6 commits intohpcaitech:mainfrom
char-1ee:refactor/modeling
Jun 10, 2024
Merged

[Inference] Refactor modeling attention layer by abstracting attention backends#5771
char-1ee merged 6 commits intohpcaitech:mainfrom
char-1ee:refactor/modeling

Conversation

@char-1ee
Copy link
Copy Markdown
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
Comment thread colossalai/inference/config.py Outdated
Comment thread colossalai/inference/config.py Outdated
Comment thread colossalai/inference/core/engine.py Outdated
Comment thread colossalai/inference/core/engine.py Outdated
Comment thread colossalai/inference/modeling/backends/attention_backend.py Outdated
Comment thread colossalai/inference/modeling/backends/pre_attention_backend.py Outdated
Comment thread colossalai/inference/modeling/backends/attention_backend.py Outdated
Comment thread colossalai/inference/modeling/backends/pre_attention_backend.py Outdated
Comment thread colossalai/inference/modeling/models/nopadding_llama.py Outdated
char-1ee added 3 commits June 7, 2024 08:33
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 force-pushed the refactor/modeling branch from 1ed7f7f to 5f398fc Compare June 7, 2024 08:34
Comment thread colossalai/_C/.nfs0000000013155a3b0000021b Outdated
char-1ee added 2 commits June 7, 2024 09:09
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
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