Skip to content

Latest commit

 

History

History
102 lines (81 loc) · 5.31 KB

File metadata and controls

102 lines (81 loc) · 5.31 KB

Llama 3 is a family of LLMs. The model is quantized to w4a16 (4-bit weights and 16-bit activations) and part of the model is quantized to w8a16 (8-bit weights and 16-bit activations) making it suitable for on-device deployment. For Prompt and output length specified below, the time to first token is Llama-PromptProcessor-Quantized's latency and average time per addition token is Llama-TokenGenerator-Quantized's latency.

This is based on the implementation of Llama-v3-8B-Instruct found here. This repository contains scripts for optimized on-device export suitable to run on Qualcomm® devices. More details on model performance across various devices, can be found here.

Qualcomm AI Hub Models uses Qualcomm AI Hub Workbench to compile, profile, and evaluate this model. Sign up to run these models on a hosted Qualcomm® device.

Deploying Llama 3 on-device

Please follow the LLM on-device deployment tutorial.

Setup

1. Install the package

Install the package via pip:

# NOTE: 3.10 <= PYTHON_VERSION < 3.14 is supported.
pip install "qai-hub-models[llama-v3-8b-instruct]"

For llama_v3_8b_instruct, some additional functionality can be faster or is available only with a GPU on the host machine.

  • 🟢 Exporting the model for on-device deployment (GPU not required)
  • 🟡 Running the demo (GPU recommended for speed, but not required)
  • 🟡 Running evaluation (GPU recommended for speed, but not required)
  • 🔴 Quantizing the model (GPU required)

If you are quantizing your own variant of llama_v3_8b_instruct, a dedicated CUDA enabled GPU (40 GB VRAM for 3B models to 80 GB VRAM for 8B models) is recommended. A GPU can also increase the speed of evaluation and demo of your quantized model significantly but it not strictly required.

Install the GPU package via pip:

# NOTE: 3.10 <= PYTHON_VERSION < 3.14 is supported.
pip install "qai-hub-models[llama-v3-8b-instruct]" onnxruntime-gpu==1.23.2 https://github.com/quic/aimet/releases/download/2.26.0/aimet_onnx-2.26.0+cu121-cp310-cp310-manylinux_2_34_x86_64.whl -f https://download.pytorch.org/whl/torch_stable.html

2. Configure Qualcomm® AI Hub Workbench

Sign-in to Qualcomm® AI Hub Workbench with your Qualcomm® ID. Once signed in navigate to Account -> Settings -> API Token.

With this API token, you can configure your client to run models on the cloud hosted devices.

qai-hub configure --api_token API_TOKEN

Navigate to docs for more information.

Run CLI Demo

Run the following simple CLI demo to verify the model is working end to end:

python -m qai_hub_models.models.llama_v3_8b_instruct.demo

More details on the CLI tool can be found with the --help option. See demo.py for sample usage of the model including pre/post processing scripts. Please refer to our general instructions on using models for more usage instructions.

Export for on-device deployment

To run the model on Qualcomm® devices, you must export the model for use with an edge runtime such as TensorFlow Lite, ONNX Runtime, or Qualcomm AI Engine Direct. Use the following command to export the model:

python -m qai_hub_models.models.llama_v3_8b_instruct.export

Additional options are documented with the --help option.

License

  • The license for the original implementation of Llama-v3-8B-Instruct can be found here.

References

Community

Usage and Limitations

This model may not be used for or in connection with any of the following applications:

  • Accessing essential private and public services and benefits;
  • Administration of justice and democratic processes;
  • Assessing or recognizing the emotional state of a person;
  • Biometric and biometrics-based systems, including categorization of persons based on sensitive characteristics;
  • Education and vocational training;
  • Employment and workers management;
  • Exploitation of the vulnerabilities of persons resulting in harmful behavior;
  • General purpose social scoring;
  • Law enforcement;
  • Management and operation of critical infrastructure;
  • Migration, asylum and border control management;
  • Predictive policing;
  • Real-time remote biometric identification in public spaces;
  • Recommender systems of social media platforms;
  • Scraping of facial images (from the internet or otherwise); and/or
  • Subliminal manipulation