Copilot commented on code in PR #12511: URL: https://github.com/apache/gluten/pull/12511#discussion_r3587630284
########## 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), but `StageExecutionMode.fromId(0)` always returns `CPUStageMode`. If `id` is ever used for serialization/deserialization (or logging/metrics keyed by id), this makes `MockGPUStageMode` ambiguous and effectively non-roundtrippable. ########## gluten-substrait/src/main/scala/org/apache/spark/shuffle/GlutenShuffleUtils.scala: ########## @@ -171,7 +173,8 @@ object GlutenShuffleUtils { blocksByAddress, context, metrics, - shouldBatchFetch)) + shouldBatchFetch, + executionMode)) .shuffleReader Review Comment: The new `executionMode` is plumbed into `GenShuffleReaderParameters`, but the current backend implementations of `SparkPlanExecApi.genColumnarShuffleReader` (e.g. Velox `ShuffleUtil.genColumnarShuffleReader`) don’t consult `parameters.executionMode` and always build the same reader. As a result, reducer-stage execution mode is not actually influencing shuffle reader selection yet, which looks like it undermines the goal of independently choosing CPU vs GPU shuffle readers per stage. ########## 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 path hard-codes `CPUStageMode` and leaves a `FIXME` to “pass proper StageExecutionMode”. With stage execution modes now being propagated across shuffle boundaries, always using `CPUStageMode` here can select the wrong shuffle reader implementation when this operator runs inside a GPU stage (and the FIXME suggests this is a known gap). ########## 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 path hard-codes `CPUStageMode` and leaves a `FIXME` to “pass proper StageExecutionMode”. With stage execution modes now being propagated across shuffle boundaries, always using `CPUStageMode` here can select the wrong shuffle reader implementation when this operator runs inside a GPU stage (and the FIXME suggests this is a known gap). -- 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]
