Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6fd3db5
[RunInference] Add a capacity-based autoscaling signal for model-serv…
AMOOOMA Oct 30, 2026
07aac31
[RunInference] Add prefix-aware batching across workers
AMOOOMA Oct 30, 2026
3610dd1
Clean up docstrings and readability in autoscaling_metrics
AMOOOMA Nov 2, 2026
f84e5f4
Make NumLoadedModelsPublisher a plain sink
AMOOOMA Nov 3, 2026
4345b29
Package the model-server capacity signal behind one call
AMOOOMA Nov 3, 2026
833afa7
Fold the sampler and signal glue into make_model_server_publisher
AMOOOMA Nov 3, 2026
5085d0d
Make AutoscalingMetricConfig plain data
AMOOOMA Nov 3, 2026
746051e
Let NumLoadedModelsPublisher read the server itself
AMOOOMA Nov 3, 2026
098fd25
Describe the capacity signal in requests and state its units
AMOOOMA Nov 3, 2026
3a2d345
Add completion-rate aggregation modes to the capacity estimator
AMOOOMA Nov 3, 2026
a84f728
Tidy the estimator docstring and fill test gaps
AMOOOMA Nov 3, 2026
02b92c3
Reject unsupported keyed batching options and harden num_shards lookup
AMOOOMA Nov 3, 2026
2cd0ec0
Publish the autoscaling metric atomically and time samples monotonically
AMOOOMA Nov 3, 2026
0227bba
Publish the autoscaling metric without touching cell internals
AMOOOMA Nov 5, 2026
7acd8e9
Batch keyed elements with the stateful BatchElements DoFns
AMOOOMA Nov 5, 2026
e2ff8e3
Add DistributionCell.reset_to and skip estimates with no completions
AMOOOMA Nov 5, 2026
b7d9632
Merge remote-tracking branch 'upstream/master' into HEAD
AMOOOMA Nov 5, 2026
a7b46e3
Merge remote-tracking branch 'upstream/master' into HEAD
AMOOOMA Nov 5, 2026
56cf5bf
Fix the default_key_fn type hint for pyrefly
AMOOOMA Nov 5, 2026
465a1d7
Narrow the autoscaling_metrics public API and state its requirements
AMOOOMA Nov 5, 2026
305eeb2
Merge remote-tracking branch 'origin/pr-model-server-autoscaling' int…
AMOOOMA Nov 6, 2026
5687806
[RunInference] vLLM: prefix-aware batching and capacity-based autosca…
AMOOOMA Oct 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
* (Go) Added the standard `millis_instant` and `decimal` logical types for cross-language rows ([#39684](https://github.com/apache/beam/issues/39684)).
* [Beam SQL] Added `PRIMARY KEY (...) NOT ENFORCED` to `CREATE EXTERNAL TABLE`, and `ALTER TABLE ... ADD/DROP PRIMARY KEY` ([#40826](https://github.com/apache/beam/issues/40826)).
* [Beam SQL] Added a `WITH (...)` clause to set per-statement connector options in `FROM` and `INSERT INTO` ([#40848](https://github.com/apache/beam/issues/40848)).
* (Python) `BatchElements` can group elements by key across workers (`key_fn`, `num_shards`), and RunInference model handlers can use it through `batch_key_fn` / `batch_key_num_shards`. `apache_beam.ml.inference.prefix_batching` adds a `PrefixBatchingConfig` and prompt/chat prefix extractors so LLM handlers can batch requests that share a prompt prefix and hit the server's prefix cache ([#40905](https://github.com/apache/beam/pull/40905)).
* (Python) vLLM model handlers accept a `prefix_batching_config` to batch requests that share a prompt prefix, and publish a capacity-based autoscaling signal (`num_loaded_models_<model_identifier>`, estimated from vLLM's completion rate and in-flight requests) so Dataflow's GPU autoscaling scales vLLM workers with load; tune or disable it with `autoscaling_config` / `enable_autoscaling_metric`. `apache_beam.ml.inference.autoscaling_metrics` provides the generic pieces for other model-server handlers ([#40908](https://github.com/apache/beam/pull/40908)).

### Performance

Expand Down
12 changes: 12 additions & 0 deletions sdks/python/apache_beam/metrics/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ def reset(self):
# type: () -> None
self.data = DistributionData.identity_element()

def reset_to(self, value):
"""Atomically replaces the distribution with a single sample of value.

Like ``reset()`` followed by ``update(value)``, except that a concurrent
reader never sees the empty distribution in between. Useful for publishing
the latest value of a gauge-like quantity as a distribution whose
cumulative mean (sum / count) is that value.
"""
ivalue = int(value)
with self._lock:
self.data = DistributionData(ivalue, 1, ivalue, ivalue)

def combine(self, other):
# type: (DistributionCell) -> DistributionCell
result = DistributionCell()
Expand Down
31 changes: 31 additions & 0 deletions sdks/python/apache_beam/metrics/cells_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,37 @@ def test_basic_operations(self):
d.update(900)
self.assertEqual(d.get_cumulative(), DistributionData(912, 3, 2, 900))

def test_reset_to(self):
d = DistributionCell()
d.update(10)
d.update(2)
d.reset_to(7)
self.assertEqual(d.get_cumulative(), DistributionData(7, 1, 7, 7))
d.reset_to(3.6)
self.assertEqual(d.get_cumulative(), DistributionData(3, 1, 3, 3))
d.update(5)
self.assertEqual(d.get_cumulative(), DistributionData(8, 2, 3, 5))

def test_reset_to_never_exposes_an_empty_distribution(self):
d = DistributionCell()
d.reset_to(1)
stop = threading.Event()
counts = set()

def read():
while not stop.is_set():
counts.add(d.get_cumulative().count)

reader = threading.Thread(target=read)
reader.start()
try:
for i in range(20000):
d.reset_to(i % 7 + 1)
finally:
stop.set()
reader.join()
self.assertEqual(counts, {1})

def test_integer_only(self):
d = DistributionCell()
d.update(3.1)
Expand Down
Loading
Loading