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 executorch kv cache incompatibility with to_executorch lowering #7279

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

dvorjackz
Copy link
Contributor

@dvorjackz dvorjackz commented Dec 11, 2024

Summary

Fix the Llama 3.2 vision text decoder prefill issue by marking the kv cache as an initialized mutable buffer in a custom pass

Test plan

  • Add kv_cache export tests that test accuracy against torchtune eager and verify contents of the cache after prefill and token-by-token generation
  • Export and run full Llama 3.2 vision text decoder
> python -m examples.models.llama.export_llama --model llama3_2_vision --checkpoint /tmp/Llama-3.2-11B-Vision-Instruct/original/consolidated.pth --params examples/models/llama3_2_vision/text_decoder/params/demo_config.json  --metadata '{"append_eos_to_prompt": 0, "get_bos_id":128000, "get_eos_ids":[128009, 128001], "get_n_bos": 0, "get_n_eos": 0}' --output_name="llama3_2_vision.pte" -d fp32 --verbose --max_seq_length 64 -k
> python -m examples.models.llama3_2_vision.runner.native --model llama3_2_vision --pte llama3_2_vision.pte  --tokenizer /tmp/Llama-3.2-11B-Vision-Instruct/original/tokenizer.model --prompt "Who's the founder of Meta?" --params examples/models/llama3_2_vision/text_decoder/params/demo_config.json --max_len 64 -kv --temperature 0

Copy link

pytorch-bot bot commented Dec 11, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/7279

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure

As of commit e297c9b with merge base 343aa0c (image):

NEW FAILURE - The following job has failed:

  • pull / unittest-arm / linux-job (gh)
    RuntimeError: Command docker exec -t b90672cd8630d1544e16c7c60d45fd7508caeb7cb8b1bc44652f5f7c7e8f80fe /exec failed with exit code 1

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 11, 2024
@dvorjackz dvorjackz marked this pull request as draft December 11, 2024 00:44
@dvorjackz dvorjackz force-pushed the jz/fix-prefill branch 2 times, most recently from d538d43 to ee2eb15 Compare December 16, 2024 21:08
@dvorjackz dvorjackz force-pushed the jz/fix-prefill branch 2 times, most recently from 5dcb8f7 to f723fe1 Compare December 18, 2024 05:40
@dvorjackz dvorjackz marked this pull request as ready for review December 18, 2024 06:11
@dvorjackz dvorjackz changed the title [DRAFT] Fix executorch kv cache incompatibility with to_executorch lowering Fix executorch kv cache incompatibility with to_executorch lowering Dec 18, 2024
@dvorjackz dvorjackz requested review from tarun292 and lucylq December 21, 2024 00:40
for pattern in self.patterns:
if pattern in name:
meta["et_init_buffer"] = True

Copy link
Contributor

Choose a reason for hiding this comment

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

We should raise an exception here if we don't find the buffer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: not user facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants