Skip to content

Checkpoint Validation Pipeline Operations: Airflow polling integrations, PyConfig overrides, and pipeline lifecycle tooling - #4800

Open
olufiyin19 wants to merge 8 commits into
mainfrom
ckpt-validation-pr6-airflow-integration
Open

Checkpoint Validation Pipeline Operations: Airflow polling integrations, PyConfig overrides, and pipeline lifecycle tooling#4800
olufiyin19 wants to merge 8 commits into
mainfrom
ckpt-validation-pr6-airflow-integration

Conversation

@olufiyin19

Copy link
Copy Markdown
Collaborator

Description

This PR concludes the Agent Checkpoint Validation pipeline stack with external tooling and automation wrappers necessary to safely operate the system within Cloud Run and Airflow.

  1. Airflow DAG Triggering & Monitoring
  • Introduced wait_for_airflow_run.py to seamlessly bridge the Cloud Run Agent with Composer/Airflow DAG runs. The script polls the REST API sequentially, allowing the agent to continuously monitor asynchronous forward_pass and decode job metrics without timing out the Cloud Run sidecar.
  1. Automated Email Alerts Delivery
  • Built send_email.py as a standalone utility hook. When the validator detects an unresolvable numerical divergence or the agent optimization loop hits the maximum iteration count, it fires a structured Markdown email payload to alert the designated code owners directly.
  1. Base Configuration & Lifecycle Tooling
  • PyConfig Logging: Explicitly restored logger.setLevel(os.environ.get("LOGLEVEL", "INFO")) inside src/maxtext/configs/pyconfig.py (which had been inadvertently stripped from main). This ensures diagnostic execution traces are properly emitted to stdout for Airflow log capture.
  • Ephemeral Branch Cleanup: Included branch_cleanup.py and connected GitHub Actions scripts to safely purge intermediate PR stacks triggered dynamically by the AI agent, avoiding CI/CD branch pollution.

Stack

6th PR in stack. Depends on the preceding upstream PR: #4729

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an automated model onboarding and verification pipeline (the Overwatch Agent) to validate converted model checkpoints, including shape validation, checkpoint inspection, forward pass logit verification, and decoding checks. It also adds a validation check in pyconfig.py to prevent string fields from being incorrectly set to None. Feedback on these changes highlights a critical bug in layer_metrics.py where formatting None values (due to NaN or Inf activations) will cause a TypeError and crash the pipeline. Additionally, reliability and portability improvements are recommended, specifically adding a timeout to urllib.request.urlopen in adk_agent.py and replacing the platform-dependent sed -i command in deploy_to_cloud_run.sh with a more portable alternative.

Comment thread src/maxtext/experimental/agent/ckpt_validation_pipeline/layer_metrics.py Outdated
@olufiyin19
olufiyin19 force-pushed the ckpt-validation-pr6-airflow-integration branch 3 times, most recently from 93482fb to aa0f3ab Compare August 10, 2026 05:16
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@olufiyin19

Copy link
Copy Markdown
Collaborator Author

@gemini-cli /review

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hi @olufiyin19, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@olufiyin19

Copy link
Copy Markdown
Collaborator Author

@gemini-cli /review

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hi @olufiyin19, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

## 📋 Review Summary

This pull request completes the Agent Checkpoint Validation pipeline stack by introducing robust Airflow polling, automated Pub/Sub alert hooks, and ephemeral branch cleanup tooling. The overall architecture is highly modular and designed to prevent TPU compute waste by enforcing fast-fail validation checks on model checkpoints.

🔍 General Feedback

  • Subprocess Robustness: Improved handling of subprocess output streams using concurrent reading prevents deadlocks and timeout bypasses if the underlying validation processes freeze.
  • On-Device Array Conversions: Safe detaching and copying of PyTorch on-device tensors ensures metrics calculation works perfectly across CPU, GPU, and TPU environments without raising conversion exceptions.
  • CI/CD Cleanup: Improved Docker and Google Cloud Build setup scripts with strict traps ensures cleaner workspace states and avoids polluting temporary build artifacts.

@olufiyin19
olufiyin19 force-pushed the ckpt-validation-pr6-airflow-integration branch from dd145f1 to 8488751 Compare August 10, 2026 19:35
@olufiyin19

Copy link
Copy Markdown
Collaborator Author

@gemini-cli /review

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hi @olufiyin19, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

## 📋 Review Summary

This Pull Request successfully rounds out the Overwatch Checkpoint Validation automated pipeline stack by integrating robust Airflow DAG polling, alert notification dispatch mechanisms, branch pruning automation, and log capture improvements. While the structural changes and pipeline operational scripts are well-implemented and highly useful, there are critical configuration and schema validation regressions related to DeepSeek V4 that must be resolved before merging to avoid production failures.

