Commit 0417faad authored by Kristi Park's avatar Kristi Park Committed by Commit Bot

Revert "[Power ML] Change UserActivityPrediction flag to enabled"

This reverts commit 12c3b65c.

Reason for revert: Suspect for failing PowerPolicy browser_tests, https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/linux-chromeos-rel/20473

Original change's description:
> [Power ML] Change UserActivityPrediction flag to enabled
> 
> Bug: 862461
> Change-Id: I624d39293e50754629b3b30990828af73f57f0b3
> Reviewed-on: https://chromium-review.googlesource.com/c/1482281
> Reviewed-by: Dan Erat <derat@chromium.org>
> Reviewed-by: Steven Holte <holte@chromium.org>
> Commit-Queue: Jia Meng <jiameng@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#634856}

TBR=derat@chromium.org,holte@chromium.org,jiameng@chromium.org

Change-Id: Ic6cee677470af06e5ef5de8d362a2978a37291c2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 862461, 935044
Reviewed-on: https://chromium-review.googlesource.com/c/1484821Reviewed-by: default avatarKristi Park <kristipark@chromium.org>
Commit-Queue: Kristi Park <kristipark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634891}
parent 079c096d
...@@ -222,18 +222,25 @@ void LogPowerMLSmartDimParameterResult(SmartDimParameterResult result) { ...@@ -222,18 +222,25 @@ void LogPowerMLSmartDimParameterResult(SmartDimParameterResult result) {
UMA_HISTOGRAM_ENUMERATION("PowerML.SmartDimParameter.Result", result); UMA_HISTOGRAM_ENUMERATION("PowerML.SmartDimParameter.Result", result);
} }
// Returns "dim_threshold" from experiment parameter. Also logs status to UMA. // Returns "dim_threshold" from experiment parameter. Also logs status to UMA
float GetDimThreshold() { // (i.e. whether the parameter is undefined or cannot be parsed, or can be
const double default_threshold = -0.18; // parsed successfully.
const double dim_threshold = base::GetFieldTrialParamByFeatureAsDouble( base::Optional<float> GetDimThreshold() {
features::kUserActivityPrediction, "dim_threshold", default_threshold); const std::string dim_threshold_str = base::GetFieldTrialParamValueByFeature(
if (std::abs(dim_threshold - default_threshold) < 1e-10) { features::kUserActivityPrediction, "dim_threshold");
LogPowerMLSmartDimParameterResult( if (dim_threshold_str.empty()) {
SmartDimParameterResult::kUseDefaultValue); LogPowerMLSmartDimParameterResult(SmartDimParameterResult::kUndefinedError);
} else { return base::nullopt;
LogPowerMLSmartDimParameterResult(SmartDimParameterResult::kSuccess); }
double dim_threshold_double;
if (!base::StringToDouble(dim_threshold_str, &dim_threshold_double)) {
LogPowerMLSmartDimParameterResult(SmartDimParameterResult::kParsingError);
return base::nullopt;
} }
return dim_threshold;
LogPowerMLSmartDimParameterResult(SmartDimParameterResult::kSuccess);
return base::Optional<float>(dim_threshold_double);
} }
} // namespace } // namespace
...@@ -315,12 +322,12 @@ SmartDimModelResult SmartDimModelImpl::CalculateInactivityScoreTfNative( ...@@ -315,12 +322,12 @@ SmartDimModelResult SmartDimModelImpl::CalculateInactivityScoreTfNative(
UserActivityEvent::ModelPrediction UserActivityEvent::ModelPrediction
SmartDimModelImpl::CreatePredictionFromInactivityScore(float inactivity_score) { SmartDimModelImpl::CreatePredictionFromInactivityScore(float inactivity_score) {
UserActivityEvent::ModelPrediction prediction; UserActivityEvent::ModelPrediction prediction;
const float dim_threshold = GetDimThreshold(); const base::Optional<float> dim_threshold = GetDimThreshold();
prediction.set_decision_threshold(ScoreToProbability(dim_threshold)); prediction.set_decision_threshold(ScoreToProbability(dim_threshold.value()));
prediction.set_inactivity_score(ScoreToProbability(inactivity_score)); prediction.set_inactivity_score(ScoreToProbability(inactivity_score));
if (inactivity_score >= dim_threshold) { if (inactivity_score >= dim_threshold.value()) {
prediction.set_response(UserActivityEvent::ModelPrediction::DIM); prediction.set_response(UserActivityEvent::ModelPrediction::DIM);
} else { } else {
prediction.set_response(UserActivityEvent::ModelPrediction::NO_DIM); prediction.set_response(UserActivityEvent::ModelPrediction::NO_DIM);
...@@ -335,6 +342,11 @@ UserActivityEvent::ModelPrediction SmartDimModelImpl::ShouldDimTfNative( ...@@ -335,6 +342,11 @@ UserActivityEvent::ModelPrediction SmartDimModelImpl::ShouldDimTfNative(
UserActivityEvent::ModelPrediction prediction; UserActivityEvent::ModelPrediction prediction;
prediction.set_response(UserActivityEvent::ModelPrediction::MODEL_ERROR); prediction.set_response(UserActivityEvent::ModelPrediction::MODEL_ERROR);
const base::Optional<float> dim_threshold = GetDimThreshold();
if (!dim_threshold) {
return prediction;
}
float inactivity_score = 0; float inactivity_score = 0;
const SmartDimModelResult result = const SmartDimModelResult result =
CalculateInactivityScoreTfNative(input_features, &inactivity_score); CalculateInactivityScoreTfNative(input_features, &inactivity_score);
...@@ -356,6 +368,12 @@ void SmartDimModelImpl::ShouldDimMlService( ...@@ -356,6 +368,12 @@ void SmartDimModelImpl::ShouldDimMlService(
UserActivityEvent::ModelPrediction prediction; UserActivityEvent::ModelPrediction prediction;
prediction.set_response(UserActivityEvent::ModelPrediction::MODEL_ERROR); prediction.set_response(UserActivityEvent::ModelPrediction::MODEL_ERROR);
const base::Optional<float> dim_threshold = GetDimThreshold();
if (!dim_threshold) {
std::move(callback).Run(prediction);
return;
}
std::vector<float> vectorized_features; std::vector<float> vectorized_features;
auto preprocess_result = auto preprocess_result =
PreprocessInput(input_features, &vectorized_features); PreprocessInput(input_features, &vectorized_features);
......
...@@ -44,8 +44,7 @@ enum class SmartDimParameterResult { ...@@ -44,8 +44,7 @@ enum class SmartDimParameterResult {
kSuccess = 0, kSuccess = 0,
kUndefinedError = 1, kUndefinedError = 1,
kParsingError = 2, kParsingError = 2,
kUseDefaultValue = 3, kMaxValue = kParsingError
kMaxValue = kUseDefaultValue
}; };
// Real implementation of SmartDimModel that predicts whether an upcoming screen // Real implementation of SmartDimModel that predicts whether an upcoming screen
......
...@@ -146,6 +146,25 @@ TEST_F(SmartDimModelImplTest, ShouldDim) { ...@@ -146,6 +146,25 @@ TEST_F(SmartDimModelImplTest, ShouldDim) {
EXPECT_TRUE(callback_done); EXPECT_TRUE(callback_done);
} }
TEST_F(SmartDimModelImplTest, ModelError) {
// Model parameter is undefined, which would trigger a model error.
bool callback_done = false;
smart_dim_model_.RequestDimDecision(
features_, base::BindOnce(
[](bool* callback_done,
UserActivityEvent::ModelPrediction prediction) {
EXPECT_EQ(
UserActivityEvent::ModelPrediction::MODEL_ERROR,
prediction.response());
EXPECT_FALSE(prediction.has_decision_threshold());
EXPECT_FALSE(prediction.has_inactivity_score());
*callback_done = true;
},
&callback_done));
scoped_task_environment_.RunUntilIdle();
EXPECT_TRUE(callback_done);
}
// Check that CancelableCallback ensures a callback doesn't execute twice, in // Check that CancelableCallback ensures a callback doesn't execute twice, in
// case two RequestDimDecision() calls were made before any callback ran. // case two RequestDimDecision() calls were made before any callback ran.
TEST_F(SmartDimModelImplTest, CheckCancelableCallback) { TEST_F(SmartDimModelImplTest, CheckCancelableCallback) {
......
...@@ -80,7 +80,7 @@ const base::Feature kUseMessagesStagingUrl{"UseMessagesStagingUrl", ...@@ -80,7 +80,7 @@ const base::Feature kUseMessagesStagingUrl{"UseMessagesStagingUrl",
// Defined here rather than in //chrome alongside other related features so that // Defined here rather than in //chrome alongside other related features so that
// PowerPolicyController can check it. // PowerPolicyController can check it.
const base::Feature kUserActivityPrediction{"UserActivityPrediction", const base::Feature kUserActivityPrediction{"UserActivityPrediction",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// Enables or disables ML service inferencing (instead of TFNative inferencing) // Enables or disables ML service inferencing (instead of TFNative inferencing)
// for the Smart Dim feature on Chrome OS. // for the Smart Dim feature on Chrome OS.
......
...@@ -43318,10 +43318,6 @@ Called by update_net_trust_anchors.py.--> ...@@ -43318,10 +43318,6 @@ Called by update_net_trust_anchors.py.-->
<int value="2" label="Parsing error"> <int value="2" label="Parsing error">
Threshold parameter was not parsed correctly from string to double. Threshold parameter was not parsed correctly from string to double.
</int> </int>
<int value="3" label="Use default value">
Threshold parameter was not supplied or same as the default value. In either
case, the default value was used.
</int>
</enum> </enum>
<enum name="PowerSupplyType"> <enum name="PowerSupplyType">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment