You need to agree to share your contact information to access this model
The information you provide will be collected, stored, processed and shared in accordance with the Meta Privacy Policy.
Meta Large Language Model Compiler (LLM Compiler) LICENSE AGREEMENT
Version Release Date: 27th June 2024
“Agreement” means the terms and conditions for use, reproduction, distribution and modification of the LLM Compiler Materials set forth herein.
“Documentation” means the specifications, manuals and documentation accompanying the LLM Compiler distributed by Meta at:
- https://huggingface.co/facebook/llm-compiler-7b * https://huggingface.co/facebook/llm-compiler-7b-ftd * https://huggingface.co/facebook/llm-compiler-13b * https://huggingface.co/facebook/llm-compiler-13b-ftd
“Licensee” or “you” means you, or your employer or any other person or entity (if you are entering into this Agreement on such person or entity’s behalf), of the age required under applicable laws, rules or regulations to provide legal consent and that has legal authority to bind your employer or such other person or entity if you are entering in this Agreement on their behalf.
“Meta Large Language Model Compiler” and “LLM Compiler” mean the foundational large language models and software and algorithms, including machine-learning model code, trained model weights, inference-enabling code, training-enabling code, fine-tuning enabling code and other elements of the foregoing distributed by Meta at: - https://huggingface.co/facebook/llm-compiler-7b * https://huggingface.co/facebook/llm-compiler-7b-ftd * https://huggingface.co/facebook/llm-compiler-13b * https://huggingface.co/facebook/llm-compiler-13b-ftd
“LLM Compiler Materials” means, collectively, Meta’s proprietary LLM Compiler and Documentation (and any portion thereof) made available under this Agreement.
“Meta” or “we” means Meta Platforms Ireland Limited (if you are located in or, if you are an entity, your principal place of business is in the EEA or Switzerland) and Meta Platforms, Inc. (if you are located outside of the EEA or Switzerland).
By clicking “I Accept” below or by using or distributing any portion or element of the LLM Compiler Materials, you agree to be bound by this Agreement.
- License Rights and Redistribution. \
a. Grant of Rights. You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under Meta’s intellectual property or other rights owned by Meta embodied in the LLM Compiler Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the LLM Compiler Materials.
b. Redistribution and Use.
i. If you distribute or make available the LLM Compiler Materials (or any derivative works thereof), or a product or service that uses any of them, including another AI model, you shall (A) provide a copy of this Agreement with any such LLM Compiler Materials; and (B) prominently display “Built with LLM Compiler” on a related website, user interface, blogpost, about page, or product documentation. If you use the LLM Compiler Materials to create, train, fine tune, or otherwise improve an AI model, which is distributed or made available, you shall also include “LLM Compiler” at the beginning of any such AI model name.
ii. If you receive LLM Compiler Materials, or any derivative works thereof, from a Licensee as part of an integrated end user product, then Section 2 of this Agreement will not apply to you.
iii. You must retain in all copies of the LLM Compiler Materials that you distribute the following attribution notice within a “Notice” text file distributed as a part of such copies: “LLM Compiler is licensed under the LLM Compiler License, Copyright © Meta Platforms, Inc. All Rights Reserved.”
iv. Your use of the LLM Compiler Materials must comply with applicable laws and regulations (including trade compliance laws and regulations) and adhere to the Acceptable Use Policy for Llama Materials (available at https://llama.meta.com/llama3/use-policy), which is hereby incorporated by reference into this Agreement.
v. You will not use the LLM Compiler Materials or any output or results of the LLM Compiler Materials to improve any other large language model.
- Additional Commercial Terms. If, on the LLM Compiler release date, the monthly active users of the products or services made available by or for Licensee, or Licensee’s affiliates, is greater than 700 million monthly active users in the preceding calendar month, you must request a license from Meta, which Meta may grant to you in its sole discretion, and you are not authorized to exercise any of the rights under this Agreement unless or until Meta otherwise expressly grants you such rights.
3**. Disclaimer of Warranty**. UNLESS REQUIRED BY APPLICABLE LAW, THE LLM COMPILER MATERIALS AND ANY OUTPUT AND RESULTS THEREFROM ARE PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, AND META DISCLAIMS ALL WARRANTIES OF ANY KIND, BOTH EXPRESS AND IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE LLM COMPILER MATERIALS AND ASSUME ANY RISKS ASSOCIATED WITH YOUR USE OF THE LLM COMPILER MATERIALS AND ANY OUTPUT AND RESULTS. - Limitation of Liability. IN NO EVENT WILL META OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, ARISING OUT OF THIS AGREEMENT, FOR ANY LOST PROFITS OR ANY INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, EVEN IF META OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
- Intellectual Property.
a. No trademark licenses are granted under this Agreement, and in connection with the LLM Compiler Materials, neither Meta nor Licensee may use any name or mark owned by or associated with the other or any of its affiliates, except as required for reasonable and customary use in describing and redistributing the LLM Compiler Materials or as set forth in this Section 5(a). Meta hereby grants you a license to use LLM Compiler (the “Mark”) solely as required to comply with the last sentence of Section 1.b.i. You will comply with Meta’s brand guidelines (currently accessible at https://about.meta.com/brand/resources/meta/company-brand/). All goodwill arising out of your use of the Mark will inure to the benefit of Meta.
b. Subject to Meta’s ownership of LLM Compiler Materials and derivatives made by or for Meta, with respect to any derivative works and modifications of the LLM Compiler Materials that are made by you, as between you and Meta, you are and will be the owner of such derivative works and modifications.
c. If you institute litigation or other proceedings against Meta or any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the LLM Compiler Materials or LLM Compiler outputs or results, or any portion of any of the foregoing, constitutes infringement of intellectual property or other rights owned or licensable by you, then any licenses granted to you under this Agreement shall terminate as of the date such litigation or claim is filed or instituted. You will indemnify and hold harmless Meta from and against any claim by any third party arising out of or related to your use or distribution of the LLM Compiler Materials.
- Term and Termination. The term of this Agreement will commence upon your acceptance of this Agreement or access to the LLM Compiler Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein. Meta may terminate this Agreement if you are in breach of any term or condition of this Agreement. Upon termination of this Agreement, you shall delete and cease use of the LLM Compiler Materials. Sections 3, 4 and 7 shall survive the termination of this Agreement.
- Governing Law and Jurisdiction. This Agreement will be governed and construed under the laws of the State of California without regard to choice of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement. The courts of California shall have exclusive jurisdiction of any dispute arising out of this Agreement.
Log in or Sign Up to review the conditions and access this model content.
You need to share contact information with Meta to access this model
The information you provide will be collected, stored, processed and shared in accordance with the Meta Privacy Policy.
Introducing Meta Large Language Model Compiler (LLM Compiler), a state-of-the-art LLM for compiler optimization
Takeaways
- LLM Compiler is a state-of-the-art LLM that builds upon Code Llama with improved performance for code optimization and compiler reasoning.
- LLM Compiler is free for both research and commercial use.
- LLM Compiler is available in two flavors:
- LLM Compiler, the foundational models, pretrained on over 500B tokens of LLVM-IR, x86_84, ARM, and CUDA assembly codes and trained to predict the effect of LLVM optimizations;
- and LLM Compiler FTD, which is further fine-tuned to predict the best optimizations for code in LLVM assembly to reduce code size, and to disassemble assembly code to LLVM-IR.
- LLM Compiler demonstrates far stronger understanding of compiler optimizations than existing publicly available LLMs, perfectly emulating the compiler 20% of the time.
- LLM Compiler FTD sets state-of-the-art results on the tasks of optimization for code size and disassembly. It achieves a 5.24% code size improvement over -Oz vs GPT-4 Turbo 0.03%, and 0.96 round-trip BLEU score on disassembly vs GPT-4 Turbo 0.43.
LINKS
- LLM Compiler research paper
- Download the LLM Compiler and LLM Compiler FTD models:
We are excited to announce the release of LLM Compiler, a model targeted at code and compiler optimization tasks. LLM Compiler is built on top of our state-of-the-art large language model, Code Llama, adding capabilities to better understand compiler intermediate representations, assembly language and optimization. LLM Compiler is demonstrated on two difficult tasks: optimizing for code size and decompiling from assembly to the compiler’s intermediate representation. We release these foundation models to accelerate the application of LLMs for code optimization tasks and to enhance developer experience.
We are releasing LLM Compiler under the LLM Compiler License Agreement, which incorporates the Acceptable Use Policy for Llama Materials.
How LLM Compiler works
LLM Compiler is a specialization of Code Llama. It is a cutting-edge tool designed to optimize code using deep learning. LLM Compiler has been pre-trained on a vast amount of LLVM assembly (IR), x86_64, ARM, and CUDA assembly codes. LLM Compiler can predict, given a piece of LLVM assembly and a sequence of optimization passes for opt
, the LLVM optimizer, what the change in code size will be and what the output code will look like after applying these optimizations. It has ‘understood’ the behavior of the optimizing compiler to such a degree that in many cases it can perfectly replicate its output. These capabilities make it ideally suited to compiler optimization tasks.
In addition to this core functionality and to demonstrate its ability to solve complex compiler optimization problems, LLM Compiler has been fine-tuned for two specific downstream tasks:
- Predicting the best optimization passes for
opt
to use in order to minimize code size, given a piece of LLVM assembly code. \
- Generating LLVM IR from a piece of x86_64 or ARM assembly code. \
We are releasing LLM Compiler models in two sizes: 7B and 13B parameters. The models have been trained with a context window of 16,000 tokens.
The two models address different serving and latency requirements. The 7B model, for example, can be served on a single GPU and is more suitable for tasks that require low latency, like fine grained optimisation. The 13B model returns the best results.
When using the LLM Compiler models, users must abide by our license and acceptable use policy.
LLM Compiler performance
We tested the performance of LLM Compiler models for emulating compiler transformations, predicting optimal pass lists and decompiling intermediate representation on hold out test sets and compared them to Code Llama and GPT-4. We compare LLM Compiler Foundation to Code Llama Base and LLM Compiler FTD to Code Llama Instruct.
We evaluate LLM Compiler's ability to emulate compiler optimizations by giving it samples of unoptimized intermediate representation and a randomly generated list of optimizations. We then ask the model to generate the corresponding IR after the optimizations have been applied. In the table below we report the model's accuracy in reproducing the IR we would get from running opt. With very little knowledge of IR, Code Llama is unable to achieve high values while the LLM Compiler can generate character-by-character matches of expected assembly in 20% of the cases.
Model | Size | Accuracy at emulating compiler optimizations |
Code Llama | 7B | 1.2% |
Code Llama | 13B | 0.8% |
LLM Compiler | 7B | 16% |
LLM Compiler | 13B | 20% |
In a similar approach we evaluate our model's ability to optimize IR for code size. In this instance, however, we let the model generate the pass list that is to be used on a given unoptimized IR. We then use this pass list to optimize the particular program using opt and record the binary size. The baseline is the binary size of the program when optimized using -Oz. Only LLM Compiler FTD models provide an improvement over -Oz, with the 13B parameter model marginally outperforming the smaller model, generating smaller object files than -Oz in 61% of cases.
Lastly, we evaluate disassembly performance by giving the model x86 assembly code and ask it to generate the corresponding IR. We then round-trip the model-generated disassembled IR back down to assembly. This enables us to evaluate accuracy of the disassembly by comparing the BLEU score of the original assembly against the round-trip result. LLM Compiler FTD 13B has the highest accuracy of round-tripped assembly (round trip BLEU) and most frequently produces perfect disassembly. Code Llama Instruct and GPT-4 Turbo struggle with generating syntactically correct LLVM-IR.
Model | Size | Code Size Improvement | Round trip BLEU |
GPT-4 Turbo | -0.01% | 0.43 | |
Code Llama Inst | 7B | -0.49% | 0.48 |
Code Llama Inst | 13B | -0.42% | 0.62 |
LLM Compiler FTD | 7B | 4.77% | 0.95 |
LLM Compiler FTD | 13B | 4.88% | 0.96 |
Releasing LLM Compiler
LLMs are being used to make programming easier. They are beginning to be used to make programs more efficient.
At Meta, our conviction is that AI models, especially those designed for coding, thrive best with an open strategy, fostering both innovation and security. Models that are accessible to the public can expedite the creation of novel compiler optimization technologies. In turn, this will allow programs to be more efficient and smaller, enhancing the quality of life for all. By making models such as LLM Compiler available, the whole community can explore their potential, pinpoint problems, and rectify any vulnerabilities.
The model weights are available on Hugging Face.
Responsible use
Our research paper provides an in-depth look into the development process of the LLM Compiler, the methods we used for our benchmarking tests, and further insights into the model's limitations. It also discusses the issues faced, the steps we took to mitigate them.
Developers are advised to assess their models using evaluation benchmarks specific to compilers. Given that compilers are not bug-free, any suggested compiler optimizations must be rigorously tested. When a model decompiles assembly code, its accuracy should be confirmed.
The future of generative AI for optimisation
LLM Compiler is designed to support compiler researchers and engineers. But there are still many more use cases to support than what our models can serve. We hope that LLM Compiler will inspire others to leverage LLMs to create new innovative tools for research and commercial products.
Try LLM Compiler today
Download the LLM Compiler and LLM Compiler FTD models:
Read the research paper
Model Card
LLM Compiler is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 13 billion parameters. This is the repository for the 13 billion parameter foundation model version in the Hugging Face Transformers format. This model is designed for code optimization. Links to other models can be found in the index at the bottom.
Number of parameters | Base Model | Fine-tuned for code size and dissassembly |
---|---|---|
7B | facebook/llm-compiler-7b | facebook/llm-compiler-7b-ftd |
13B | facebook/llm-compiler-13b | facebook/llm-compiler-13b-ftd |
Model Use
To use this model, please make sure to install transformers:
pip install transformers accelerate
Example code using each of the model's compiler capabilities may be found in llm_compiler_demo.py.
The code below demonstrates default capabilities. You may need to set the HuggingFace access token - see (https://huggingface.co/docs/hub/security-tokens).
from transformers import AutoTokenizer
import transformers
import torch
model = "facebook/llm-compiler-13b"
tokenizer = AutoTokenizer.from_pretrained(model)
pipeline = transformers.pipeline(
"text-generation",
model=model,
torch_dtype=torch.float16,
device_map="auto",
)
sequences = pipeline(
'%3 = alloca i32, align 4',
do_sample=True,
top_k=10,
temperature=0.1,
top_p=0.95,
num_return_sequences=1,
eos_token_id=tokenizer.eos_token_id,
max_length=200,
)
for seq in sequences:
print(f"Result: {seq['generated_text']}")
Model Details
*Note: Use of this model is governed by the Meta license. Meta developed and publicly released the LLM Compiler family of large language models (LLMs).
Model Developers Meta
Variations LLM Compiler comes in two model sizes of 7B, 13B parameters in two flavors, the foundation and instruction fine-tuned for code size and disassembly.
This repository contains the 13 billion parameter foundation model.
Input Models input text only.
Example prompt See llm_compiler_demo.py
in the repo for examples of the different use cases.
Output Models generate text only.
Model Architecture LLM Compiler is an auto-regressive language model that uses an optimized transformer architecture.
Model Dates LLM Compiler has been trained between January 2024 and June 2024.
Status This is a static model trained on an offline dataset.
License A custom commercial license is available at: https://ai.meta.com/resources/models-and-libraries/llama-downloads/
Research Paper More information can be found in the paper "Meta Large Language Model Compiler: Foundation Models of Compiler Optimization".
Intended Use
Intended Use Cases LLM Compiler is intended for commercial and research use in English, relevant programming languages, LLVM IR, x86_64 assembly and ARM assembly.
Out-of-Scope Uses Use in any manner that violates applicable laws or regulations (including trade compliance laws). Use in languages other than English. Use in any other way that is prohibited by the Acceptable Use Policy and Licensing Agreement for LLM Compiler and its variants.
Hardware and Software
Training Factors We used custom training libraries. The training and fine-tuning of the released models have been performed Meta’s Research Super Cluster.
Carbon Footprint In aggregate, training all LLM Compiler models required 14K GPU hours of computation on hardware of type A100-80GB (TDP of 350-400W), not including the training of Code Llama. 100% of the estimated tCO2eq emissions were offset by Meta’s sustainability program.
Training Data
All experiments reported here and the released models have been trained and fine-tuned using the same data as Code Llama with different weights (see Section 2 and Table 1 in the research paper for details).
Evaluation Results
See evaluations for the main models and detailed ablations in Section 3 and safety evaluations in Section 4 of the research paper.
Ethical Considerations and Limitations
LLM Compiler and its variants are a new technology that carries risks with use. Testing conducted to date has been in English, and has not covered, nor could it cover all scenarios. For these reasons, as with all LLMs, LLM Compilers’s potential outputs cannot be predicted in advance, and the model may in some instances produce inaccurate or objectionable responses to user prompts. Therefore, before deploying any applications of LLM Compiler, developers should perform safety testing and tuning tailored to their specific applications of the model.
Please see the Responsible Use Guide available available at https://ai.meta.com/llama/responsible-use-guide.
- Downloads last month
- 149