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

Add BTLM support + benchmark results #29

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ The following figures plot model perplexities under the various different approa
| ![mistral_7b_ppl_vram_plotted](https://github.com/microsoft/torchscale/assets/37621491/3a4c5634-cc1b-42d1-a35a-afb376a4f970) | ![gpt_j_6b_ppl_vram_plotted](https://github.com/tomaarsen/attention_sinks/assets/37621491/bdca944f-2fd2-46c4-8a88-2e1a8f16f75f) |
| **Qwen-7B** | **StableLM-3B-4E1T** |
| ![qwen_7b_ppl_vram_plotted](https://github.com/tomaarsen/attention_sinks/assets/37621491/ecf8beaf-7f8b-4412-bdcc-1d7f78b265bd) | ![stablelm_3b_4e1t_ppl_vram_plotted](https://github.com/tomaarsen/attention_sinks/assets/37621491/d1170e63-870a-404c-99a1-03eebd62422e) |
| **BTLM-3B-8k-base** | |
| ![btlm_3b_8k_base_ppl_vram_plotted](https://github.com/tomaarsen/attention_sinks/assets/37621491/4ea8c754-fc58-49c5-b5df-58c2e0eb178b)| |

The results are clear as day:
1. `transformers`: The VRAM usage is linear as it doesn't do any windowing. The performance heavily falls after the pretraining length.
Expand Down
6 changes: 5 additions & 1 deletion attention_sinks/inject_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"gptj": "GPTJModel",
"mistral": "MistralModel",
"qwen": "QWenModel",
"stablelm_epoch": "StableLMEpochModel"
"stablelm_epoch": "StableLMEpochModel",
"btlm": "BTLMModel",
}
ATTENTION_NAME_MAPPING = {
"llama": "LlamaAttention",
Expand All @@ -28,6 +29,7 @@
"mistral": "MistralAttention",
"qwen": "QWenAttention",
"stablelm_epoch": "Attention",
"btlm": "BTLMAttention",
}
KV_DIM_MAPPING = {
"llama": (2, 2),
Expand All @@ -38,6 +40,7 @@
"mistral": (2, 2),
"qwen": (1, 1),
"stablelm_epoch": (2, 2),
"btlm": (2, 2),
}


Expand Down Expand Up @@ -103,6 +106,7 @@ def _inject_pos_shift_attention(cls, model: PreTrainedModel) -> Optional[int]:
"mistral": mistral_pos_shift_attention_forward,
"qwen": qwen_pos_shift_attention_forward,
"stablelm_epoch": stablelm_epoch_pos_shift_attention_forward,
"btlm": None,
}

# Not all models require updated attention forwards
Expand Down
Loading