Skip to content

Add cancellation checkpoint in logistic regression. - #3032

Merged
codemzs merged 2 commits into
dotnet:masterfrom
codemzs:lrcancellationcheckpoint
Mar 22, 2019
Merged

Add cancellation checkpoint in logistic regression.#3032
codemzs merged 2 commits into
dotnet:masterfrom
codemzs:lrcancellationcheckpoint

Conversation

@codemzs

@codemzscodemzs commented Mar 20, 2019

Copy link
Copy Markdown
Member

fixes#3031

Please read the issue before reviewing this PR.

@codecov

codecovBot commented Mar 20, 2019

Copy link
Copy Markdown

Codecov Report

Merging #3032 into master will increase coverage by 0.09%.
The diff coverage is 100%.

@@ Coverage Diff @@## master #3032 +/- ##
==========================================
+ Coverage 72.41% 72.5% +0.09% 
==========================================
Files 803 804 +1 Lines 143851 144080 +229 Branches 16173 16179 +6 ==========================================
+ Hits 104171 104467 +296 + Misses 35258 35197 -61 + Partials 4422 4416 -6
FlagCoverage Δ
#Debug72.5% <100%> (+0.09%)⬆️
#production68.15% <100%> (+0.06%)⬆️
#test88.69% <ø> (+0.08%)⬆️
Impacted FilesCoverage Δ
.../Standard/LogisticRegression/LbfgsPredictorBase.cs71.33% <100%> (+0.06%)⬆️
...crosoft.ML.StandardTrainers/Optimizer/Optimizer.cs73.41% <100%> (+0.07%)⬆️
...soft.ML.Data/DataView/DataViewConstructionUtils.cs85.27% <0%> (-0.9%)⬇️
src/Microsoft.ML.Transforms/Text/LdaTransform.cs89.26% <0%> (-0.63%)⬇️
src/Microsoft.ML.FastTree/TreeTrainersCatalog.cs94.18% <0%> (ø)⬆️
...soft.ML.Data/DataLoadSave/DataOperationsCatalog.cs73.23% <0%> (ø)⬆️
...osoft.ML.Data/DataView/InternalSchemaDefinition.cs56.94% <0%> (ø)⬆️
...crosoft.ML.StandardTrainers/Standard/SdcaBinary.cs72.68% <0%> (ø)⬆️
...osoft.ML.Functional.Tests/SchemaDefinitionTests.cs98.46% <0%> (ø)
test/Microsoft.ML.Tests/Scenarios/Api/TestApi.cs97.63% <0%> (+0.01%)⬆️
... and 11 more

@codemzs
codemzs requested a review from wschinMarch 20, 2019 17:37
@rogancarr

Copy link
Copy Markdown
Contributor

What's the performance implications here?

while (cursor.MoveNext())
{
Host.CheckAlive();
WeightSum += cursor.Weight;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel it's not the only place we need a check point.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, added one more in Line Search Minimize function.

@wschin

Copy link
Copy Markdown
Contributor
 }

This looks very suspicious. Could you add some check points to this function? I also feel we need to perf algs before adding checking points.


Refers to: src/Microsoft.ML.StandardTrainers/Standard/LogisticRegression/LbfgsPredictorBase.cs:567 in 5540101. [](commit_id = 5540101, deletion_comment = False)

e => e.SetProgress(0, exCount, totalCount));
while (cursor.MoveNext())
{
Host.CheckAlive();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Host.CheckAlive(); [](start = 18, length = 20)

is it too much to do it in every row fetch? would it be enough to do it every 10 cursor moves, or some other number > 1.
(idk if there are any best practiced on how to determine the frequency of checks , from maybe the CancellationToken implementations)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And how is that any more efficient than what we have now? You will end up executing an if condition on every row fetch ... based on my analysis of the current solution this doesn’t add any significant overhead.

Cancellation token works differently. You register a callback with it and when a signal is sent it invokes the callback and you do work to gracefully shutdown a process. Our plan is to implement cancellation token post 1.0.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We spoke offline. I think this is the best we can do until we get cancellation tokens into the mix. CheckAlive only checks a bool property, so it's probably faster than checking to see if it's the 10th iteration or not.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To add some late flavor to this, the branch predictor should be slightly better at the (almost perfectly) constant bool property, than the return value from iteration % 10 (including the hidden division operation..could check every 8 as the compiler should optimize to a bitwise AND).

That said, there's the overhead of the CheckAlive() function call which maybe greater if not inlined.

@codemzs
codemzs merged commit b6c5b70 into dotnet:masterMar 22, 2019
@codemzscodemzs mentioned this pull request Apr 2, 2019
@ghostghost locked as resolved and limited conversation to collaborators Mar 23, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cancellation checkpoints in LogisticRegression

5 participants

@codemzs@rogancarr@wschin@justinormont@sfilipi