Add Self-Patching Agent for the Checkpoint Validation Pipeline - #4729
Add Self-Patching Agent for the Checkpoint Validation Pipeline#4729olufiyin19 wants to merge 5 commits into
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
🤖 Hi @entrpn, I've received your request, and I'm working on it now! You can track my progress in the logs for more details. |
There was a problem hiding this comment.
This PR introduces an automated Fixer Agent sidecar built on the Google GenAI Agent Development Kit (ADK) to establish a serverless self-patching and validation pipeline for converted model checkpoints. The overall architectural design is robust and highly innovative, integrating GCS polling, multi-agent reasoning loops (Analyst, Fixer, Verifier), standard repo formatting, and automated Airflow re-triggering to resolve validation failures without human intervention.
🔍 General Feedback
- Positive Highlights: The code structure is incredibly clean, modular, and extremely well-organized. Using native Google GenAI SDK chats with automatic function calling provides a highly scalable framework for orchestration.
- Git State Management: The current
git initsetup inside the Docker container is a critical structural issue because it creates a disconnected repository with unrelated history compared to origin, causinggit pushand PR creation to fail. This is easily corrected by initializing the repo and doing a soft reset to align its commit graph with origin. - Environment and Path Configuration: A couple of hardcoded developer laptop absolute paths (
/Users/fiyinbenstowe/...) exist inalerter.pyand the prompt template03_verify.txt. Converting these to relative paths or configuration environment variables ensures seamless operation in Google Cloud Run. - JSON Compatibility: To prevent downstream parse failures in Google Cloud, avoiding non-standard JSON representations like raw
NaNvalues is highly recommended.
1e30195 to
a9b557f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
@gemini-cli /review |
|
🤖 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. |
There was a problem hiding this comment.
This Pull Request introduces the automated Fixer Agent sidecar built natively on the Google GenAI Agent Development Kit (ADK) to complete the checkpoint validation loop. While the overall multi-stage architecture and autonomous self-healing concepts are highly innovative and well-documented, the implementation currently contains multiple critical correctness bugs and missing files that will prevent it from running successfully in production.
🔍 General Feedback
- High Technical Debt & Fragility: The use of runtime regex-based string manipulation and dynamic
exec()to monkeypatch central model restoration routines is extremely fragile. Fixing the underlying bugs directly inside the localmodel_creation_utils.pymodule is a much more maintainable approach. - Robust Exception and Resource Handling: Ensure subprocesses are clean, linting checks are enforced natively, and credentials/environment variables are verified before the container initializes.
- Unused/Superfluous Disables: There are several unnecessary
# pylint: disabledirectives in the files (e.g.pylint: disable=syntax-error) which should be cleaned up to maintain high code-quality scores.
32d854f to
faa66fe
Compare
faa66fe to
7900aa4
Compare
7900aa4 to
3136cee
Compare
3136cee to
e07796f
Compare
Description
This PR introduces the automated Fixer Agent sidecar (
agent_sidecar/) built natively on the Google GenAI Agent Development Kit (ADK). This is the fifth and final PR in the Checkpoint Validation Agent stack (building upon PR #4462, PR #4726, #4727, and #4728), completing the autonomous self-healing checkpoint conversion and validation loop.When checkpoint conversion or validation pipelines fail in Airflow across varied model architectures (e.g. Gemma, Llama, Deepseek, Mistral, Qwen), failures often stem from diagnosable root causes such as
remat_policyout-of-memory errors during evaluation, tensor shape transpositions, or missing configuration overrides. Previously, engineers had to manually inspect logs, formulate patches, lint code, re-trigger pipelines, and open pull requests by hand.This PR provides a containerized, continuously running sidecar service that monitors Google Cloud Storage for validation failure reports, autonomously diagnoses root causes using specialized inspection tools, applies fixes conforming to domain constraints, verifies code against strict repository linting standards (10.00/10 pylint), triggers Airflow validation DAGs, and opens clean GitHub pull requests without human intervention.
Key Implementation Details
adk_agent.pyusing the native Agent Development Kit (ADK), structured around a multi-stage prompt workflow (01_diagnose.txt,02_patch.txt,03_verify.txt, andmeta_agent.txt).* Distinguishing between evaluation vs. training tasks when configuring
remat_policy.* Using
remat_policy=minimalas the standard fallback for evaluation out-of-memory failures.* Escaping JSON braces in diagnostic prompts to prevent prompt injection or formatting collisions.
agent_sidecar/fixer/tools/)analyze_shapes.py: Compares expected vs. actual checkpoint tensor shapes to isolate parameter dimension mismatches.analyze_layer_activations.py: Integrates withlayer_metrics.pyto localize per-layer numerical drift or NaN/Inf contamination.run_linters.py: Runs automatedpylintandpyinkchecks on AI-generated patches, enforcing a strict 10.00/10 pylint score before committing code.trigger_airflow_dag.py: Programmatically re-triggers Airflow DAG runs to verify that code patches resolve the original failure end-to-end.github_branch_manager.py&create_pull_request.py: Automates branch creation, git staging, and GitHub PR submission with detailed root-cause summaries.gcs_poller.pyto continuously poll GCS buckets forFAILEDvalidation JSON reports, coordinated viastate_manager.pyto prevent duplicate repair attempts.Dockerfile&deploy_to_cloud_run.sh) for deployment to Google Cloud Run.Stack
5th PR in stack. Depends on the preceding upstream PR: #4728
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.