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

[llama] Added the fused rotary embedding kernel #719

Merged
merged 3 commits into from
Dec 20, 2024

Conversation

rsuderman
Copy link
Contributor

Reworked rotary embedding application to be performed via a custom kernel. This includes dropping static_table for the sake of maintenance (it was largely unused). It includes a simple numerical test however under the hood no numerical change should occur.

Existing baseline vs hugging face remained unchanged.

Reworked rotary embedding application to be performed via a custom
kernel. This includes dropping `static_table` for the sake of
maintenance (it was largely unused). It includes a simple numerical test
however under the hood no numerical change should occur.

Existing baseline vs hugging face remained unchanged.
@aviator19941
Copy link
Collaborator

Is it expected that the exported IR becomes much bigger (for 8b f16 bs4 tp1 IR is about 34 GB)?

Sharding code can cause the prebaked matrix size to explode in size.
@rsuderman
Copy link
Contributor Author

Is it expected that the exported IR becomes much bigger (for 8b f16 bs4 tp1 IR is about 34 GB)?

Updated how we do causal attention on prefill. It was baking out the attention matrix as a constant which was very beefy.

@rsuderman rsuderman merged commit fc9576b into nod-ai:main Dec 20, 2024
23 of 24 checks passed
archana-ramalingam added a commit that referenced this pull request Jan 4, 2025
monorimet pushed a commit that referenced this pull request Jan 8, 2025
Reworked rotary embedding application to be performed via a custom
kernel. This includes dropping `static_table` for the sake of
maintenance (it was largely unused). It includes a simple numerical test
however under the hood no numerical change should occur.

Existing baseline vs hugging face remained unchanged.
archana-ramalingam added a commit that referenced this pull request Jan 10, 2025
…719)" (#752)

This reverts commit fc9576b, which
causes segmentation fault at Llama prefill in IREE runtime.
stbaione added a commit to stbaione/SHARK-Platform that referenced this pull request Jan 15, 2025
stbaione added a commit that referenced this pull request Jan 16, 2025
…kernel (#719)" (#752)" (#828)

This reverts commit 63ff841.

# Description

Our [user
docs](https://github.com/nod-ai/shark-ai/blob/main/docs/shortfin/llm/user/llama_serving.md)
started producing repetitive output:

```bash
curl http://localhost:8003/generate \
    -H "Content-Type: application/json" \
    -d '{
        "text": "Name the capital of the United States.",
        "sampling_params": {"max_completion_tokens": 50}
    }'

data:  Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington
```

After bisecting, the problematic commit was found to be
63ff841.

Without commit reverted:

```bash
curl http://localhost:8003/generate \
    -H "Content-Type: application/json" \
    -d '{
        "text": "Name the capital of the United States.",
        "sampling_params": {"max_completion_tokens": 50}
    }'

data:  Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington, D.C.! Washington
```

With commit reverted:

```bash
curl http://localhost:8003/generate \
    -H "Content-Type: application/json" \
    -d '{
        "text": "Name the capital of the United States.",
        "sampling_params": {"max_completion_tokens": 50}
    }'

data:  Washington D.C. is the capital of the United States. Washington D.C. is a special district that is not part of any state but is the capital of the United States. Washington D.C. is a federal district that serves as the seat of the
```
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.

2 participants