[DECOUPLED-MODE] Checkpointing: import GCS via decoupling stub in dynamic loader#91
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Route the dynamic HuggingFace checkpoint loader's Google Cloud Storage access through the existing decoupling helper instead of importing it directly.
Previously,
src/maxtext/checkpoint_conversion/utils/load_dynamic.pydid a top-levelfrom google.cloud import storage. In "decoupled" environments (DECOUPLE_GCLOUD=TRUE), where optional Google Cloud dependencies are intentionally not installed, this unconditional import raisedImportError: cannot import name 'storage' from 'google.cloud'at module load.Because
load_dynamicis pulled in transitively bymaxtext.common.checkpointing(and thus bymaxtext/__init__), the erroraborted the entire pytest collection at
tests/conftest.pyimport time, so the full decoupled test suite failed before running a single test.The rest of the codebase already accesses GCS through
maxtext.common.gcloud_stub.gcs_storage(), which returns the realgoogle.cloud.storagemodule when available and a no-op stub otherwise. This PR makesload_dynamic.pyfollow that same pattern:from google.cloud import storagewithfrom maxtext.common.gcloud_stub import gcs_storage.storage = gcs_storage()at module scope, so the existingstorage.Client()/list_blobs(...)call sites are unchanged.This is a minimal, low-risk change: in non-decoupled runs behavior is identical (real
google.cloud.storage, now withtransfer_managerattached by the helper); in decoupled runs the module imports cleanly and GCS calls are stubbed.No functional GCS behavior changes for real workloads.
Tests
Verified in the ROCm TheRock 7.14 MaxText container with the decoupled venv (
DECOUPLE_GCLOUD=TRUE,PYTHONPATH=src):python -c "import maxtext.checkpoint_conversion.utils.load_dynamic as m; print(m.storage._IS_STUB)"imports OK, prints
True(stub) in decoupled mode.pytest -m 'not cpu_only and not tpu_only and not post_training and decoupled' tests --ignore=tests/post_training2664 collected / 481 deselected / 2 skipped / 2183 selected, no collection error; tests execute normally.Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.