You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Pipeline.resize_concurrency runtime API + enable_adaptive_concurrency flag
Summary:
This is Diff 3b in the T262755626 stack. Adds the user-facing API on top of Diff 3a's foundation:
1. `Pipeline.resize_concurrency(qualified_name, new_value)` — synchronous foreground-thread API. Detects in-loop callers via `asyncio.get_running_loop()` and raises RuntimeError to prevent self-deadlock. Lifecycle gated against NOT_STARTED and STOPPED states. Forwards to `_resize_concurrency_async` via `_EventLoop.run_coroutine_threadsafe`.
2. `Pipeline._resize_concurrency_async(qualified_name, new_value)` — async source-of-truth. Safe to call from a `BackgroundTask` or any in-loop coroutine. Updates the registered `ResizableSemaphore` AND the `_dynamic_concurrency` sibling dict atomically (single asyncio turn). Track B's `AdaptiveTuner` (RFC) will use this directly.
3. `Pipeline.list_stages()` — returns sorted qualified names registered with semaphores. Useful for notebook discovery during A/B sweeps.
4. `build_pipeline(..., enable_adaptive_concurrency=False)` and `PipelineBuilder.build(..., enable_adaptive_concurrency=False)` — public flag that wires every Pipe stage with a `ResizableSemaphore` (matching its static `concurrency`) so `Pipeline.resize_concurrency` can adjust admission caps at runtime. Default False keeps the static admission gate (zero per-task overhead) on the no-opt path. Production callers (e.g. LCA's `SPDLConfig.enable_adaptive_concurrency` in Diff 4) use this flag; the existing `_install_semaphores_for_test` knob remains for SPDL's own tests.
V5.7 continuous-mode regression test included: builds a continuous-mode pipeline, runs across 3 epochs, calls `resize_concurrency` mid-run, and verifies (a) no crash on epoch sentinel propagation, (b) resized cap takes effect for subsequent items, (c) in-flight items at resize time complete normally.
Error semantics:
- `KeyError` on unknown qualified_name; the message lists valid names from the registry.
- `ValueError` on `new_value < 1`.
- `RuntimeError` on lifecycle violations or in-loop sync calls.
Documentation note included in `resize_concurrency` docstring: Meta-internal dashboards (e.g., `_logging.py`) currently report build-time `StageInfo.concurrency` and do not reflect resizes performed via this API. Operators reading live values from a notebook should use `list_stages()` and `pipeline._impl._dynamic_concurrency` directly. Future Track B work may extend Meta logging to read the dict.
Differential Revision: D102929252
0 commit comments