Google Kubernetes Engine (GKE) lets you pre-train sparse Mixture-of-Experts (MoE)
models across multi-host GPU clusters. In this tutorial, you pre-train the model
Qwen3-30B-A3B from randomized model weights on two A4 (a4-highgpu-8g) virtual
machine (VM) instances with a total of 16 NVIDIA B200 GPUs. Qwen3-30B-A3B has
30.5 billion total parameters, 3.3 billion active parameters, 128 experts, and
Top-8 routing. The training workload randomly initializes model weights, so you
don't need a Hugging Face access token to complete this tutorial.
This tutorial is intended for machine learning (ML) engineers, researchers, and platform administrators who deploy distributed GPU training workloads on Google Cloud.
Objectives
- Provision a two-node A4 GKE cluster in Standard mode by using Cluster Toolkit.
- Prepare a tokenized C4 dataset and tokenizer on Cloud Storage FUSE.
- Run multi-host pre-training for Qwen3-30B-A3B across 16 NVIDIA B200 GPUs by using NVIDIA Megatron-Bridge, Kueue, and Kubernetes JobSet.
- Monitor GPU utilization, verify asynchronous checkpoints, and resume training from a saved checkpoint.
- Clean up all deployed resources to avoid ongoing charges.
Costs
In this document, you use the following billable components of Google Cloud:
To generate a cost estimate based on your projected usage, use the pricing calculator.
Before you begin
Set up your environment for the tutorial:
Select or create a Google Cloud project and verify that billing is enabled for your project.
Install and initialize the Google Cloud CLI. If you're using Cloud Shell, then the gcloud CLI is preinstalled.
Install the following tools. If you're using Cloud Shell, then these tools are preinstalled:
- The
kubectlCLI - The
gke-gcloud-auth-pluginauthentication plugin - The
envsubstutility (included in thegettextorgettext-basepackage) curltar
- The
If you run this tutorial from a Linux or macOS workstation rather than Cloud Shell, then verify that your environment meets the Cluster Toolkit dependencies. The
gcluster deploy --download-dependenciescommand downloads Terraform automatically.Enable the Kubernetes Engine API, Compute Engine API, Cloud Storage API, Identity and Access Management API, Cloud Resource Manager API, Service Usage API, Cloud Logging API, and Cloud Monitoring API in your Google Cloud project:
Verify that network configurations and organization policies in your Google Cloud project allow outbound internet access for GKE nodes. When the cluster runs, nodes must pull the
nvcr.io/nvidia/nemo:26.08.01container image from NVIDIA NGC and the publicQwen/Qwen3-30B-A3Btokenizer andallenai/c4dataset shard from Hugging Face.
Required roles
To get the permissions that you need to complete this tutorial, ask your administrator to grant you the following IAM roles on your project:
- Compute Admin (
roles/compute.admin) - Kubernetes Engine Admin (
roles/container.admin) - Storage Admin (
roles/storage.admin) - Service Account Admin (
roles/iam.serviceAccountAdmin) - Service Account User (
roles/iam.serviceAccountUser) - Project IAM Admin (
roles/resourcemanager.projectIamAdmin) - Service Usage Admin (
roles/serviceusage.serviceUsageAdmin) - Monitoring Viewer (
roles/monitoring.viewer)
For more information about granting roles, see Manage access to projects, folders, and organizations.
You might also be able to get the required permissions through custom roles or other predefined roles.
Set up your environment variables
Configure your authentication and environment variables for the tutorial:
Sign in to the gcloud CLI and generate Application Default Credentials for Terraform:
Export the environment variables that you use throughout this tutorial:
Replace the following:
YOUR_PROJECT_ID: the ID of your Google Cloud project.YOUR_REGION: the compute region where your A4 capacity is located and where you want to deploy your cluster, such asus-central1.YOUR_ZONE: the compute zone where your A4 capacity is located, such asus-central1-b.YOUR_CLUSTER_NAME: the name for your GKE cluster and Cluster Toolkit deployment. The name must start with a lowercase letter and contain only lowercase letters, numbers, and hyphens. Keep the name to 20 lowercase characters or fewer so that the generated service account ID (YOUR_CLUSTER_NAME-gke-np-sa) stays within the 30-character Identity and Access Management (IAM) limit.YOUR_GCS_BUCKET: a globally unique name for the Cloud Storage bucket that stores the Terraform state for Cluster Toolkit.YOUR_RESERVATION_NAME: the name of your A4 reservation, or the extended reservation block path in the formatRESERVATION_NAME/reservationBlocks/RESERVATION_BLOCK_NAME.
These commands set the values of
CLUSTER_TOOLKIT_VERSIONtov1.109.0,NODE_COUNTto2, andAUTHORIZED_CIDRto0.0.0.0/0, and they also configure your default project and billing quota project for the gcloud CLI. For production deployments, to help protect access to the cluster control plane, restrictAUTHORIZED_CIDRto your workstation's/32CIDR range.
Create the GKE cluster
Download Cluster Toolkit and provision a GKE cluster in Standard mode:
Download and extract the prebuilt Cluster Toolkit bundle for the version specified in
CLUSTER_TOOLKIT_VERSION(v1.109.0), change your working directory tocluster-toolkit, and then verify the binary version:Create a Cloud Storage bucket to store your Cluster Toolkit Terraform state, and enable uniform bucket-level access and Object Versioning on the bucket:
Populate the
examples/gke-a4/gke-a4-deployment.yamldeployment configuration file for two A4 nodes:By default, the deployment file configures the
reservation_affinityfield to consume a specific reservation. If you don't have a specific reservation, then before you deploy the cluster, you can updateexamples/gke-a4/gke-a4-deployment.yamlto use Spot VMs or Flex-start VMs instead. For configuration instructions, see GKE consumption options.Deploy the GKE cluster by using the
gcluster deploycommand with the--download-dependenciesflag, which downloads Terraform automatically:If you run
./gcluster deploywithout the--auto-approveflag, then to apply the proposed changes, enterawhen prompted.Wait for cluster deployment to finish, which takes about 18 to 20 minutes. When the deployment succeeds, the output is similar to the following:
Apply complete! Resources: 80 added, 0 changed, 0 destroyed.Fetch
kubectlcredentials for your cluster and verify that the two A4 nodes, thenccl-rdma-installerDaemonSet, thedefault-rdmaResourceClaimTemplate object, the Kueue queues, and the Cloud Storage FUSE PersistentVolumeClaims (PVCs) are ready:Verify that the output shows
Readyfor both A4 nodes, two ready Pods (2) fornccl-rdma-installer,default-rdmaand the Kueue queues present, andBoundfor both Cloud Storage FUSE PVCs.Optional: To verify GPUDirect RDMA (
gIB) bandwidth across all 16 NVIDIA B200 GPUs, run the bundled two-node NVIDIA Collective Communications Library (NCCL)all_gather_perfJobSet from thecluster-toolkitdirectory, inspect the Pod logs for Node 0 (job-completion-index=0), and then delete the JobSet to release the Kueue quota:The NCCL test takes about 3 minutes to finish. In the Node 0 logs, confirm that the
busbwcolumn reports approximately 370 GBps to 375 GBps for the 8 GiB message size row (8589934592in thesizecolumn)—not the lowerAvg bus bandwidthsummary value across all message sizes at the end of the output.
Prepare the tokenized dataset
In this section, you use the qwen3-data-prep.yaml manifest to run a
Kueue-managed Kubernetes Job that downloads the tokenizer and 100,000 C4
documents and writes tokenized .bin and .idx files to your
Cloud Storage FUSE training volume.
To prepare and run the data-preparation Job, do the following:
Download the Kubernetes manifest files for dataset preparation and multi-host pre-training:
Retrieve and export the names of the training and checkpointing Cloud Storage FUSE PVCs that Cluster Toolkit created:
Review the
qwen3-data-prep.yamlmanifest. If you didn't download it earlier, then create a file namedqwen3-data-prep.yamlwith the following content:Substitute the
${TRAINING_PVC}environment variable intoqwen3-data-prep.yaml, submit the Job, wait for completion, and inspect the Job logs:Dataset preparation takes about 2 to 4 minutes on the first container image pull.
Before you proceed to pre-training, verify that the logs list the saved tokenizer and tokenized
.binand.idxfiles, ending with the following message:Dataset preparation complete.
Run the multi-host pre-training workload
The qwen3-30b-a3b-pretrain-jobset.yaml manifest defines a two-node
Kueue-managed Kubernetes JobSet that runs the official NVIDIA Megatron-Bridge
B200 performance recipe (scripts/performance/bootstrap.py) across 16 NVIDIA
B200 GPUs. The manifest configures the following optimizations for A4 clusters:
- A4 topology-aligned parallelism: Configures expert parallelism (
EP=8), dense data parallelism (Dense DP=16), expert data parallelism (Expert DP=2), tensor parallelism (TP=1), and pipeline parallelism (PP=1). Keeping all eight expert-parallel ranks inside each node's NVLink domain (1.8 TBps per GPU) lets the workload use thehybridepdispatcher andfull_iterationCUDA graphs. Dense layers and replicated expert shards synchronize across nodes over 400 Gbps per GPU (3.2 Tbps per node) GPUDirect RDMA (gIB) with a global batch size (GBS) of 1,024 and a micro-batch size (MBS) of 4. - Blackwell MXFP8 precision and built-in RDMA stack: Uses the unmodified
--compute_dtype fp8_mxrecipe inside the pinnednvcr.io/nvidia/nemo:26.08.01container image. The container image bundles the/etc/gcp_nccl_init.shGPUDirect RDMA initialization script, so that you don't need a hostgIBmount. - Local SSD staging and asynchronous checkpointing: Copies the tokenized
C4 dataset and tokenizer from Cloud Storage FUSE to each node's Local SSD
disk before training starts. The workload runs 50 iterations with
--save_interval 25,--load_dir, andcheckpoint.async_save=Trueso that iteration 25 saves asynchronously intorch_distformat during iterations 26 through 50. - GPU memory management for asynchronous checkpointing and resumption:
Overrides the
PYTORCH_CUDA_ALLOC_CONFenvironment variable (expandable_segments:False,max_split_size_mb:512,graph_capture_record_stream_reuse:True) and setstrain.empty_unused_memory_level=1. These settings help prevent GPU virtual address exhaustion and out-of-memory errors when persistent asynchronous checkpoint workers run or when CUDA graphs are captured after checkpoint resumption.
Deploy and monitor the two-node pre-training JobSet:
Review the
qwen3-30b-a3b-pretrain-jobset.yamlmanifest. If you didn't download it earlier, then create a file namedqwen3-30b-a3b-pretrain-jobset.yamlwith the following content:Export
TRAIN_ITERS=50, substitute the environment variables intoqwen3-30b-a3b-pretrain-jobset.yaml, apply the JobSet, and verify that Kueue admits the workload and starts both Pods:Optional: In a separate terminal session, stream live per-iteration loss, auxiliary load-balancing loss, step latency, and throughput (
TFLOP/s/GPU) from the Node 1 Pod (job-completion-index=1):Each JobSet Pod runs the
megatron-bridgecontainer: the Node 0 Pod (job-completion-index=0) logs startup and checkpoint progress, while the Node 1 Pod (job-completion-index=1) logs per-iteration training metrics. Node 1 pauses logging after iteration 50 for about 5 to 7 minutes while Node 0 flushes the final checkpoint (approximately 400 GiB) to Cloud Storage FUSE. To watch checkpoint save progress instead, replacejob-completion-index=1withjob-completion-index=0. To stop streaming logs at any time, press Control+C.Wait for the
qwen3-30b-a3bJobSet to reach theCompletedstate. Then, to verify asynchronous checkpoint overlap and iteration progress, inspect the Node 0 and Node 1 logs:The pre-training JobSet takes about 20 to 25 minutes in total to finish, including about 5 to 7 minutes after iteration 50 while Node 0 flushes the final checkpoint to Cloud Storage FUSE.
Healthy Node 0 logs have the following properties:
Confirmation that
/etc/gcp_nccl_init.shwas sourcedscheduled an asyncandsuccessfully savedmessages for iterations 25 and 50
Healthy Node 1 logs show decreasing language-modeling loss (
lm loss) with noNaNorInfvalues across iterations 1 through 50. Iterations 26 through 50 continue running while the iteration 25 checkpoint flushes in the background.You can ignore benign container warnings, including
Failed to import Triton kernelsandNCCL WARN Call to ibv_query_port_speed failed with error Protocol not supported errno 93. You can also ignoreWARNING: Starting a checkpoint save before previous has finishedat iteration 50. That final warning occurs because 25 training steps finish faster than the background checkpoint flush to Cloud Storage FUSE; for production runs, increase the value of the--save_intervalflag.
Monitor GPU metrics and verify checkpoints
In this section, you verify your pre-training run by charting GPU utilization in Monitoring and listing the saved dataset and checkpoint objects in your Cloud Storage buckets.
View GPU utilization in Monitoring
To verify that all 16 NVIDIA B200 GPUs across both hosts actively processed the pre-training workload, inspect the utilization metric for each GPU:
-
In the Google Cloud console, go to the leaderboard Metrics explorer page:
If you use the search bar to find this page, then select the result whose subheading is Monitoring.
In the Metric menu, select Prometheus Target > Dcgm >
prometheus.googleapis.com/DCGM_FI_DEV_GPU_UTIL/gauge.In the Filter field, filter by
clusterequal to your cluster name (YOUR_CLUSTER_NAME).To view utilization per GPU across both hosts, group the results by
Hostnameandgpu.For a healthy pre-training run, all 16 GPUs show sustained high utilization—for example, 90% to 100% during active training iterations, with brief drops during startup and checkpoint writes.
Verify dataset and checkpoints
To confirm that the tokenized C4 dataset and both the mid-run (iter_0000025)
and final (iter_0000050) asynchronous torch_dist checkpoints exist in your
Cloud Storage buckets, do the following:
Retrieve the training and checkpoint bucket names from your cluster's PersistentVolumes and list their contents:
In the
gcloud storage lsoutput, confirm that the following files and directories exist:- In the training bucket (
gs://${TRAINING_BUCKET}/dataset/):c4_qwen3_text_document.binandc4_qwen3_text_document.idx - In the checkpoint bucket (
gs://${CHECKPOINT_BUCKET}/qwen3-30b-a3b/):latest_checkpointed_iteration.txt,iter_0000025/, anditer_0000050/ - In each checkpoint directory (
iter_0000025/anditer_0000050/): 16.distcpshards,run_config.yaml, andtrain_state.pt
- In the training bucket (
Verify checkpoint resumption
Confirm that the training job resumes without errors from the saved checkpoint by doing the following:
Delete the completed JobSet, relaunch it with
TRAIN_ITERS=55, wait for completion, and inspect the resumed iterations in Node 1 logs:Checkpoint resumption takes about 20 to 25 minutes in total to finish. During startup, loading approximately 400 GiB of distributed checkpoint shards from Cloud Storage FUSE produces a quiet period of about 11 to 12 minutes in the logs before training iterations resume.
In the Node 1 logs, verify that iterations 51 through 55 complete with continuous
lm lossvalues and noNaNorInferrors.Optional: To observe checkpoint loading and final save progress while the resumed JobSet runs, in a separate terminal session, stream live Node 0 logs:
Check the Node 0 logs to confirm that there is a
successfully loaded checkpointmessage at iteration 50.
Scale to larger models and clusters
This two-node setup demonstrates a multi-node scaling pattern for A4 clusters. The configuration pairs intra-node NVLink expert parallelism with cross-node GPUDirect RDMA data parallelism, Blackwell MXFP8 precision, and asynchronous checkpointing. The following table compares this configuration against a single-node baseline and a 32-node production MoE configuration:
| Scale tier | Example model | Nodes and B200 GPUs | Typical parallelism | MoE dispatcher and precision | Storage and checkpointing |
|---|---|---|---|---|---|
| Single-node baseline | Qwen3-30B-A3B | 1 node (8 GPUs) | TP=1, PP=1, EP=8, Dense DP=8, Expert DP=1 (GBS=512, MBS=4) |
hybridep (intra-node NVLink), fp8_mx, CUDA graphs |
Local SSD disks or Cloud Storage FUSE |
| Dual-node (this tutorial) | Qwen3-30B-A3B | 2 nodes (16 GPUs) | TP=1, PP=1, EP=8, Dense DP=16, Expert DP=2 (GBS=1024, MBS=4) |
hybridep (intra-node NVLink), cross-node DP and Expert DP over gIB RDMA, full_iteration CUDA graphs, fp8_mx |
Cloud Storage FUSE with asynchronous torch_dist |
| Large-scale production MoE | Qwen3-235B-A22B | 32 nodes (256 GPUs) | TP=1, PP=8, EP=8, Dense DP=32, Expert DP=4 (GBS=8192, MBS=2) |
hybridep (intra-node EP=8), cross-node PP and DP over gIB RDMA, fp8_mx |
Google Cloud Managed Lustre, Local SSD disks, and asynchronous torch_dist |
When you scale to larger MoE models (such as Qwen3-235B-A22B or DeepSeek-V3 671B) and larger A4 clusters (16 to 32 or more nodes), update the following configurations:
- Cluster size and Kueue topology: Increase
NODE_COUNT(static_node_countinexamples/gke-a4/gke-a4-deployment.yaml) to match your A4 reservation block size. Updateparallelism,completions,NNODES, and--num_gpusin the JobSet manifest to match. Use Kueue topology-aware scheduling (kueue.x-k8s.io/podset-preferred-topologyfor best-effort compact placement, orkueue.x-k8s.io/podset-required-topologyset tocloud.google.com/gce-topology-blockto require Pods to be colocated within a single RDMA topology block). - Two-tier A4 interconnect: Each
a4-highgpu-8gVM instance provides 1.8 TBps of intra-node NVLink per GPU and 3.2 Tbps of inter-node RDMA over Converged Ethernet v2 (RoCEv2) (gIB) across eight 400 Gbps network interface cards (NICs). On clusters with 16 or more nodes, keepTPandhybridepEP <= 8inside each eight-GPU NVLink domain. Scale across nodes by usingPP,DP, or standard NCCLalltoallexpert parallelism overgIBRDMA. - High-throughput storage and checkpoint I/O: For models with
100 billion or more parameters across 16 or more nodes, mount
Managed Lustre for shared datasets and parallel
torch_distcheckpoint writes. Alternatively, pair non-persistent Local SSD disk checkpoints with periodic asynchronous uploads to Cloud Storage. - Performance recipes: To target a larger MoE architecture, pass the
corresponding model recipe flags directly to
scripts/performance/bootstrap.py. For example, to configure Qwen3-235B-A22B on 256 NVIDIA B200 GPUs, pass--model_family_name qwen --model_recipe_name qwen3_235b_a22b --gpu b200 --num_gpus 256 --compute_dtype fp8_mx.
Clean up
To avoid incurring ongoing charges to your Google Cloud account for the resources used in this tutorial, delete the workloads, storage objects, cluster, and Terraform state bucket:
Delete the pre-training JobSet, the dataset preparation Job, and the dataset and checkpoint objects stored in the Cloud Storage buckets:
From the
cluster-toolkitdirectory, destroy the GKE cluster and its associated infrastructure by using thegcluster destroycommand:Destroying the cluster takes about 10 to 13 minutes to finish.
Delete the Cloud Storage bucket that stores the Terraform state:
What's next
- Explore NVIDIA Megatron-Bridge recipes in the NVIDIA Megatron-Bridge GitHub repository.
- Review hardware details for A4 VMs with NVIDIA B200 GPUs.
- Learn more about Cluster Toolkit in the Cluster Toolkit overview.
- Compare storage services for AI and ML workloads.
- Read about managing AI-optimized GKE clusters.