Copilot commented on code in PR #12511:
URL: https://github.com/apache/gluten/pull/12511#discussion_r3587690834


##########
gluten-substrait/src/main/scala/org/apache/gluten/execution/StageExecutionMode.scala:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+package org.apache.gluten.execution
+
+trait StageExecutionMode {
+  def name: String = this.getClass.getSimpleName.replaceAll("\\$", "")
+  def id: Int
+}
+
+case object CPUStageMode extends StageExecutionMode {
+  override def id: Int = 0
+}
+case object GPUStageMode extends StageExecutionMode {
+  override def id: Int = 1
+}
+case object MockGPUStageMode extends StageExecutionMode {
+  override def id: Int = 0
+}
+
+object StageExecutionMode {
+  def fromId(id: Int): StageExecutionMode = id match {
+    case 0 => CPUStageMode
+    case 1 => GPUStageMode
+    case _ => throw new IllegalArgumentException(s"Unknown StageExecutionMode 
id: $id")
+  }
+}

Review Comment:
   `MockGPUStageMode` currently uses the same `id` as `CPUStageMode` (0) and 
`StageExecutionMode.fromId` cannot round-trip it. This makes the `id` field 
ambiguous and can lead to incorrect mode reconstruction if the `id` is ever 
serialized (e.g., through shuffle metadata or plan tags).



##########
gluten-substrait/src/main/scala/org/apache/gluten/execution/ColumnarCollectTailBaseExec.scala:
##########
@@ -101,7 +101,9 @@ abstract class ColumnarCollectTailBaseExec(
         metrics,
         shuffleWriterType
       ),
-      readMetrics
+      readMetrics,
+      // FIXME: pass proper StageExecutionMode
+      CPUStageMode
     )

Review Comment:
   This shuffle read is hard-coded to `CPUStageMode` with a `FIXME`. With stage 
execution modes now influencing shuffle reader/writer and batch-resizing 
behavior, this risks running tail-collection shuffles with a mismatched 
execution mode when the upstream stage is GPU-marked.



##########
gluten-substrait/src/main/scala/org/apache/gluten/execution/ColumnarCollectLimitBaseExec.scala:
##########
@@ -102,7 +102,9 @@ abstract class ColumnarCollectLimitBaseExec(
         metrics,
         shuffleWriterType
       ),
-      readMetrics
+      readMetrics,
+      // FIXME: pass proper StageExecutionMode
+      CPUStageMode
     )

Review Comment:
   This shuffle read is hard-coded to `CPUStageMode` with a `FIXME`. With the 
new stage execution mode propagation, this can produce inconsistent shuffle 
behavior when the upstream plan is marked for GPU execution (e.g., GPU shuffle 
writer + CPU shuffle reader) and leaves a known TODO in production code.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to