8000 fix(examples): eliminate managed_xprof startup race and align image name by CatherineF-dev · Pull Request #1502 · google/xmc · GitHub
[go: up one dir, main page]

Skip to content

fix(examples): eliminate managed_xprof startup race and align image name - #1502

Draft
CatherineF-dev wants to merge 1 commit into
fix/verifier-managed-xprof-urlfrom
fix/examples-managed-xprof-startup-race
Draft

CatherineF-dev wants to merge 1 commit into
fix/verifier-managed-xprof-urlfrom
fix/examples-managed-xprof-startup-race

Conversation

@CatherineF-dev
@CatherineF-dev CatherineF-dev commented Oct 30, 2026 •
Copy link
Copy Markdown
Collaborator

PR Stack

Summary

Eliminates the startup race in examples/managed_xprof_artifact_job by pre-registering the EXECUTION-phase ManagedXprofArtifact before creating each WorkUnit, starts the on-demand JAX profiler server after programmatic tracing completes, and aligns the default container image name to managed-xprof-artifact-job.

Motivation & Context

Creating a WorkUnit before attaching its ManagedXprofArtifact allows the initial Actuator and Reconciler passes to run before display_name and run_group exist in Experiment State Server. Starting jax.profiler.start_server(9999) before jax.profiler.stop_trace() also risks concurrent on-demand capture collisions during programmatic tracing.

Key Changes

  • Updated examples/managed_xprof_artifact_job/launch.py and README.md to pre-create the EXECUTION-phase ManagedXprofArtifact under experiments/{xid}/workUnits/{wid} before calling CreateWorkUnit(work_unit_id=wid) via experiment_state_api.
  • Updated examples/managed_xprof_artifact_job/worker.py to start jax.profiler.start_server(9999) after jax.profiler.stop_trace() completes.
  • Renamed default container image from programmatic-xprof-job to managed-xprof-artifact-job in build_and_push.sh, launch.py, and .github/workflows/nightly-examples-e2e.yml.

Assumptions

None — requirements were fully specified.

Verification & Testing

  • Commands Executed: ./tools/run_affected_tests.py --skip-emulator-check
  • Coverage & Test Status: All pre-commit linters and affected tests pass; verified end-to-end on a live GKE development environment.

Related Issues / Bugs

N/A

TAG=agy
CONV=108bc446-88fa-4cbf-b70b-e3e5e9c917c5

@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 refactors the XManager Cloud launch example to pre-create the ManagedXprof artifact before submitting work units with explicit IDs, eliminating startup races between the Actuator and the Diagon Reconciler. Additionally, the worker is updated to start the JAX profiler server only after programmatic tracing completes to prevent trace collisions. Feedback suggests wrapping the JAX profiler server startup in a try-except block to prevent port-binding failures from crashing the entire workload.

Comment on lines +76 to +77
jax.profiler.start_server(profiler_port)
print(f"JAX profiler server listening on port {profiler_port}.", flush=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If the profiler port is already in use or another startup error occurs, start_server will raise an exception and crash the entire workload, even though programmatic tracing has already completed successfully. Wrapping start_server in a try-except block ensures the workload can continue running its remaining steps.

Suggested change
jax.profiler.start_server(profiler_port)
print(f"JAX profiler server listening on port {profiler_port}.", flush=True)
try:
jax.profiler.start_server(profiler_port)
print(f'JAX profiler server listening on port {profiler_port}.', flush=True)
except Exception as e:
print(f'Failed to start JAX profiler server on port {profiler_port}: {e}. On-demand profiling will be unavailable.', flush=True)

@CatherineF-dev
CatherineF-dev force-pushed the fix/examples-managed-xprof-startup-race branch from dec110a to 5e1f158 Compare October 30, 2026 14:54
Creating a WorkUnit before attaching its EXECUTION-phase ManagedXprofArtifact
introduces a startup race where the initial Actuator scheduling pass or
Diagon Reconciler pass can run before display_name and run_group exist in
Experiment State Server. In addition, starting the on-demand JAX profiler
server on port 9999 before jax.profiler.stop_trace() completes allows
interactive captures to collide with an active programmatic trace session.

- Pre-create the EXECUTION-phase ManagedXprofArtifact under
  experiments/{xid}/workUnits/{wid} before calling CreateWorkUnit with an
  explicit work_unit_id={wid} via the public experiment_state_api client,
  eliminating the startup race as well as misleading SDK/ESS warnings.
- Start jax.profiler.start_server(9999) after jax.profiler.stop_trace()
  finishes in worker.py so on-demand captures cannot collide with an active
  programmatic trace session.
- Align the default container image name from programmatic-xprof-job to
  managed-xprof-artifact-job across build_and_push.sh, launch.py, and
  .github/workflows/nightly-examples-e2e.yml.

TAG=agy
CONV=108bc446-88fa-4cbf-b70b-e3e5e9c917c5
@CatherineF-dev
CatherineF-dev force-pushed the fix/verifier-managed-xprof-url branch from d9de688 to 58889d2 Compare October 30, 2026 15:18
@CatherineF-dev
CatherineF-dev force-pushed the fix/examples-managed-xprof-startup-race branch from 5e1f158 to f69d12e Compare October 30, 2026 15:18

This branch has not been deployed

No deployments
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

0