Package: autogluon.bench
AutoGluon-BenchWelcome to AutoGluon-Bench, a suite for benchmarking your AutoML frameworks.SetupFollow the steps below to set up autogluon-bench:# create virtual env and update pippython3-mvenv.venv_agbenchsource.venv_agbench/bin/activate
python3-mpipinstall--upgradepipInstallautogloun-benchfrom PyPI:python3-mpipinstallautogluon.benchInstallautogluon-benchfrom source for development:gitclonehttps://github.com/autogluon/autogluon-bench.gitcdautogluon-bench# install from source in editable modepipinstall-e".[tests]"Run benchmarks locallyTo run the benchmarks on your local machine, use the following command:agbench run path/to/local_config_fileCheck out oursample local configuration filesfor local runs.The results are stored in the following directory:{WORKING_DIR}/{root_dir}/{module}/{benchmark_name}_{timestamp}.Tabular and Timeseries BenchmarkTo perform tabular or timeseries benchmarking, set the module to 'tabular' or 'timeseries'. You must set both Benchmark Configurations and Tabular/Timeseries Specific configurations, and each should have a single value. Refer to thesample configuration filefor more details.The tabular/timeseires module leverages theAMLBbenchmarking framework. Required and optional AMLB arguments are specified via the configuration file mentioned previously.Custom configuration is supported by providing a local directory toamlb_user_dirin the config, by which custom frameworks, constraints and datasets can be overriden. We have a minimum workingcustom configsetup for benchmarking on a custom framework (aAutoGluondev branch). In thesample configuration file, change the following field to:framework: AutoGluon_dev:example
amlb_user_dir: path_to/sample_configs/amlb_configsFor more customizations, please follow theexample custom configuration folderprovided by AMLB and theirdocumentation.Multimodal BenchmarkFor multimodal benchmarking, set the module to multimodal. Note that multimodal benchmarking directly calls the MultiModalPredictor, bypassing the extra layer ofAMLB. Therefore, the required arguments are different from those for tabular or timeseries. Please refer to thesample multimodal local run configuration file.We also support customizations on benchmarking framework, datasets, and metrics by providingcustom_resource_dir,custom_dataloader,custom_metrics.To define custom frameworks, you can follow theexamples.Create a folder under working directory, e.g.custom_resources/Create a yaml file namedmultimodal_frameworks.yamlAdd an entry to the file withrepoas the GitHub URL,versionas the branch or tag name,paramsto be used byMultiModalPredictor.Addcustom_resource_dir: custom/resources/in the run configuration file.To add more datasets to your benchmarking jobs. We support custom datasets with custom defined data loaders. Follow these steps:Create a folder under the working directory, e.g.custom_dataloader/Create a dataset yaml file,custom_dataloader/datasets.yamlwhich includes all required properties for your problem type, please refer to thefunction.Create a dataset loader class,custom_dataloader/dataloader.py, which downloads and loads the dataset as a dataframe. Please set the required properties as mentioned above.Addcustom_dataloaderin theagbench runconfiguration, wheredataloader_file,class_nameanddataset_config_fileare required.Make sure you have the proper permission to download the dataset. If running inAWS mode, we support downloading from the S3 bucket specified asDATA_BUCKETin theagbench runconfiguration under the same AWS Batch deployment account.Please refer toherefor more examples.Adding custom metrics is similar as adding data loaders. Internally, we convert the custom metrics into anAutoGluon Scorerusing theautogluon.core.metrics.make_scorerfunction. Follow these steps to set up:Create a folder under the working directory, e.g.custom_metrics/Create a metrics script,custom_metrics/metrics.pywhich has a function defined that returns a metrics score.Addcustom_metricsin theagbench runconfiguration, wheremetrics_path,function_nameare required. Aditional arguments can be added for themake_scorerfunction.Please refer toherefor more examples.Run benchmarks on AWSAutoGluon-Bench uses the AWS CDK to build an AWS Batch compute environment for benchmarking.To get started, installNode.jsandAWS CDKwith the following instructions:InstallNode Version Manager.Source profile or restart the terminal.Follow thePrerequisitessection on theAWS CDK Guideand install an appropriateNode.jsversion for your system:nvminstall$VERSION# install Node.jsnpminstall-gaws-cdk# install aws-cdkcdk--version# verify the installation, you might need to update the Node.js version depending on the log.Follow theAWS CLI Installation Guideto installawscliv2.If it is the first time using CDK to deploy to an AWS environment (An AWS environment is a combination of an AWS account and Region), please run the following:cdkbootstrapaws://CDK_DEPLOY_ACCOUNT/CDK_DEPLOY_REGIONYou will need a cloud configuration file to run the benchmarks. You can edit the providedsample cloud config files, or use the CLI tool to generate the cloud config files locally.For multimodal:agbench generate-cloud-config --module multimodal --cdk-deploy-account <AWS_ACCOUNT_ID> --cdk-deploy-region <AWS_ACCOUNT_REGION> --prefix <PREFIX> --metrics-bucket <METRICS_BUCKET> --data-bucket <DATA_BUCKET> --dataset-names DATASET_1,DATASET_2 --custom-resource-dir <CUSTOM_RESOURCE_DIR> --custom-dataloader "dataloader_file:value1;class_name:value2;dataset_config_file:value3"For tabular or timeseries:agbench generate-cloud-config --module <MODULE> --cdk-deploy-account <AWS_ACCOUNT_ID> --cdk-deploy-region <AWS_ACCOUNT_REGION> --prefix <PREFIX> --metrics-bucket <METRICS_BUCKET> --git-uri-branch <AMLB_GIT_URI_BRANCH> --framework <AMLB_FRAMEWORK> --amlb-benchmark <BENCHMARK1>,<BENCHMARK2> --amlb-task "BENCHMARK1:DATASET1,DATASET2;BENCHMARK2:DATASET3" --amlb-constraint <CONSTRAINT> --amlb-fold-to-run "BENCHMARK1:DATASET1:fold1/fold2,DATASET2:fold1/fold2;BENCHMARK1:DATASET3:fold1/fold2" --amlb-user-dir <AMLB_USER_DIR>For more details, you can runagbench generate-cloud-config --helpAfter having the configuration file ready, use the command below to initiate benchmark runs on cloud:agbench run /path/to/cloud_config_fileThis command automatically sets up an AWS Batch environment using instance specifications defined in thecloud config files. It also creates a lambda function named with your chosenLAMBDA_FUNCTION_NAME. This lambda function is automatically invoked with the cloud config file you provided, submitting a single AWS Batch job or a parent job forArray jobsto the job queue (named with thePREFIXyou provided).In order for the Lambda function to submit multiple Array child jobs simultaneously, you need to specify a list of values for each module-specific key. Each combination of configurations is saved and uploaded to your specifiedMETRICS_BUCKETin S3, stored underS3://{METRICS_BUCKET}/configs/{module}/{BENCHMARK_NAME}_{timestamp}/{BENCHMARK_NAME}_split_{UID}.yaml. Here,UIDis a unique ID assigned to the split.The AWS infrastructure configurations and submitted job ID is saved locally at{WORKING_DIR}/{root_dir}/{module}/{benchmark_name}_{timestamp}/aws_configs.yaml. You can use this file to check the job status at any time:agbenchget-job-status--config-file/path/to/aws_configs.yamlYou can also check the job status using job IDs:agbenchget-job-status--job-idsJOB_ID_1--job-idsJOB_ID_2—cdk_deploy_regionAWS_REGIONJob logs can be viewed on the AWS console. Each job has anUIDattached to the name, which you can use to identify the respective config split. After the jobs are completed and reach theSUCCEEDEDstatus in the job queue, you'll find metrics saved underS3://{METRICS_BUCKET}/{module}/{benchmark_name}_{timestamp}/{benchmark_name}_{timestamp}_{UID}.A cloud configuration file with time-stampedbenchmark_nameis also saved under{WORKING_DIR}/{root_dir}/{module}/{benchmark_name}_{timestamp}/{module}_cloud_configs.yamlBy default, the infrastructure created is retained for future use. To automatically remove resources after the run, use the--remove_resourcesoption:agbenchrunpath/to/cloud_config_file--remove-resourcesThis will check the job status every 2 minutes and remove resources after all jobs succeed. If any job fails, resources will be kept.If you want to manually remove resources later, use:agbenchdestroy-stack--config-file`{WORKING_DIR}/{root_dir}/{module}/{benchmark_name}_{timestamp}/aws_configs.yaml`Or you can remove specific stacks by running:agbenchdestroy-stack--static-resource-stackSTATIC_RESOURCE_STACK_NAME--batch-stackBATCH_STACK_NAME--cdk-deploy-accountCDK_DEPLOY_ACCOUNT--cdk-deploy-regionCDK_DEPLOY_REGIONwhere you can find all argument values in{WORKING_DIR}/{root_dir}/{module}/{benchmark_name}_{timestamp}/aws_configs.yaml.Configure the AWS infrastructureThe default infrastructure configurations are locatedhere.
CDK_DEPLOY_ACCOUNT: dummy
CDK_DEPLOY_REGION: dummy
PREFIX: ag-bench
MAX_MACHINE_NUM: 20
BLOCK_DEVICE_VOLUME: 100
TIME_LIMIT: 3600
RESERVED_MEMORY_SIZE: 15000
INSTANCE: g4dn.2xlarge
LAMBDA_FUNCTION_NAME: ag-bench-jobwhere:CDK_DEPLOY_ACCOUNTandCDK_DEPLOY_REGIONshould be overridden with your AWS account ID and desired region to create the stack.PREFIXis used as an identifier for the stack and resources created.MAX_MACHINE_NUMis the maximum number of EC2 instances can be started for AWS Batch.BLOCK_DEVICE_VOLUMEis the size of storage device attached to instance.TIME_LIMITis the timeout of AWS Batch job, i.e. the maximum time the instance will run. There is a buffer of 3600s added on top of it to account for instance startup time and dataset download time.RESERVED_MEMORY_SIZEis used together with the instance memory size to calculate the container shm_size.INSTANCEis the EC2 instance type.LAMBDA_FUNCTION_NAMEis the lambda function prefix to submit jobs to AWS Batch.To override these configurations, use thecdk_contextkey in your custom config file. See oursample cloud configfor reference.Formultimodalmodule, these will also be overridden by aconstraintdefinedhereor a custom constraint specified inmultimodal_constraints.yamlundercustom_resource_dir. Seesample custom constraints fileMonitoring metrics for your instances on AWSA variety of metrics are available for the EC2 instances that are launched during benchmarking. These can be accessed through the AWS Console by following this navigation path:CloudWatch->All metrics->AWS namespaces->EC2. For a comprehensive list of these metrics, refer to theofficial AWS documentation.In addition to the standard metrics, we also provide a custom metric forGPUUtilization. This can be found in theCloudWatchsection underAll metrics->Custom namespaces->EC2. Please note that theGPUUtilizationmetric is also updated every five minutes.We provide an option to save aggregated (average) custom hardware metrics (GPUUtilizationandCPUUtilizationlogged in 5s intervals) to the benchmark directory under the provided S3 bucket, simply use the option when running benchmark:agbench run --save-hardware-metricsNote that currently this command waits for all jobs to become successful to pull the hardware metrics.Evaluating benchmark runsBenchmark results can be evaluated using the tools insrc/autogluon/bench/eval/. The evaluation logic will aggregate, clean, and produce evaluation results for runs stored in S3.
In a future release, we intend to add evaluation support for multimodal benchmark results.Evaluation StepsBegin by setting up AWS credentials for the default profile for the AWS account that has the benchmark results in S3.Step 1: Aggregate AMLB results on S3. After running the benchmark inAWS mode, take note of thebenchmark_namewith timestamp in{WORKING_DIR}/{root_dir}/{module}/{benchmark_name}_{timestamp}/{module}_cloud_configs.yamland run the command below:agbench aggregate-amlb-results {METRICS_BUCKET} {module} {benchmark_name} --constraint {constraint}This will create a new file on S3 with this signature:s3://{METRICS_BUCKET}/aggregated/{module}/{benchmark_name}/results_automlbenchmark_{constraint}_{benchmark_name}.csvCurrently, aggregation is also supported for multimodal benchmark results without the--constratintoption.For more details, run:agbench aggregate-amlb-results --helpStep 2: Further clean the aggregated results.If the file is still on S3 from the previous step, run:agbench clean-amlb-results {benchmark_name} --results-dir-input s3://{METRICS_BUCKET}/aggregated/{module}/{benchmark_name}/ --benchmark-name-in-input-path --constraints constratint_1 --constraints constratint_2 --results-dir-output {results_dir_output} 
--out-path-prefix {out_path_prefix} --out-path-suffix {out_path_suffix}where{results_dir_input}can also be a local directory. This will create a local file{results_dir_output}/{out_path_prefix}{benchmark_name}{out_path_suffix}.For more details, run:agbench clean-amlb-results --helpStep 3: Run evaluation on multiple cleaned files fromStep 2agbench evaluate-amlb-results --frameworks-run framework_1 --frameworks-run framework_2 --results-dir-input data/results/input/prepared/openml/ --paths file_name_1.csv --paths file_name_2.csv --output-suffix benchmark_name --no-clean-data