├── .clang-format ├── .dockerignore ├── .github ├── PULL_REQUEST_TEMPLATE.md ├── runs-on.yml └── workflows │ ├── build.yml │ ├── clang-format-check.yml │ ├── docker-build.yml │ ├── gpu-ci.yml │ ├── helpers │ ├── free_space_on_runner.sh │ ├── gpu_ci_helper.py │ ├── install_cudnn.sh │ ├── install_dependencies.sh │ ├── install_nccl.sh │ └── oracle_con.py │ ├── pip-deploy.yml │ ├── pip-install.yml │ └── shell-check.yml ├── .gitignore ├── .gitmodules ├── .readthedocs.yaml ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── INSTALL.md ├── LICENSE ├── MANIFEST.in ├── MULTI-NODE.md ├── README.md ├── SERVE.md ├── cmake ├── cuda.cmake ├── cudnn.cmake ├── flash_attn.cmake ├── hip.cmake ├── json.cmake ├── legion.cmake ├── nccl.cmake ├── optional.cmake ├── pip_install │ └── CMakeLists.txt ├── utils.cmake └── variant.cmake ├── conda └── flexflow.yml ├── config ├── config.inc └── config.linux ├── docker ├── README.md ├── build.sh ├── flexflow-environment │ ├── Dockerfile │ └── install_pytorch.sh ├── flexflow │ └── Dockerfile ├── publish.sh ├── pull.sh └── run.sh ├── docs ├── Makefile ├── doxygen │ ├── Doxyfile │ ├── README.md │ └── theme │ │ ├── rust_customdoxygen.css │ │ ├── rust_footer.html │ │ └── rust_header.html ├── make.bat ├── requirements.txt └── source │ ├── chatbot.rst │ ├── conf.py │ ├── cpp_api.rst │ ├── developers_guide │ ├── developers_guide.rst │ ├── ff_internals.rst │ └── internals.md │ ├── docker.rst │ ├── imgs │ ├── gradio_api.png │ └── gradio_interface.png │ ├── index.rst │ ├── installation.rst │ ├── keras.rst │ ├── mt5.rst │ ├── multinode.rst │ ├── onnx.rst │ ├── prompt_template.rst │ ├── python │ ├── create.rst │ ├── dataloader.rst │ ├── init.rst │ ├── layers.rst │ ├── models.rst │ └── train.rst │ ├── pytorch.rst │ ├── rag.rst │ ├── serve_api.rst │ ├── serve_fastapi.rst │ ├── serve_gradioapi.rst │ ├── serve_overview.rst │ ├── serve_usecases.rst │ ├── train_examples.rst │ ├── train_interface.rst │ ├── train_overview.rst │ ├── train_python_api.rst │ └── welcome.rst ├── img ├── overview.png ├── performance.png └── spec_infer_demo.gif ├── include └── flexflow │ ├── accessor.h │ ├── attention_config.h │ ├── basic_graph.h │ ├── batch_config.h │ ├── config.h │ ├── dataloader.h │ ├── device.h │ ├── dominators.h │ ├── ffconst.h │ ├── ffconst_utils.h │ ├── fftype.h │ ├── flash_api.h │ ├── flexflow_c.h │ ├── gpt_tokenizer.h │ ├── graph.h │ ├── graph_structures.h │ ├── inference.h │ ├── initializer.h │ ├── layer.h │ ├── loss_functions.h │ ├── machine_view.h │ ├── mapper.h │ ├── memory_optimization.h │ ├── metrics_functions.h │ ├── model.h │ ├── node.h │ ├── op_meta.h │ ├── operator.h │ ├── operator_params.h │ ├── ops │ ├── add_bias_residual_layer_norm.h │ ├── add_bias_residual_layer_norm_params.h │ ├── aggregate.h │ ├── aggregate_params.h │ ├── aggregate_spec.h │ ├── aggregate_spec_params.h │ ├── arg_topk.h │ ├── arg_topk_params.h │ ├── argmax.h │ ├── argmax_params.h │ ├── attention.h │ ├── attention_params.h │ ├── batch_matmul.h │ ├── batch_matmul_params.h │ ├── batch_norm.h │ ├── beam_topk.h │ ├── beam_topk_params.h │ ├── cache.h │ ├── cast.h │ ├── cast_params.h │ ├── concat.h │ ├── concat_params.h │ ├── conv_2d.h │ ├── conv_2d_params.h │ ├── dropout.h │ ├── dropout_params.h │ ├── element_binary.h │ ├── element_binary_params.h │ ├── element_unary.h │ ├── element_unary_params.h │ ├── embedding.h │ ├── embedding_params.h │ ├── experts.h │ ├── experts_params.h │ ├── flat.h │ ├── flat_params.h │ ├── fused.h │ ├── gather.h │ ├── gather_params.h │ ├── groupby.h │ ├── groupby_params.h │ ├── inc_multihead_self_attention.h │ ├── inc_multihead_self_attention_params.h │ ├── kernels │ │ ├── batch_matmul_kernels.h │ │ ├── cast_kernels.h │ │ ├── concat_kernels.h │ │ ├── conv_2d_kernels.h │ │ ├── decompress_kernels.h │ │ ├── dropout_kernels.h │ │ ├── element_binary_kernels.h │ │ ├── embedding_kernels.h │ │ ├── flat_kernels.h │ │ ├── gather_kernels.h │ │ ├── inc_multihead_self_attention_kernels.h │ │ ├── inc_multihead_self_attention_utils.cuh │ │ ├── linear_kernels.h │ │ ├── lora_linear_kernels.h │ │ ├── pool_2d_kernels.h │ │ ├── reshape_kernels.h │ │ ├── residual_rms_norm_kernels.h │ │ ├── rms_norm_kernels.h │ │ ├── softmax_kernels.h │ │ ├── split_kernels.h │ │ └── transpose_kernels.h │ ├── layer_norm.h │ ├── layer_norm_params.h │ ├── linear.h │ ├── linear_params.h │ ├── lora_linear.h │ ├── lora_linear_params.h │ ├── mean.h │ ├── noop.h │ ├── pool_2d.h │ ├── pool_2d_params.h │ ├── reduce.h │ ├── reduce_params.h │ ├── reshape.h │ ├── reshape_params.h │ ├── residual_layer_norm.h │ ├── residual_layer_norm_params.h │ ├── residual_rms_norm.h │ ├── residual_rms_norm_params.h │ ├── reverse.h │ ├── rms_norm.h │ ├── rms_norm_params.h │ ├── sampling.h │ ├── sampling_params.h │ ├── sigmoid_silu_multi.h │ ├── sigmoid_silu_multi_params.h │ ├── softmax.h │ ├── softmax_params.h │ ├── spec_inc_multihead_self_attention.h │ ├── spec_inc_multihead_self_attention_params.h │ ├── split.h │ ├── split_params.h │ ├── topk.h │ ├── topk_params.h │ ├── transpose.h │ ├── transpose_params.h │ ├── tree_inc_multihead_self_attention.h │ └── tree_inc_multihead_self_attention_params.h │ ├── optimizer.h │ ├── page_manager.h │ ├── parallel_ops │ ├── allreduce.h │ ├── allreduce_params.h │ ├── combine.h │ ├── combine_params.h │ ├── fused_parallel_op.h │ ├── fused_parallel_op_params.h │ ├── kernels │ │ ├── allreduce_kernels.h │ │ ├── combine_kernels.h │ │ ├── parallel_identity_kernels.h │ │ ├── partition_kernels.h │ │ ├── reduction_kernels.h │ │ └── replicate_kernels.h │ ├── parallel_identity.h │ ├── parallel_identity_params.h │ ├── parallel_op.h │ ├── parallel_op_info.h │ ├── partition.h │ ├── partition_params.h │ ├── reduction.h │ ├── reduction_params.h │ ├── replicate.h │ └── replicate_params.h │ ├── parallel_tensor.h │ ├── recompile.h │ ├── request_manager.h │ ├── runtime.h │ ├── simulator.h │ ├── substitution.h │ ├── substitution_loader.h │ ├── tensor.h │ └── utils │ ├── cuda_helper.h │ ├── disjoint_set.h │ ├── dot │ ├── dot_file.h │ └── record_formatter.h │ ├── file_loader.h │ ├── hash_utils.h │ ├── hip_helper.h │ ├── memory_allocator.h │ ├── peft_weight_allocator.h │ ├── random_utils.h │ ├── recursive_logger.h │ ├── test_utils.h │ └── tuple.h ├── inference ├── .gitignore ├── README.md ├── flexllm │ ├── CMakeLists.txt │ └── peft_train.cc ├── incr_decoding │ ├── CMakeLists.txt │ └── incr_decoding.cc ├── inference_wrapper.in ├── models │ ├── falcon.cc │ ├── falcon.h │ ├── llama.cc │ ├── llama.h │ ├── mpt.cc │ ├── mpt.h │ ├── opt.cc │ ├── opt.h │ ├── starcoder.cc │ └── starcoder.h ├── peft │ ├── CMakeLists.txt │ └── peft.cc ├── python │ ├── chat.py │ ├── entrypoint │ │ ├── fastapi_incr.py │ │ └── fastapi_specinfer.py │ ├── ff_peft.py │ ├── incr_decoding.py │ ├── peft_demo │ │ ├── INSTRUCTIONS.md │ │ ├── demo.ipynb │ │ └── demo.py │ ├── save_dataset.py │ ├── spec_infer.py │ ├── streamlit │ │ ├── README.md │ │ ├── app.py │ │ └── fastapi_incr.py │ └── usecases │ │ ├── gradio_incr.py │ │ ├── gradio_specinfer.py │ │ ├── prompt_template_incr.py │ │ ├── prompt_template_specinfer.py │ │ ├── rag_incr.py │ │ └── rag_specinfer.py ├── spec_infer │ ├── CMakeLists.txt │ └── spec_infer.cc └── utils │ ├── compress_llama_weights.py │ ├── download_hf_model.py │ ├── download_peft_model.py │ ├── mem_analysis.py │ └── upload_peft_model.py ├── pyproject.toml ├── python ├── flexflow │ ├── __init__.py │ ├── config.py │ ├── core │ │ ├── __init__.py │ │ ├── flexflow_cffi.py │ │ ├── flexflow_logger.py │ │ ├── flexflow_top.py │ │ └── flexflowlib.py │ ├── findpylib.py │ ├── serve │ │ ├── __init__.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── base.py │ │ │ ├── falcon.py │ │ │ ├── llama.py │ │ │ ├── mpt.py │ │ │ ├── opt.py │ │ │ └── starcoder.py │ │ └── serve.py │ ├── torch │ │ ├── __init__.py │ │ ├── model.py │ │ └── nn │ │ │ ├── __init__.py │ │ │ └── modules │ │ │ ├── __init__.py │ │ │ └── module.py │ └── type.py ├── flexflow_cffi_build.py ├── flexflow_cffi_header.py.in └── flexflow_python_build.py ├── requirements.txt ├── scripts ├── format.sh ├── gdb │ └── pretty_print.py ├── install_tokenizer.sh ├── mnist_mlp_run.sh └── rdelacou │ └── generate_trace.py ├── setup.py ├── src ├── c │ └── flexflow_c.cc ├── dataloader │ ├── dataloader.cc │ ├── dataloader.cpp │ └── dataloader.cu ├── loss_functions │ ├── loss_functions.cc │ ├── loss_functions.cpp │ └── loss_functions.cu ├── mapper │ └── mapper.cc ├── metrics_functions │ ├── metrics_functions.cc │ ├── metrics_functions.cpp │ └── metrics_functions.cu ├── ops │ ├── add_bias_residual_layer_norm.cc │ ├── add_bias_residual_layer_norm.cpp │ ├── add_bias_residual_layer_norm.cu │ ├── aggregate.cc │ ├── aggregate.cpp │ ├── aggregate.cu │ ├── aggregate_spec.cc │ ├── aggregate_spec.cpp │ ├── aggregate_spec.cu │ ├── arg_topk.cc │ ├── arg_topk.cpp │ ├── arg_topk.cu │ ├── argmax.cc │ ├── argmax.cpp │ ├── argmax.cu │ ├── attention.cc │ ├── attention.cpp │ ├── attention.cu │ ├── attention_impl.cu │ ├── batch_matmul.cc │ ├── batch_norm.cc │ ├── batch_norm.cpp │ ├── batch_norm.cu │ ├── beam_topk.cc │ ├── beam_topk.cpp │ ├── beam_topk.cu │ ├── cache.cc │ ├── cache.cpp │ ├── cache.cu │ ├── cast.cc │ ├── concat.cc │ ├── conv_2d.cc │ ├── dropout.cc │ ├── element_binary.cc │ ├── element_unary.cc │ ├── element_unary.cpp │ ├── element_unary.cu │ ├── embedding.cc │ ├── experts.cc │ ├── experts.cpp │ ├── experts.cu │ ├── flat.cc │ ├── fused.cc │ ├── fused.cpp │ ├── fused.cu │ ├── gather.cc │ ├── group_by.cc │ ├── group_by.cpp │ ├── group_by.cu │ ├── inc_multihead_self_attention.cc │ ├── inc_multihead_self_attention.cpp │ ├── inc_multihead_self_attention.cu │ ├── kernels │ │ ├── batch_matmul.cpp │ │ ├── batch_matmul.cu │ │ ├── cast_kernels.cpp │ │ ├── cast_kernels.cu │ │ ├── concat_kernels.cpp │ │ ├── concat_kernels.cu │ │ ├── conv_2d_kernels.cpp │ │ ├── conv_2d_kernels.cu │ │ ├── decompress_kernels.cpp │ │ ├── decompress_kernels.cu │ │ ├── dropout_kernels.cpp │ │ ├── dropout_kernels.cu │ │ ├── element_binary_kernels.cpp │ │ ├── element_binary_kernels.cu │ │ ├── embedding_kernels.cpp │ │ ├── embedding_kernels.cu │ │ ├── flat_kernels.cpp │ │ ├── flat_kernels.cu │ │ ├── gather_kernels.cpp │ │ ├── gather_kernels.cu │ │ ├── linear_kernels.cpp │ │ ├── linear_kernels.cu │ │ ├── lora_linear_kernels.cpp │ │ ├── lora_linear_kernels.cu │ │ ├── pool_2d_kernels.cpp │ │ ├── pool_2d_kernels.cu │ │ ├── reshape_kernels.cpp │ │ ├── reshape_kernels.cu │ │ ├── residual_rms_norm_kernels.cpp │ │ ├── residual_rms_norm_kernels.cu │ │ ├── rms_norm_kernels.cpp │ │ ├── rms_norm_kernels.cu │ │ ├── softmax.cpp │ │ ├── softmax.cu │ │ ├── split_kernels.cpp │ │ ├── split_kernels.cu │ │ ├── transpose_kernels.cpp │ │ └── transpose_kernels.cu │ ├── layer_norm.cc │ ├── layer_norm.cpp │ ├── layer_norm.cu │ ├── linear.cc │ ├── lora_linear.cc │ ├── lora_linear_params.cc │ ├── mean.cc │ ├── mean.cpp │ ├── mean.cu │ ├── moe.cc │ ├── noop.cc │ ├── pool_2d.cc │ ├── reduce.cc │ ├── reduce.cpp │ ├── reduce.cu │ ├── reshape.cc │ ├── residual_layer_norm.cc │ ├── residual_layer_norm.cpp │ ├── residual_layer_norm.cu │ ├── residual_rms_norm.cc │ ├── reverse.cc │ ├── reverse.cpp │ ├── reverse.cu │ ├── rms_norm.cc │ ├── sampling.cc │ ├── sampling.cpp │ ├── sampling.cu │ ├── sigmoid_silu_multi.cc │ ├── sigmoid_silu_multi.cpp │ ├── sigmoid_silu_multi.cu │ ├── softmax.cc │ ├── spec_inc_multihead_self_attention.cc │ ├── spec_inc_multihead_self_attention.cpp │ ├── spec_inc_multihead_self_attention.cu │ ├── split.cc │ ├── topk.cc │ ├── topk.cpp │ ├── topk.cu │ ├── transpose.cc │ ├── tree_inc_multihead_self_attention.cc │ ├── tree_inc_multihead_self_attention.cpp │ └── tree_inc_multihead_self_attention.cu ├── parallel_ops │ ├── allreduce.cc │ ├── combine.cc │ ├── fused_parallel_op.cc │ ├── fused_parallel_op.cpp │ ├── fused_parallel_op.cu │ ├── kernels │ │ ├── allreduce_kernels.cpp │ │ ├── allreduce_kernels.cu │ │ ├── combine_kernels.cpp │ │ ├── combine_kernels.cu │ │ ├── parallel_identity_kernels.cpp │ │ ├── parallel_identity_kernels.cu │ │ ├── partition_kernels.cpp │ │ ├── partition_kernels.cu │ │ ├── reduction_kernels.cpp │ │ ├── reduction_kernels.cu │ │ ├── replicate_kernels.cpp │ │ └── replicate_kernels.cu │ ├── parallel_identity.cc │ ├── partition.cc │ ├── reduction.cc │ └── replicate.cc ├── recompile │ └── recompile_state.cc ├── runtime │ ├── accessor.cc │ ├── accessor_kernel.cpp │ ├── accessor_kernel.cu │ ├── batch_config.cc │ ├── beam_search_batch_config.cc │ ├── compile.sh │ ├── cpp_driver.cc │ ├── cuda_helper.cu │ ├── ffconst_utils.cc │ ├── fftype.cc │ ├── file_loader.cc │ ├── gpt_tokenizer.cc │ ├── graph.cc │ ├── hip_helper.cpp │ ├── inference_manager.cc │ ├── initializer.cc │ ├── initializer_kernel.cpp │ ├── initializer_kernel.cu │ ├── layer.cc │ ├── machine_model.cc │ ├── machine_view.cc │ ├── memory_allocator.cc │ ├── memory_optimization.cc │ ├── model.cc │ ├── model.cpp │ ├── model.cu │ ├── network.cc │ ├── operator.cc │ ├── operator_params.cc │ ├── optimizer.cc │ ├── optimizer_kernel.cpp │ ├── optimizer_kernel.cu │ ├── page_manager.cc │ ├── parallel_op.cc │ ├── parallel_tensor.cc │ ├── peft_weight_allocator.cc │ ├── peft_weight_allocator.cpp │ ├── peft_weight_allocator.cu │ ├── recursive_logger.cc │ ├── request_manager.cc │ ├── request_manager.cpp │ ├── request_manager.cu │ ├── simulator.cc │ ├── simulator.cpp │ ├── simulator.cu │ ├── strategy.cc │ ├── substitution.cc │ ├── substitution_loader.cc │ ├── tensor.cpp │ ├── tensor.cu │ └── tree_verify_batch_config.cc └── utils │ └── dot │ └── record_formatter.cc ├── tests ├── align │ ├── README.md │ ├── align_create_tensor_ff.py │ ├── align_create_tensor_torch.py │ ├── align_ff_utils.py │ ├── align_test.py │ ├── align_utils.py │ ├── mt5_encoder │ │ └── align_mt5_encoder_ff.py │ ├── mt5_ff_utils.py │ ├── peft_flash_attn │ │ ├── align.py │ │ ├── align_2_tensors_from_pt.py │ │ ├── launch.json │ │ ├── peft_flash_debug_note │ │ └── test_bwd_2x_grad_buf.py │ └── test_all_operators.sh ├── fine_grained_alignment_test.sh ├── inference │ ├── cpp_inference_tests.sh │ ├── generate_inf_test_configs.py │ ├── huggingface_inference.py │ ├── huggingface_inference_simple.py │ ├── huggingface_pipeline.py │ ├── inference_alignment_test.py │ └── test_inference_output.py ├── inference_tests.sh ├── multinode_helpers │ ├── mpi_wrapper1.sh │ └── mpi_wrapper2.sh ├── peft │ ├── alignment │ │ ├── align_test_utils.py │ │ ├── llama_alignment_tests.ipynb │ │ └── opt_alignment_tests.ipynb │ ├── hf_finetune.py │ ├── hf_serve.py │ ├── hf_train.py │ ├── hf_utils.py │ └── peft_alignment_test.py ├── peft_test.sh └── python_interface_test.sh └── triton ├── CMakeLists.txt ├── Dockerfile.QA ├── README.md ├── cmake └── TritonLegionBackendConfig.cmake.in ├── qa ├── L0_e2e │ ├── models │ │ ├── add │ │ │ ├── 1 │ │ │ │ ├── model.onnx │ │ │ │ └── model.strategy │ │ │ └── config.pbtxt │ │ ├── cast │ │ │ ├── 1 │ │ │ │ ├── model.onnx │ │ │ │ └── model.strategy │ │ │ └── config.pbtxt │ │ ├── identity │ │ │ ├── 1 │ │ │ │ ├── model.onnx │ │ │ │ └── model.strategy │ │ │ └── config.pbtxt │ │ ├── mul │ │ │ ├── 1 │ │ │ │ ├── model.onnx │ │ │ │ └── model.strategy │ │ │ └── config.pbtxt │ │ ├── reciprocal │ │ │ ├── 1 │ │ │ │ ├── model.onnx │ │ │ │ └── model.strategy │ │ │ └── config.pbtxt │ │ ├── softmax │ │ │ ├── 1 │ │ │ │ ├── model.onnx │ │ │ │ └── model.strategy │ │ │ └── config.pbtxt │ │ ├── softmax1 │ │ │ ├── 1 │ │ │ │ ├── model.onnx │ │ │ │ └── model.strategy │ │ │ └── config.pbtxt │ │ ├── sqrt │ │ │ ├── 1 │ │ │ │ ├── model.onnx │ │ │ │ └── model.strategy │ │ │ └── config.pbtxt │ │ ├── sub │ │ │ ├── 1 │ │ │ │ ├── model.onnx │ │ │ │ └── model.strategy │ │ │ └── config.pbtxt │ │ └── tanh │ │ │ ├── 1 │ │ │ ├── model.onnx │ │ │ └── model.strategy │ │ │ └── config.pbtxt │ ├── operator_test.py │ ├── test.sh │ └── test_helpers.py ├── L0_parser │ └── test.sh └── common │ └── util.sh └── src ├── CMakeLists.txt ├── Makefile ├── accessor.h ├── backend.cc ├── common.h ├── config.h ├── cudahelp.h ├── instance.cc ├── instance.h ├── libtriton_legion.ldscript ├── model.cc ├── model.h ├── onnx ├── onnx-data.proto ├── onnx-ml.proto └── onnx-operators-ml.proto ├── onnx_parser.cc ├── onnx_parser.h ├── operator.cc ├── operator.h ├── operators ├── binary.cc ├── binary.cu ├── binary.h ├── concat.cc ├── concat.h ├── conv2d.cc ├── conv2d.h ├── flat.h ├── linear.h ├── matmul.cc ├── matmul.h ├── pool2d.cc ├── pool2d.h ├── reshape.cc ├── reshape.h ├── softmax.cc ├── softmax.h ├── unary.cc ├── unary.cu └── unary.h ├── runtime.cc ├── runtime.h ├── strategy.cc ├── strategy.h ├── tensor.cc ├── tensor.h ├── test ├── CMakeLists.txt ├── data │ ├── add.onnx │ ├── avg_pool.onnx │ ├── avg_pool_autopad.onnx │ ├── avg_pool_ceil.onnx │ ├── avg_pool_count_include_pad.onnx │ ├── avg_pool_pad.onnx │ ├── cast.onnx │ ├── conv2d_with_bias.onnx │ ├── identity.onnx │ ├── max_pool.onnx │ ├── max_pool_autopad.onnx │ ├── max_pool_ceil.onnx │ ├── max_pool_dilations.onnx │ ├── max_pool_order.onnx │ ├── mul.onnx │ ├── reciprocal.onnx │ ├── softmax.onnx │ ├── softmax_default_axis.onnx │ ├── softmax_negative_axis.onnx │ ├── sqrt.onnx │ ├── sub.onnx │ └── tanh.onnx ├── mock │ ├── binary.cc │ ├── concat.cc │ ├── conv2d.cc │ ├── legion.cc │ ├── matmul.cc │ ├── pool2d.cc │ ├── reshape.cc │ ├── softmax.cc │ ├── strategy.cc │ ├── triton_error.cc │ └── unary.cc ├── onnx_parser_test.cc └── scripts │ └── onnx_maker.py └── types.h /.dockerignore: -------------------------------------------------------------------------------- 1 | # Ignore all folders which start with "build" 2 | /build*/ 3 | 4 | # Ignore compiled files 5 | /.tools/ 6 | /python/flexflow_python 7 | /python/flexflow/core/legion_cffi.py 8 | python/flexflow/core/flexflow_cffi_header.py 9 | python/flexflow/core/legion_cffi_header.py 10 | *.pb.cc 11 | *.pb.h 12 | *.o 13 | *.a 14 | 15 | # Ignore inference assets 16 | /inference/weights/* 17 | /inference/tokenizer/* 18 | /inference/prompt/* 19 | /inference/output/* 20 | 21 | /tests/inference/python_test_configs/*.json 22 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Description of changes:** 2 | 3 | 4 | 5 | **Related Issues:** 6 | 7 | Linked Issues: 8 | - Issue # 9 | 10 | Issues closed by this PR: 11 | - Closes # 12 | 13 | -------------------------------------------------------------------------------- /.github/runs-on.yml: -------------------------------------------------------------------------------- 1 | images: 2 | dlami-x64: 3 | platform: "linux" 4 | arch: "x64" 5 | ami: "ami-04a2add47e78915e6" 6 | 7 | runners: 8 | gpu-nvidia: 9 | family: ["g5.12xlarge"] 10 | image: dlami-x64 11 | rocm-builder: 12 | family: ["c4.8xlarge"] 13 | image: dlami-x64 -------------------------------------------------------------------------------- /.github/workflows/clang-format-check.yml: -------------------------------------------------------------------------------- 1 | name: Clang format 2 | on: [push, pull_request, workflow_dispatch] 3 | jobs: 4 | formatting-check: 5 | name: Formatting Check 6 | runs-on: ubuntu-22.04 7 | strategy: 8 | matrix: 9 | path: 10 | - check: "src" 11 | exclude: '\.proto$' 12 | - check: "include" 13 | - check: "inference" 14 | - check: "python" 15 | - check: "scripts" 16 | - check: "tests" 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Run clang-format style check for C/C++/Protobuf programs. 20 | uses: jidicula/clang-format-action@v4.8.0 21 | with: 22 | clang-format-version: "15" 23 | check-path: ${{ matrix.path['check'] }} 24 | exclude-regex: ${{ matrix.path['exclude'] }} 25 | -------------------------------------------------------------------------------- /.github/workflows/helpers/free_space_on_runner.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | set -x 4 | 5 | sudo rm -rf /usr/share/dotnet 6 | sudo rm -rf /usr/local/lib/android 7 | sudo rm -rf /opt/ghc 8 | sudo rm -rf "/usr/local/share/boost" 9 | sudo rm -rf "$AGENT_TOOLSDIRECTORY" 10 | -------------------------------------------------------------------------------- /.github/workflows/helpers/install_cudnn.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | set -x 4 | 5 | # Cd into directory holding this script 6 | cd "${BASH_SOURCE[0]%/*}" 7 | 8 | ubuntu_version=$(lsb_release -rs) 9 | ubuntu_version=${ubuntu_version//./} 10 | 11 | wget -c -q "https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${ubuntu_version}/x86_64/cuda-keyring_1.1-1_all.deb" 12 | sudo dpkg -i cuda-keyring_1.1-1_all.deb 13 | sudo apt update -y 14 | rm -f cuda-keyring_1.1-1_all.deb 15 | sudo apt-get -y install libcudnn9-cuda-12 16 | sudo apt-get -y install libcudnn9-dev-cuda-12 17 | sudo apt-get -y install libcudnn9-samples 18 | sudo ldconfig 19 | -------------------------------------------------------------------------------- /.github/workflows/helpers/install_nccl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | set -x 4 | 5 | # Cd into directory holding this script 6 | cd "${BASH_SOURCE[0]%/*}" 7 | 8 | ubuntu_version=$(lsb_release -rs) 9 | ubuntu_version=${ubuntu_version//./} 10 | wget -c -q "https://developer.download.nvidia.com/compute/cuda/repos/ubuntu${ubuntu_version}/x86_64/cuda-keyring_1.1-1_all.deb" 11 | sudo dpkg -i cuda-keyring_1.1-1_all.deb 12 | sudo apt-get update -y --allow-change-held-packages 13 | rm -f cuda-keyring_1.1-1_all.deb 14 | sudo apt install -y --allow-change-held-packages libnccl2 libnccl-dev 15 | -------------------------------------------------------------------------------- /.github/workflows/helpers/oracle_con.py: -------------------------------------------------------------------------------- 1 | import oci 2 | import argparse 3 | import os 4 | 5 | parser = argparse.ArgumentParser(description="Program with optional flags") 6 | group = parser.add_mutually_exclusive_group() 7 | group.add_argument("--start", action="store_true", help="Start action") 8 | group.add_argument("--stop", action="store_true", help="Stop action") 9 | parser.add_argument("--instance_id", type=str, required=True, help="instance id required") 10 | args = parser.parse_args() 11 | 12 | oci_key_content = os.getenv("OCI_CLI_KEY_CONTENT") 13 | 14 | config = { 15 | "user": os.getenv("OCI_CLI_USER"), 16 | "key_content": os.getenv("OCI_CLI_KEY_CONTENT"), 17 | "fingerprint": os.getenv("OCI_CLI_FINGERPRINT"), 18 | "tenancy": os.getenv("OCI_CLI_TENANCY"), 19 | "region": os.getenv("OCI_CLI_REGION") 20 | } 21 | 22 | # Initialize the OCI configuration 23 | oci.config.validate_config(config) 24 | 25 | # Initialize the ComputeClient to interact with VM instances 26 | compute = oci.core.ComputeClient(config) 27 | 28 | # Replace 'your_instance_id' with the actual instance ID of your VM 29 | instance_id = args.instance_id 30 | 31 | # Perform the action 32 | if args.start: 33 | # Start the VM 34 | compute.instance_action(instance_id, "START") 35 | else: 36 | # Stop the VM 37 | compute.instance_action(instance_id, "STOP") 38 | -------------------------------------------------------------------------------- /.github/workflows/shell-check.yml: -------------------------------------------------------------------------------- 1 | name: Shell Check 2 | on: [push, pull_request, workflow_dispatch] 3 | jobs: 4 | shellcheck: 5 | name: Shellcheck 6 | runs-on: ubuntu-22.04 7 | steps: 8 | - uses: actions/checkout@v3 9 | - name: Run ShellCheck 10 | uses: ludeeus/action-shellcheck@master 11 | with: 12 | ignore_paths: ./triton/** 13 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "deps/legion"] 2 | path = deps/legion 3 | url = https://github.com/flexflow/legion.git 4 | [submodule "deps/nccl"] 5 | path = deps/nccl 6 | url = https://github.com/NVIDIA/nccl.git 7 | [submodule "deps/variant"] 8 | path = deps/variant 9 | url = https://github.com/mpark/variant 10 | [submodule "deps/optional"] 11 | path = deps/optional 12 | url = https://github.com/TartanLlama/optional.git 13 | [submodule "deps/json"] 14 | path = deps/json 15 | url = https://github.com/nlohmann/json.git 16 | [submodule "deps/tokenizers-cpp"] 17 | path = deps/tokenizers-cpp 18 | url = https://github.com/mlc-ai/tokenizers-cpp.git 19 | fetchRecurseSubmodules = true 20 | [submodule "deps/flashinfer"] 21 | path = deps/flashinfer 22 | url = https://github.com/flashinfer-ai/flashinfer.git 23 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yaml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Set the version of Python and other tools you might need 9 | build: 10 | os: ubuntu-20.04 11 | tools: 12 | python: "3.8" 13 | # You can also specify other tool versions: 14 | # nodejs: "16" 15 | # rust: "1.55" 16 | # golang: "1.17" 17 | 18 | # Build documentation in the docs/ directory with Sphinx 19 | sphinx: 20 | configuration: docs/source/conf.py 21 | 22 | #If using Sphinx, optionally build your docs in additional formats such as PDF 23 | formats: 24 | - pdf 25 | 26 | # Optionally declare the Python requirements required to build your docs 27 | python: 28 | install: 29 | - requirements: docs/requirements.txt 30 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | graft deps 2 | recursive-exclude . .git 3 | prune triton 4 | include python/flexflow/version.txt 5 | -------------------------------------------------------------------------------- /cmake/cudnn.cmake: -------------------------------------------------------------------------------- 1 | # find cudnn in CUDNN_ROOT and CUDA_ROOT 2 | if(CUDNN_PATH) 3 | set(CUDNN_ROOT ${CUDNN_PATH}) 4 | else() 5 | # if CUDNN_PATH is not set, let's try to find it in the CUDA root 6 | set(CUDNN_ROOT ${CUDA_TOOLKIT_ROOT_DIR}) 7 | endif() 8 | find_library(CUDNN_LIBRARY 9 | NAMES libcudnn${LIBEXT} 10 | PATHS ${CUDNN_ROOT} ${CUDA_ROOT} 11 | PATH_SUFFIXES lib lib64 12 | DOC "CUDNN library." ) 13 | 14 | find_path(CUDNN_INCLUDE_DIR 15 | NAMES cudnn.h 16 | HINTS ${CUDNN_ROOT} ${CUDA_ROOT} 17 | PATH_SUFFIXES include 18 | DOC "CUDNN include directory." ) 19 | 20 | # find cudnn, set cudnn lib and include 21 | if(CUDNN_LIBRARY AND CUDNN_INCLUDE_DIR) 22 | set(CUDNN_FOUND ON) 23 | set(CUDNN_LIBRARIES ${CUDNN_LIBRARY}) 24 | set(CUDNN_INCLUDE_DIRS ${CUDNN_INCLUDE_DIR}) 25 | endif() 26 | 27 | # find cuda and cudnn 28 | if(CUDNN_FOUND) 29 | list(APPEND FLEXFLOW_EXT_LIBRARIES 30 | ${CUDNN_LIBRARIES}) 31 | 32 | list(APPEND FLEXFLOW_INCLUDE_DIRS 33 | ${CUDNN_INCLUDE_DIR}) 34 | endif() 35 | 36 | if(CUDNN_FOUND) 37 | message( STATUS "CUDNN include : ${CUDNN_INCLUDE_DIR}" ) 38 | message( STATUS "CUDNN libraries : ${CUDNN_LIBRARIES}" ) 39 | else() 40 | message( FATAL_ERROR "CUDNN package not found -> specify search path via CUDNN_DIR variable") 41 | endif() 42 | -------------------------------------------------------------------------------- /cmake/hip.cmake: -------------------------------------------------------------------------------- 1 | if (NOT FF_HIP_ARCH STREQUAL "") 2 | if (FF_HIP_ARCH STREQUAL "all") 3 | set(FF_HIP_ARCH "gfx900,gfx902,gfx904,gfx906,gfx908,gfx909,gfx90a,gfx90c,gfx940,gfx1010,gfx1011,gfx1012,gfx1013,gfx1030,gfx1031,gfx1032,gfx1033,gfx1034,gfx1035,gfx1036,gfx1100,gfx1101,gfx1102,gfx1103") 4 | endif() 5 | string(REPLACE "," "," HIP_ARCH_LIST "${FF_HIP_ARCH}") 6 | endif() 7 | 8 | message(STATUS "FF_HIP_ARCH: ${FF_HIP_ARCH}") 9 | if(FF_GPU_BACKEND STREQUAL "hip_rocm") 10 | #set(HIP_CLANG_PATH ${ROCM_PATH}/llvm/bin CACHE STRING "Path to the clang compiler by ROCM" FORCE) 11 | set(GPU_TARGETS "${FF_HIP_ARCH}" CACHE STRING "The GPU TARGETs") 12 | endif() 13 | -------------------------------------------------------------------------------- /cmake/json.cmake: -------------------------------------------------------------------------------- 1 | include(FetchContent) 2 | 3 | FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz) 4 | FetchContent_MakeAvailable(json) -------------------------------------------------------------------------------- /cmake/optional.cmake: -------------------------------------------------------------------------------- 1 | set(OPTIONAL_BUILD_TESTS OFF) 2 | set(OPTIONAL_BUILD_PACKAGE OFF) 3 | 4 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/deps/optional) 5 | 6 | list(APPEND FLEXFLOW_EXT_LIBRARIES optional) 7 | list(APPEND FLEXFLOW_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/deps/optional/include/) 8 | -------------------------------------------------------------------------------- /cmake/variant.cmake: -------------------------------------------------------------------------------- 1 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/deps/variant) 2 | 3 | list(APPEND FLEXFLOW_EXT_LIBRARIES mpark_variant) 4 | list(APPEND FLEXFLOW_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/deps/variant/include/) -------------------------------------------------------------------------------- /conda/flexflow.yml: -------------------------------------------------------------------------------- 1 | name: flexflow 2 | channels: 3 | - defaults 4 | - conda-forge 5 | dependencies: 6 | - python 7 | - cffi 8 | - rust 9 | - cmake-build-extension 10 | - jq 11 | - pytest 12 | - pip 13 | - pip: 14 | - numpy 15 | - torch 16 | - torchaudio 17 | - torchvision 18 | - regex 19 | - transformers>=4.47.1 20 | - sentencepiece 21 | - einops 22 | - requests 23 | - scipy 24 | - bitsandbytes 25 | - datasets 26 | - accelerate 27 | - loralib 28 | - triton 29 | - peft 30 | - pytest 31 | -------------------------------------------------------------------------------- /docker/flexflow/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG FF_GPU_BACKEND=cuda 2 | ARG gpu_backend_version=12.1 3 | FROM flexflow-environment-$FF_GPU_BACKEND$gpu_backend_version:latest 4 | 5 | LABEL org.opencontainers.image.source=https://github.com/flexflow/flexflow-serve 6 | LABEL org.opencontainers.image.description="flexflow-serve container" 7 | 8 | # Copy flexflow-serve repository 9 | RUN mkdir flexflow-serve 10 | WORKDIR /usr/flexflow-serve 11 | COPY . . 12 | 13 | # Args to build flexflow-serve 14 | ARG BUILD_CONFIGS 15 | ARG N_BUILD_CORES 16 | 17 | # Create install directory if needed 18 | RUN for pair in $BUILD_CONFIGS; do \ 19 | key=${pair%%=*}; \ 20 | value=${pair#*=}; \ 21 | if [ "$key" = "INSTALL_DIR" ] && [ -n "$value" ]; then \ 22 | mkdir -p "$value"; \ 23 | fi; \ 24 | done 25 | 26 | # Build and install C++ and Python versions of flexflow-serve 27 | RUN mkdir -p build && cd build && \ 28 | eval "$BUILD_CONFIGS" ../config/config.linux && \ 29 | make -j $N_BUILD_CORES install && \ 30 | ldconfig 31 | 32 | ENTRYPOINT ["/bin/bash"] 33 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile clean 16 | 17 | clean: 18 | rm -rf build doxygen/output doxygen/cpp_api 19 | @$(SPHINXBUILD) -M clean "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 20 | 21 | # Catch-all target: route all unknown targets to Sphinx using the new 22 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 23 | %: Makefile 24 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 25 | -------------------------------------------------------------------------------- /docs/doxygen/README.md: -------------------------------------------------------------------------------- 1 | # Doxygen Documentation 2 | 3 | This directory holds the configuration file for building 4 | the HTML Doxygen documentation for the C++ and Python code. 5 | This documentation is mainly for the developers of FlexFlow for now. 6 | 7 | ## Generate documentation locally 8 | 9 | 1. Install [doxygen](https://www.doxygen.nl/index.html). The configuration file is based on Doxygen 1.9.3. But all recent Doxygen versions should work. 10 | 2. Define `$FF_HOME` environmental variable to be the root directory of the FlexFlow repo. 11 | 3. Run Doxygen with `doxygen $FF_HOME/docs/doxygen/Doxyfile` 12 | 4. Now, you may browse the docs by opening the index page `$FF_HOME/docs/doxygen/output/html/index.html` with your favorite web browser. 13 | -------------------------------------------------------------------------------- /docs/doxygen/theme/rust_footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
16 | 17 | 18 |