Skip to content

add a new DAG 'axlearn_emergency_save' - #186

Open
ernie-chang wants to merge 5 commits into
masterfrom
axlearn-dev/dag-001
Open

add a new DAG 'axlearn_emergency_save'#186
ernie-chang wants to merge 5 commits into
masterfrom
axlearn-dev/dag-001

Conversation

@ernie-chang

@ernie-chang ernie-chang commented Jul 29, 2025

Copy link
Copy Markdown

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):

  • I have performed a self-review of my code.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run one-shot tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed.

Comment thread xlml/utils/axlearn.py Outdated
# See the License for the specific language governing permissions and
# limitations under the License.

"""Utilities to run workloads with axlearn."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AXLearn is a proper noun, please be mindful

Comment thread xlml/utils/axlearn.py Outdated
# 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))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. please apply Airflow task group and organize tasks better
  2. why 1 hour? do we have to specify a timeout for this task? do we need to specify timeout for each task?

Comment thread xlml/utils/axlearn.py Outdated
@task(execution_timeout=timedelta(hours=1))
def set_up_axlearn_dpd(branch: str):
"""setup axlearn dependencies."""
if branch == LALITAH_BRANCH or branch == SAM_BRANCH:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edge case?

using arbitrary string is not a good design --> caller can specify any string

Comment thread xlml/utils/axlearn.py
f" $HOME/axlearn"
)

# Maybe add these lines

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this

Comment thread xlml/utils/axlearn.py Outdated
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"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why using lkolluru05's fork? this is requested by Google?

Comment thread xlml/utils/axlearn.py


@task
def generate_workload_id(benchmark_id: str) -> str:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread xlml/utils/axlearn.py
Comment on lines +27 to +29
# 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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this supposed to be the doc string of this function?

Comment thread xlml/utils/axlearn.py
Comment on lines +100 to +101
f"gcloud container clusters get-credentials {cluster_name} \
--region {region} --project {project_id}",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why's this command is considered as activate AXLearn

Comment thread xlml/utils/axlearn.py Outdated
Comment on lines +201 to +212
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} "

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please format that properly

Comment thread xlml/utils/axlearn.py Outdated
Comment on lines +173 to +199
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}"
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. shorten the code
  2. what exactly are you trying to log? the parameters passed from caller or the actual command that will be executed? ---> data_dir and jax_backend are fixed value

Comment thread xlml/apis/task.py
Comment on lines +216 to +222
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,
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
        )

Comment thread xlml/utils/axlearn.py
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}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set up -> Activate

Comment thread xlml/utils/axlearn.py
"""Generate a valid workload ID."""

# Remove all non-alphanumeric characters, and truncate to ensure the result
# is less than 40 characters.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the result could be 40 characters

Comment thread xlml/utils/axlearn.py
Comment on lines +141 to +142
create_axlearn_conf = [command_string.rstrip("\n")]
cmds = [*create_axlearn_conf]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
  ...
]

Comment thread xlml/utils/axlearn.py
Comment on lines +166 to +170
trace_list = (
("--trace_at_steps=" + ", ".join(map(str, trace_steps)))
if trace_steps
else " "
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: How about moving to L212 and do

if trace_steps:
    workload_create_cmd += "--trace_at_steps=" + ", ".join(map(str, trace_steps))

Comment thread xlml/utils/axlearn.py
Comment on lines +199 to +209
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 "

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none of these need fstring

Comment thread xlml/utils/axlearn.py
Comment on lines +174 to +175
f"export BASTION_TIER=disabled",
f"export DEFAULT_PROJECT_ID=$(gcloud config get project)",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fstring is not required

Comment thread xlml/utils/axlearn.py

assert (
result.exit_code == 0
), f"Axlearn command failed with code {result.exit_code}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run workload axlearn

Comment on lines +36 to +40
setup_jax = None
if jax_version:
setup_jax = common.set_up_jax_version(jax_version)
else:
setup_jax = common.set_up_nightly_jax()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setup_jax = common.set_up_jax_version(jax_version) if jax_version else common.set_up_nightly_jax()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants