Eliaaazzz commented on code in PR #37532:
URL: https://github.com/apache/beam/pull/37532#discussion_r3014257356


##########
sdks/python/apache_beam/testing/benchmarks/sort_and_batch_benchmark.py:
##########
@@ -0,0 +1,650 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""Benchmark: BatchElements vs SortAndBatchElements (weight-based splitting).
+
+Compares two batching strategies for variable-length inference workloads:
+
+- Baseline (BatchElements): fixed-count chunking, ignores element sizes.
+- Stateless (SortAndBatchElements): within each bundle, sorts elements
+  by size, then splits batches using max_batch_weight so that each batch
+  has a bounded total weight.  The improvement comes from *changing batch
+  boundaries* (weight-based splitting), NOT from sorting alone -- sorting
+  within fixed boundaries yields 0% gain (verified by strict-control).

Review Comment:
   > > The improvement comes from _changing batch
   > > boundaries_ (weight-based splitting), NOT from sorting alone
   > 
   > This is surprising to me - doesn't sorting the batch functionally change 
the batch boundaries as well?
   
   It does. The comment is misleading. What I meant is that sorting alone (with 
fixed count-based boundaries) yields ~0% gain, which is what the strict-control 
ablation verified. The actual improvement comes from sorting combined with 
weight-based splitting, where similar-sized elements cluster together and the 
weight constraint produces tighter batches. I'll reframe the comment to make 
that clearer.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to