Repository navigation
fix(examples): eliminate managed_xprof startup race and align image name - #1502
CatherineF-dev wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.
| jax.profiler.start_server(profiler_port) | ||
| print(f"JAX profiler server listening on port {profiler_port}.", flush=True) |
There was a problem hiding this comment.
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.
| 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) |
dec110a to
5e1f158
Compare
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
d9de688 to
58889d2
Compare
5e1f158 to
f69d12e
Compare
PR Stack
fix(reconciler): cache mlrun urls across batch flush window and downgrade 409 logsfix(verifier): auto-validate managed_xprof xprof_url and honor expected_title_patternfix(examples): eliminate managed_xprof startup race and align image name👉 Current PRSummary
Eliminates the startup race in
examples/managed_xprof_artifact_jobby pre-registering theEXECUTION-phaseManagedXprofArtifactbefore creating eachWorkUnit, starts the on-demand JAX profiler server after programmatic tracing completes, and aligns the default container image name tomanaged-xprof-artifact-job.Motivation & Context
Creating a
WorkUnitbefore attaching itsManagedXprofArtifactallows the initial Actuator and Reconciler passes to run beforedisplay_nameandrun_groupexist in Experiment State Server. Startingjax.profiler.start_server(9999)beforejax.profiler.stop_trace()also risks concurrent on-demand capture collisions during programmatic tracing.Key Changes
examples/managed_xprof_artifact_job/launch.pyandREADME.mdto pre-create theEXECUTION-phaseManagedXprofArtifactunderexperiments/{xid}/workUnits/{wid}before callingCreateWorkUnit(work_unit_id=wid)viaexperiment_state_api.examples/managed_xprof_artifact_job/worker.pyto startjax.profiler.start_server(9999)afterjax.profiler.stop_trace()completes.programmatic-xprof-jobtomanaged-xprof-artifact-jobinbuild_and_push.sh,launch.py, and.github/workflows/nightly-examples-e2e.yml.Assumptions
None — requirements were fully specified.
Verification & Testing
./tools/run_affected_tests.py --skip-emulator-checkRelated Issues / Bugs
N/A
TAG=agy
CONV=108bc446-88fa-4cbf-b70b-e3e5e9c917c5