add a new DAG 'axlearn_emergency_save' - #186
Conversation
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Utilities to run workloads with axlearn.""" |
There was a problem hiding this comment.
AXLearn is a proper noun, please be mindful
| # This function do some hacks to get Axlearn working with Airlfow | ||
| # One of them is deleting some unuseful packages in [dev] dependencies. | ||
| # We only need to run axlearn CLI | ||
| @task(execution_timeout=timedelta(hours=1)) |
There was a problem hiding this comment.
- please apply Airflow task group and organize tasks better
- why 1 hour? do we have to specify a timeout for this task? do we need to specify timeout for each task?
| @task(execution_timeout=timedelta(hours=1)) | ||
| def set_up_axlearn_dpd(branch: str): | ||
| """setup axlearn dependencies.""" | ||
| if branch == LALITAH_BRANCH or branch == SAM_BRANCH: |
There was a problem hiding this comment.
edge case?
using arbitrary string is not a good design --> caller can specify any string
| f" $HOME/axlearn" | ||
| ) | ||
|
|
||
| # Maybe add these lines |
| if branch == LALITAH_BRANCH or branch == SAM_BRANCH: | ||
| logging.info(f"Using custom branch ==> {branch}") | ||
| clone_branch = ( | ||
| f"git clone --branch {branch} https://github.com/lkolluru05/axlearn.git" |
There was a problem hiding this comment.
why using lkolluru05's fork? this is requested by Google?
|
|
||
|
|
||
| @task | ||
| def generate_workload_id(benchmark_id: str) -> str: |
There was a problem hiding this comment.
this is a very simple function and it's likely won't fail, do we need it to be an independent task? can't we just integrate it to other method which generates the configuration for AXLearn?
| # This function do some hacks to get Axlearn working with Airlfow | ||
| # One of them is deleting some unuseful packages in [dev] dependencies. | ||
| # We only need to run axlearn CLI |
There was a problem hiding this comment.
isn't this supposed to be the doc string of this function?
| f"gcloud container clusters get-credentials {cluster_name} \ | ||
| --region {region} --project {project_id}", |
There was a problem hiding this comment.
why's this command is considered as activate AXLearn
| f"axlearn gcp launch run --cluster=$CLUSTER " | ||
| f"--runner_name gke_tpu_single " | ||
| f" --name=$NAME --instance_type=$INSTANCE_TYPE " | ||
| f"--num_replicas=$NUM_REPLICAS --bundler_spec=allow_dirty=True " | ||
| f"--bundler_type=artifactregistry --bundler_spec=image=tpu " | ||
| f"--bundler_spec=dockerfile=Dockerfile --bundler_spec=target=tpu " | ||
| f"-- \"ulimit -n 1048576; ulimit -c 0; python3 -c 'import jax; jax.devices()'; python3 -m axlearn.common.launch_trainer_main\" " | ||
| f"--module=$MODULE --config=$MODEL_CONFIG " | ||
| f"--trainer_dir=$TRAIN_DIR " | ||
| f"--data_dir=gs://axlearn-public/tensorflow_datasets " | ||
| f"--jax_backend=tpu --mesh_selector=$INSTANCE_TYPE " | ||
| f"--initialization_timeout=1200 {trace_list} " |
There was a problem hiding this comment.
please format that properly
| export_var = [ | ||
| f"export CLUSTER={cluster_name}", | ||
| f"export NAME={run_name}", | ||
| f"export BASTION_TIER=disabled", | ||
| f"export DEFAULT_PROJECT_ID=$(gcloud config get project)", | ||
| "export PROJECT_ID=${PROJECT_ID:-$DEFAULT_PROJECT_ID}", | ||
| f"export INSTANCE_TYPE={accelerator_type}", | ||
| f"export NUM_REPLICAS={num_replicas}", | ||
| f"export MODULE={module}", | ||
| f"export MODEL_CONFIG={model_config}", | ||
| f"export TRAIN_DIR={trainer_dir}", | ||
| ] | ||
| logging.info( | ||
| f" Cluster: {cluster_name} \ | ||
| -- num-replicas={num_replicas} \ | ||
| --run_name={run_name} \ | ||
| --project={cluster_project} \ | ||
| --zone={zone} \ | ||
| --instance-type={accelerator_type} \ | ||
| --module={module} \ | ||
| --config={model_config} \ | ||
| --trainer_dir={trainer_dir} \ | ||
| --data_dir=gs://axlearn-public/tensorflow_datasets \ | ||
| --jax_backend=tpu \ | ||
| --mesh_selector={accelerator_type} \ | ||
| --initialization_timeout=1200 Trace: {trace_list}" | ||
| ) |
There was a problem hiding this comment.
- shorten the code
- what exactly are you trying to log? the parameters passed from caller or the actual command that will be executed? --->
data_dirandjax_backendare fixed value
| if gcs_location: | ||
| gcs_path = gcs_location | ||
| else: | ||
| gcs_path = name_format.generate_gcs_folder_location( | ||
| self.task_test_config.gcs_subfolder, | ||
| self.task_test_config.benchmark_id, | ||
| ) |
There was a problem hiding this comment.
gcs_path = gcs_location if gcs_location else name_format.generate_gcs_folder_location(
self.task_test_config.gcs_subfolder,
self.task_test_config.benchmark_id,
)
| result = hook.run_command(["bash", "-c", ";".join(cmds)]) | ||
| assert ( | ||
| result.exit_code == 0 | ||
| ), f"Set up axlearn dependencies command failed with code {result.exit_code}" |
There was a problem hiding this comment.
Set up -> Activate
| """Generate a valid workload ID.""" | ||
|
|
||
| # Remove all non-alphanumeric characters, and truncate to ensure the result | ||
| # is less than 40 characters. |
There was a problem hiding this comment.
the result could be 40 characters
| create_axlearn_conf = [command_string.rstrip("\n")] | ||
| cmds = [*create_axlearn_conf] |
There was a problem hiding this comment.
Do we need create_axlearn_conf and command_string?
Could we put the commands in a list directly instead of unpacking from another list?
cmds = [
"cat << 'CONFIG_EOF' >~/axlearn/.axlearn/axlearn.default.config",
...
]
| trace_list = ( | ||
| ("--trace_at_steps=" + ", ".join(map(str, trace_steps))) | ||
| if trace_steps | ||
| else " " | ||
| ) |
There was a problem hiding this comment.
nit: How about moving to L212 and do
if trace_steps:
workload_create_cmd += "--trace_at_steps=" + ", ".join(map(str, trace_steps))
| f"axlearn gcp launch run --cluster=$CLUSTER " | ||
| f"--runner_name gke_tpu_single " | ||
| f" --name=$NAME --instance_type=$INSTANCE_TYPE " | ||
| f"--num_replicas=$NUM_REPLICAS --bundler_spec=allow_dirty=True " | ||
| f"--bundler_type=artifactregistry --bundler_spec=image=tpu " | ||
| f"--bundler_spec=dockerfile=Dockerfile --bundler_spec=target=tpu " | ||
| f"-- \"ulimit -n 1048576; ulimit -c 0; python3 -c 'import jax; jax.devices()'; python3 -m axlearn.common.launch_trainer_main\" " | ||
| f"--module=$MODULE --config=$MODEL_CONFIG " | ||
| f"--trainer_dir=$TRAIN_DIR " | ||
| f"--data_dir=gs://axlearn-public/tensorflow_datasets " | ||
| f"--jax_backend=tpu --mesh_selector=$INSTANCE_TYPE " |
There was a problem hiding this comment.
none of these need fstring
| f"export BASTION_TIER=disabled", | ||
| f"export DEFAULT_PROJECT_ID=$(gcloud config get project)", |
There was a problem hiding this comment.
fstring is not required
|
|
||
| assert ( | ||
| result.exit_code == 0 | ||
| ), f"Axlearn command failed with code {result.exit_code}" |
There was a problem hiding this comment.
Run workload axlearn
| setup_jax = None | ||
| if jax_version: | ||
| setup_jax = common.set_up_jax_version(jax_version) | ||
| else: | ||
| setup_jax = common.set_up_nightly_jax() |
There was a problem hiding this comment.
setup_jax = common.set_up_jax_version(jax_version) if jax_version else common.set_up_nightly_jax()
Description
This test verifies the Axlearn Checkpointing saving function. It conducts the following tasks:
Run the training by enabling the checkpointing, until the local and gcs checkpoints have been saved.
Tests
cluster env:
project: cienet-cmcs
name: ernie-axlearn-v5p
zone: us-east5-a
highScaleCheckpointingConfig: enabled
GcsFuseCsiDriver: enabled
Workload Identity Federation: enabled
gcs bucket:
name: cienet-cmcs-axlearn
Hierarchical namespace: enabled
airflow/composer env:
project: cienet-cmcs
name: ernie-ml-solutions
composer version: 2.10.1
airflow version: 2.10.2
Checklist
Before submitting this PR, please make sure (put X in square brackets):