Skip to content

examples: wire TensorBoardWriter into trainer entry points#623

Draft
kmontemayor2-sc wants to merge 4 commits intomainfrom
kmonte/tb-trainer-examples
Draft

examples: wire TensorBoardWriter into trainer entry points#623
kmontemayor2-sc wants to merge 4 commits intomainfrom
kmonte/tb-trainer-examples

Conversation

@kmontemayor2-sc
Copy link
Copy Markdown
Collaborator

Adds chief-rank TensorBoard event emission to the four example trainer
entry points (homogeneous + heterogeneous, single-pool + graph-store).
Each trainer now:

  • constructs tensorboard_writer = TensorBoardWriter.from_env(enabled=is_chief_process)
  • calls tensorboard_writer.log({...}, step=batch_idx) for train,
    val, and test loss curves
  • closes the writer at the end (paired uploader shutdown)

Updates the example resource configs with both
tensorboard_resource_name and tensorboard_experiment_name
(populated with the placeholder user-provided-experiment-name
valid under the Vertex AI Experiment ID regex enforced by validation).

The CORA task config gains a comment pointing at the new proto field.
The README adds a TensorBoard section documenting the two fields and
the URL-in-stdout flow.

The writer files (gigl/utils/tensorboard_writer.py +
tests/unit/utils/tensorboard_writer_test.py) ride along since this
PR depends on them; they're owned by the writer PR and will collapse
out of this diff once that PR merges.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com

kmontemayor and others added 4 commits May 6, 2026 18:48
Adds two optional fields on ``VertexAiResourceConfig`` for opting into
Vertex AI TensorBoard. ``tensorboard_resource_name`` points at an
existing ``Tensorboard`` resource; ``tensorboard_experiment_name`` is
the user-chosen ``TensorboardExperiment`` ID under that resource —
multiple jobs sharing this name surface as comparable runs on the same
TB page.

The fields must be set together (or both unset). The validation rule is
not enforced yet (lands in a follow-up PR); this commit only adds the
proto fields and regenerates Python + Scala stubs.

Also expands the docstring on ``TrainedModelMetadata.tensorboard_logs_uri``
to document its mapping to ``AIP_TENSORBOARD_LOG_DIR`` via
``CustomJobSpec.baseOutputDirectory``.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the launcher-side TensorBoard plumbing. After this PR, callers
that pass ``tensorboard_logs_uri`` get ``baseOutputDirectory`` set on
the CustomJob, and resource configs that set
``tensorboard_experiment_name`` get three env vars injected into the
worker container so the trainer's chief-rank uploader can find the
named experiment.

- ``_build_job_config`` accepts ``tensorboard_logs_uri: Optional[Uri]``
  and derives ``base_output_dir`` from it.
- When the resource config sets ``tensorboard_experiment_name``, inject
  ``GIGL_TENSORBOARD_RESOURCE_NAME``, ``GIGL_TENSORBOARD_EXPERIMENT_NAME``,
  and ``GIGL_TENSORBOARD_RUN_NAME`` (sanitized + UTC-suffixed for
  per-launch uniqueness).
- ``_maybe_log_tensorboard_url`` prints the cross-job TB experiment URL
  at submit time so the link is visible in the launcher's local stdout.
- ``VertexAiJobConfig`` gains a ``base_output_dir`` field, threaded
  through to ``aiplatform.CustomJob``.
- ``get_tensorboard_logs_gcs_path`` now returns ``<asset_dir>/logs/``
  (was ``<asset_dir>/tensorboard_logs/``), aligning with Vertex AI's
  ``<base_output_dir>/logs/`` convention so writer events land where
  ``AIP_TENSORBOARD_LOG_DIR`` points. Updates the ConfigPopulator unit
  test that asserts on the path suffix.

Reading the new fields off the resource config and the
``tensorboard_logs_uri`` off the GbmlConfig is deferred to the next PR
(trainer/inferencer dispatch) — production trainers don't pass
``tensorboard_logs_uri`` yet, so this change is invisible to existing
production runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reads ``TrainedModelMetadata.tensorboard_logs_uri`` from the GbmlConfig
and threads it into ``launch_single_pool_job`` /
``launch_graph_store_enabled_job`` from both ``GLTTrainer`` and
``GLTInferencer``.

After this PR, the launcher (PR 3) actually receives the GCS path on
real training and inference jobs, which means ``baseOutputDirectory``
gets set on the CustomJob and ``AIP_TENSORBOARD_LOG_DIR`` is populated
inside the worker container. The chief-rank uploader / writer (next
PR) is what reads those env vars and starts streaming events.

Sharing ``tensorboard_logs_uri`` across trainer and inferencer is
deliberate: Vertex's ``baseOutputDirectory`` is component-agnostic, and
the launcher injects a different ``GIGL_TENSORBOARD_RUN_NAME`` per job
(``gigl_train_<task>`` vs ``gigl_infer_<task>``), so the two surface as
separate runs in the same ``TensorboardExperiment``.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds chief-rank TensorBoard event emission to the four example trainer
entry points (homogeneous + heterogeneous, single-pool + graph-store).
Each trainer now:

- constructs ``tensorboard_writer = TensorBoardWriter.from_env(enabled=is_chief_process)``
- calls ``tensorboard_writer.log({...}, step=batch_idx)`` for train,
  val, and test loss curves
- closes the writer at the end (paired uploader shutdown)

Updates the example resource configs with both
``tensorboard_resource_name`` and ``tensorboard_experiment_name``
(populated with the placeholder ``user-provided-experiment-name`` —
valid under the Vertex AI Experiment ID regex enforced by validation).

The CORA task config gains a comment pointing at the new proto field.
The README adds a TensorBoard section documenting the two fields and
the URL-in-stdout flow.

The writer files (``gigl/utils/tensorboard_writer.py`` +
``tests/unit/utils/tensorboard_writer_test.py``) ride along since this
PR depends on them; they're owned by the writer PR and will collapse
out of this diff once that PR merges.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kmontemayor2-sc
Copy link
Copy Markdown
Collaborator Author

/all_test

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

GiGL Automation

@ 20:32:38UTC : 🔄 Scala Unit Test started.

@ 20:41:39UTC : ✅ Workflow completed successfully.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

GiGL Automation

@ 20:32:39UTC : 🔄 Lint Test started.

@ 20:42:54UTC : ✅ Workflow completed successfully.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

GiGL Automation

@ 20:32:43UTC : 🔄 C++ Unit Test started.

@ 20:34:42UTC : ✅ Workflow completed successfully.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

GiGL Automation

@ 20:32:44UTC : 🔄 E2E Test started.

@ 21:57:00UTC : ❌ Workflow failed.
Please check the logs for more details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

GiGL Automation

@ 20:32:46UTC : 🔄 Python Unit Test started.

@ 21:27:11UTC : ✅ Workflow completed successfully.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

GiGL Automation

@ 20:32:47UTC : 🔄 Integration Test started.

@ 21:50:25UTC : ✅ Workflow completed successfully.

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.

1 participant