I used setup.Dockerfile
to create an image that I then ran tests on, swapping in the base image that I
was using for the mlgo-development
image in the experimental directory in google/ml-compiler-opt
. I
swapped between ubuntu:20.04
and ubuntu:22.04
as they have different Python versions (3.8.x and
3.10.x respectively), and are what I've worked on MLGO with. I then ran the following commands to
generate some data:
Default trace:
time PYTHONPATH=$PYTHONPATH:. python3 compiler_opt/tools/generate_default_trace.py \
--data_path=/corpus \
--output_path=/default_trace \
--gin_files=compiler_opt/rl/regalloc/gin_configs/common.gin \
--gin_bindings=config_registry.get_configuration.implementation=@configs.RegallocEvictionConfig \
--gin_bindings=clang_path="'/llvm-project/build/bin/clang'" \
--sampling_rate=0.2
Warmstart:
time PYTHONPATH=$PYTHONPATH:. python3 compiler_opt/rl/train_bc.py \
--root_dir=/warmstart \
--data_path=/default_trace \
--gin_files=compiler_opt/rl/regalloc/gin_configs/behavioral_cloning_nn_agent.gin
Making sure to apply the following patch to the ml-compiler-opt
repo to only
run a couple training iterations:
diff --git a/compiler_opt/rl/regalloc/gin_configs/ppo_nn_agent.gin b/compiler_opt/rl/regalloc/gin_configs/ppo_nn_agent.gin
index 917b5ed..e6d1942 100644
--- a/compiler_opt/rl/regalloc/gin_configs/ppo_nn_agent.gin
+++ b/compiler_opt/rl/regalloc/gin_configs/ppo_nn_agent.gin
@@ -12,7 +12,7 @@ include 'compiler_opt/rl/regalloc/gin_configs/network.gin'
train_eval.agent_name=%constant.AgentName.PPO
train_eval.warmstart_policy_dir=''
-train_eval.num_policy_iterations=3000
+train_eval.num_policy_iterations=10
train_eval.num_modules=512
train_eval.num_iterations=200
train_eval.batch_size=256
Actual training:
time PYTHONPATH=$PYTHONPATH:. python3 compiler_opt/rl/train_locally.py \
--root_dir=/output_model \
--data_path=/corpus \
--gin_bindings=clang_path="'/llvm-project/build/bin/clang'" \
--gin_files=compiler_opt/rl/regalloc/gin_configs/ppo_nn_agent.gin \
--gin_bindings=train_eval.warmstart_policy_dir=\"/warmstart/saved_policy\"