{"id":13604512,"url":"https://github.com/MachineLearningSystem/INFaaS","last_synced_at":"2025-04-12T02:30:48.150Z","repository":{"id":185461818,"uuid":"500092999","full_name":"MachineLearningSystem/INFaaS","owner":"MachineLearningSystem","description":"Model-less Inference Serving","archived":false,"fork":true,"pushed_at":"2021-05-27T04:13:51.000Z","size":1372,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-11-07T09:42:49.711Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://stanford-mast.github.io/INFaaS/","language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"stanford-mast/INFaaS","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MachineLearningSystem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-06-05T12:34:45.000Z","updated_at":"2022-05-02T09:25:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"8d80b7e3-48d8-41fd-ab1a-dca61600bc43","html_url":"https://github.com/MachineLearningSystem/INFaaS","commit_stats":null,"previous_names":["machinelearningsystem/infaas"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MachineLearningSystem%2FINFaaS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MachineLearningSystem%2FINFaaS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MachineLearningSystem%2FINFaaS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MachineLearningSystem%2FINFaaS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MachineLearningSystem","download_url":"https://codeload.github.com/MachineLearningSystem/INFaaS/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248506901,"owners_count":21115503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T19:00:47.062Z","updated_at":"2025-04-12T02:30:47.369Z","avatar_url":"https://github.com/MachineLearningSystem.png","language":null,"readme":"\u003cimg src=\"https://infaas-logo.s3-us-west-2.amazonaws.com/infaas_logo.png\" width=\"200\"\u003e\n\nINFaaS is an inference-as-a-service platform that makes inference accessible and easy-to-use by abstracting resource management and model selection.\nUsers simply specify their inference task along with any performance and accuracy requirements for queries.\n\n## Features\n- A simple-to-use API for submitting queries and performance objectives\n- A fully managed infrastructure for sharing across both models *and* users\n- Automatic scaling in response to user demand\n- Support for models built with TensorFlow, PyTorch, Caffe2, and TensorRT\n- Support for inference on CPUs, GPUs, and [Inferentia](https://aws.amazon.com/machine-learning/inferentia/) (with support for other hardware platforms coming soon)\n\n## Getting Started\nINFaaS runs on [AWS](https://aws.amazon.com/) (with other provider platform support coming soon).\n\n### One-time Setup\nThere are a few AWS-specific setup steps, all of which can be accomplished from the AWS dashboard:\n1. Create an IAM Role.\nGo to IAMs -\u003e Roles, and create an EC2 role with policies for `AmazonEC2FullAccess` and `AmazonS3FullAccess`.\n2. Create a Security Group.\nGo to EC2 -\u003e Security Groups, and allow for all inbound traffic *from your desired trusted IP addresses or domains* and all outbound traffic.\n3. Create an INFaaS Model Repository.\nGo to S3, and create a bucket.\nWe recommend to keep this bucket private, since only the trusted INFaaS infrastructure will have access to it.\n4. Create a model configuration bucket.\nAgain, go to S3, and create a bucket.\nThis bucket will hold profiled configurations used when models are registered (details in the [**Model Registration**](#model-registration) section).\nINFaaS will need access to this bucket when registering a model.\n\n### General Setup\n1. Create an [AWS EC2](https://aws.amazon.com/ec2/) instance, which will serve as the master node.\nIn our experiments, we use an `m5.2xlarge` instance.\nWe provide a public AMI (ami-036de08e2e59b4abc) in *us-west-2* (that you can [copy to your region](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/CopyingAMIs.html)) that contains the pre-installed dependencies.\nThe instance should have the IAM Role and Security Group you created in the [**One-time Setup**](#one-time-setup) attached to it.\n2. If you don't use our AMI (which already has INFaaS's directory set up), clone the INFaaS repository: `git clone https://github.com/stanford-mast/INFaaS.git`.\n3. Open `start_infaas.sh` and fill in the following entries. Entries between \u003c\u003e must be filled in prior to using INFaaS; the rest are set to defaults which can be changed based on your desired configuration.\n    ```\n    ###### UPDATE THESE VALUES BEFORE RUNNING ######\n    REGION='\u003cREGION\u003e'\n    ZONE='\u003cZONE\u003e'\n    SECURITY_GROUP='\u003cSECURITYGROUP\u003e'\n    IAM_ROLE='\u003cIAMROLE\u003e'\n    MODELDB='\u003cMYMODELDB\u003e' # Model repository bucket (do not include s3://)\n    CONFIGDB='\u003cMYCONFIGDB\u003e' # Configuration bucket (do not include s3://)\n    WORKER_IMAGE='ami-\u003cINFAASAMI\u003e'\n    NUM_INIT_CPU_WORKERS=1\n    NUM_INIT_GPU_WORKERS=0\n    NUM_INIT_INFERENTIA_WORKERS=0\n    MAX_CPU_WORKERS=1\n    MAX_GPU_WORKERS=0\n    MAX_INFERENTIA_WORKERS=0\n    SLACK_GPU=0 # Used for making popular GPU variants exclusive, set to 0 for no GPU to be used as exclusive\n    KEY_NAME='worker_key'\n    MACHINE_TYPE_GPU='p3.2xlarge'\n    MACHINE_TYPE_CPU='m5.2xlarge'\n    MACHINE_TYPE_INFERENTIA='inf1.2xlarge'\n    DELETE_MACHINES='2' # 0: VM daemon stops machines; 1: VM daemon deletes machines; 2: VM daemon persists machines, but removes them from INFaaS's view\n    ```\n    **Note:** If you would like to run the example below, you can either set CONFIGDB to be *infaas-sample-public/configs* or copy its contents over to your own configuration bucket using the [AWS CLI](https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html):\n    ```\n    aws s3 sync s3://infaas-sample-public/ s3://your-config-bucket/ --exclude \"resnet*\"\n    ```\n3. Run `./start_infaas.sh` from the INFaaS home directory (i.e., the directory that `start_infaas.sh` is located in).\nThis will set up all INFaaS components and initial workers, as well as run some basic tests to check that the system is properly set up.\nIf a worker fails to start after the timeout period, you can simply rerun the script.\nAll executables can be found in `build/bin`.\n\n### Model Registration\nCurrently, users must profile their models and generate a configuration file that can be passed to `infaas_modelregistration`.\nWe plan to make this process more automated in the future, but for now:\n- Go to `src/profiler`\n- Run `./profile_model.sh \u003cfrozen-model-path\u003e \u003caccuracy\u003e \u003cdataset\u003e \u003ctask\u003e [cpus]`\nThe script is interactive and will prompt you for information needed to profile your model.\nOnce complete, it will output a configuration (.config) file.\nUpload this configuration file to your configuration bucket configured in the [**One-time Setup**](#one-time-setup). Here is how you would do this with the [AWS CLI](https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html):\n  ```\n  aws s3 cp mymodel.config s3://your-config-bucket/mymodel.config\n  ```\n- Pass the .config (e.g., *mymodel.config*, not *my-config-bucket/mymodel.config*) to `infaas_modelregistration` as the second parameter.\n\n**Example**\n\nIn `infaas-sample-public`, we have provided a CPU TensorFlow model, an equivalent TensorRT model optimized for batch-4, and an equivalent Inferentia model optimized for batch-1 on a single Inferentia core. We also provide their respective configuration files that were generated as specified above using `src/profiler/profile_model.sh`. Register these models as follows:\n```\n./infaas_modelregistration resnet_v1_50_4.config infaas-sample-public/resnet_v1_50_4/\n./infaas_modelregistration resnet50_tensorflow-cpu_4.config infaas-sample-public/resnet50_tensorflow-cpu_4/\n./infaas_modelregistration resnet50_inferentia_1_1.config infaas-sample-public/resnet50_inferentia_1_1/\n```\nIf INFaaS is set up correctly, all of these commands should output a *SUCCEEDED* message.\n\n### Inference Query\nInformation about registered models:\n- To see the available model architectures for a given task and dataset, use `infaas_modarch`.\n- To get more information on the model-variants for a model architecture, use `infaas_modinfo`.\n\n**Example**\n\nTo see information about the models you registered in the Model Registration example, run `./infaas_modarch classification imagenet`, which should show that *resnet50* is the only registered model architecture.\n\nRunning `./infaas_modinfo resnet50` should show the three model-variants you registered: *resnet_v1_50_4*, *resnet50_tensorflow-cpu_4*, *resnet50_inferentia_1_1*.\n\nRunning queries:\n- To run an online query, use `infaas_online_query`.\nRunning this with no parameters describes the valid input configurations (corresponding with the *model-less* abstraction, which you can read about more in the second reference paper below).\nINFaaS returns the raw output from the model (e.g., output probabilities for each class).\n- To run an offline query, use `infaas_offline_query`.\nINFaaS returns whether the job scheduling was successful.\nIf successfully scheduled, the job can be monitored by checking the `output_url` bucket.\n\n**Example**\n\nNote: to run this example, you must have called `./start_infaas.sh` with at least one GPU worker (i.e., *NUM_INIT_GPU_WORKERS* \u003e= 1 and *MAX_GPU_WORKERS* \u003e= *NUM_INIT_GPU_WORKERS*) and one Inferentia worker (i.e., *NUM_INIT_INFERENTIA_WORKERS* \u003e= 1 and *MAX_INFERENTIA_WORKERS* \u003e= *NUM_INIT_INFERENTIA_WORKERS*).\n\nLet's send an online image classification query to INFaaS and specify the model architecture with a latency constraint. After you have registered the three ResNet50 models from the above Model Registration example, we can first send the request with a relaxed latency constraint (assuming you are running in `build/bin` for the image path to work):\n```\n./infaas_online_query -d 224 -i ../../data/mug_224.jpg -a resnet50 -l 300\n```\nThe first time you run the query, the latency will be on the order of seconds, since the model needs to be loaded before it can be run. If you rerun the query, it should complete much faster (in hundreds of milliseconds). INFaaS uses *resnet50_tensorflow-cpu_4* to service this query since it is sufficient to the latency requirements.\n\nNow, let's send a query with a stricter latency requirement:\n```\n./infaas_online_query -d 224 -i ../../data/mug_224.jpg -a resnet50 -l 50\n```\nAgain, the first time you run this query, the latency will be on the order of seconds (or you may even get a Deadline Exceeded message if it's longer than 10 seconds). Inferentia models can take longer to load and set up, which INFaaS accounts for in its scaling algorithm. If you rerun the query, it should complete in milliseconds. INFaaS uses *resnet50_inferentia_1_1* to service this query, since, despite being loaded, *resnet50_tensorflow-cpu_4* cannot meet the performance requirements you specified.\n\nFinally, let's send a batch-2 query with a strict latency requirements:\n```\n./infaas_online_query -d 224 -i ../../data/mug_224.jpg -i ../../data/mug_224.jpg -a resnet50 -l 20\n```\nAgain, the first time you run this query, the latency will be on the order of seconds (or you may even get a Deadline Exceeded message if it's longer than 10 seconds). Similar to Inferentia models, GPU models take longer to load and set up. If you rerun the query, it should complete in milliseconds. INFaaS uses *resnet_v1_50_4* to service this query, since (a) *resnet50_tensorflow-cpu_4* supports the batch size but not the latency requirement, and (b) *resnet50_inferentia_1_1* only supports batch-1 and cannot meet the latency requirement.\n\nYou can also simply specify a use-case to INFaaS with a latency and accuracy requirement. For example:\n```\n./infaas_online_query -d 224 -i ../../data/mug_224.jpg -t classification -D imagenet -A 70 -l 50\n```\n\n### Clean Up\nUpdate the following two parameters in `shutdown_infaas.sh`:\n```\nREGION='\u003cREGION\u003e'\nZONE='\u003cZONE\u003e'\n```\nThen, run `./shutdown_infaas.sh`.\nYou will be prompted on whether you would like to delete or shut down existing worker nodes.\nOnce this completes, all running INFaaS processes will be shut down on the master, in addition to workers being shut down or deleted (depending on what you inputted).\n\n### Contributing\nTo file a bug, ask a question, or request a feature, please file a GitHub issue.\nPull requests are welcome.\n\n### Reference\nFor details about INFaaS, please refer to the following two papers. We kindly ask that you cite them should you use INFaaS in your work.\n- Neeraja J. Yadwadkar, Francisco Romero, Qian Li, Christos Kozyrakis. [A Case for *Managed* and *Model-less* Inference Serving](https://dl.acm.org/citation.cfm?id=3321443). In *Workshop on Hot Topics in Operating Systems* (HotOS), 2019.\n- Francisco Romero*, Qian Li*, Neeraja J. Yadwadkar, Christos Kozyrakis. [INFaaS: Automated *Model-less* Inference Serving](https://www.usenix.org/conference/atc21/presentation/romero). In *USENIX Annual Technical Conference* (ATC), 2021.\n","funding_links":[],"categories":["Paper-Code"],"sub_categories":["Serving-Inference"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMachineLearningSystem%2FINFaaS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMachineLearningSystem%2FINFaaS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMachineLearningSystem%2FINFaaS/lists"}