🔍 General Feedback

  • Strong Pipeline Architecture: The modular separation of shape matching, logit verification, and decoding stages is an excellent design choice for a fast-fail workflow.
  • Robust Error Handling & Fallbacks: The use of runtime monkeypatching and structured JSON report logging in the validators is highly commendable for stability.
  • Merge Hygiene Caution: Please ensure that PR branches are rebased carefully onto main to prevent inadvertent deletion or reversion of recently merged features (such as DeepSeek V4 load balancing and logging attributes).

Comment thread src/maxtext/configs/types.py
Comment thread src/maxtext/configs/types.py Outdated
Comment thread src/maxtext/configs/pyconfig.py
@olufiyin19
olufiyin19 force-pushed the ckpt-validation-pr6-airflow-integration branch 2 times, most recently from 3378f32 to 8488751 Compare August 10, 2026 20:04
@olufiyin19
olufiyin19 force-pushed the ckpt-validation-pr6-airflow-integration branch from 8488751 to fb12c29 Compare August 10, 2026 20:06
@AI-Hypercomputer AI-Hypercomputer deleted a comment from github-actions Bot Aug 10, 2026
@olufiyin19

Copy link
Copy Markdown
Collaborator Author

@gemini-cli /review

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Hi @olufiyin19, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

## 📋 Review Summary

This Pull Request successfully introduces the operational tooling, Airflow integrations, pyconfig overrides, and cleanup routines for the Agent Checkpoint Validation pipeline. The overall codebase is modular, clean, and establishes solid automated orchestration capabilities. However, a few critical issues regarding typing-conversion logic and polling resilience must be addressed to ensure the pipeline is stable and production-ready.

🔍 General Feedback

  • Well-Structured Architecture: The modular separation between the shape, compiling, forward-pass, and decode-validation stages is clean and enforces a highly effective fast-fail system.
  • Improved Observability: Restoring logging levels and outputting HF layer-by-layer details significantly improves diagnostic logging for automated analysis.
  • Robust Cleaning: Including automated branch pruning and scheduled pruning GitHub Actions workflows maintains hygiene across the codebase.
  • Robustness Overwork: Dynamic runtime monkeypatching (especially source string rewrites) inside forward_pass_validator.py introduces fragility. In the future, resolving upstream bugs inside model_creation_utils.py directly is highly encouraged.

Comment thread src/maxtext/configs/pyconfig.py
Comment thread src/maxtext/experimental/agent/ckpt_validation_pipeline/forward_pass_validator.py Outdated
@olufiyin19
olufiyin19 force-pushed the ckpt-validation-pr6-airflow-integration branch from fb12c29 to a0edc81 Compare August 10, 2026 20:26
@olufiyin19
olufiyin19 force-pushed the ckpt-validation-pr6-airflow-integration branch from a0edc81 to 9bd506a Compare August 10, 2026 21:28
@olufiyin19
olufiyin19 force-pushed the ckpt-validation-pr6-airflow-integration branch from 4279cf1 to 25724ad Compare August 10, 2026 22:53
# Note: In a production environment, the Airflow Webserver URL and auth token would be injected via environment variables.
AIRFLOW_URL = os.environ.get(
"AIRFLOW_WEBSERVER_URL",
"https://4bae0a6de8f94e92aa8ee3a6ffc8b278-dot-us-central1.composer.googleusercontent.com",

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.

I dont' think we should expose google urls, even if internal only.


# Compile the final Markdown body with Github & Airflow links
pr_url = state_entry.get("pr_url", "https://github.com/AI-Hypercomputer/maxtext/pulls")
log_url = f"https://console.cloud.google.com/run/jobs/executions/list?project=tpu-prod-env-multipod"

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.

if the project is hardcoded here, what happens if the job runs in a different project?

except Exception as e:
logger.error("Error checking GCS for failures: %s", e)

return None, None

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.

instead create a report_data = None, blob = None and return that instead.


# Ensure temporary Dockerfile in root is cleaned up on exit
trap "rm -f ./Dockerfile .gcloudignore.tmp" EXIT
PROJECT_ID="tpu-prod-env-multipod"

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.

it would be nice if these are configurable through env variables.

To begin, you'll need:

1. A valid Google Cloud Storage (GCS) bucket where your converted checkpoint is located (e.g., `gs://my-bucket/converted_ckpt/0/items`).
2. The corresponding MaxText internal model name (e.g., `qwen3-8b`, `llama3-70b`).

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.

has qwen3-8b and llama3-70b been tested in this pipeline? If not, remove from readme and add models that have been tested e2e.

Comment thread .dockerignore
@@ -1,2 +1,4 @@
.git
maxtext_venv
.venv

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.

Remove these lines, keep them in your own environment.

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.

2 participants