dotnet / machinelearning

ML.NET is an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
8.92k stars 1.86k forks source link

Torch sharp version updates and test fixes #6954

Closed michaelgsharp closed 5 months ago

michaelgsharp commented 5 months ago

This PR updates the version of TorchSharp to the latest version to take advantage of some of the bug fixes it has that have been reported to us by some of our users.

It also fixes some test issues (makes the memory intensive ones actually run sequentially, they weren't doing it correctly before), and fixes the test namespace in the new test projects.

ericstj commented 5 months ago

At least one of the code-coverage failures mentions torchsharp: https://dev.azure.com/dnceng-public/public/_build/results?buildId=528996&view=ms.vss-test-web.build-test-results-tab&runId=12474756&resultId=101332&paneView=debug

System.DllNotFoundException : Unable to load DLL 'LibTorchSharp' or one of its dependencies: The specified module could not be found. (0x8007007E)

Stack trace
   at TorchSharp.PInvoke.NativeMethods.THSNN_custom_module(String name, ForwardFunctionC forward, IntPtr& pBoxedModule)
   at TorchSharp.torch.nn.Module..ctor(String name)
   at TorchSharp.torch.nn.HookableModule`2..ctor(String name)
   at TorchSharp.torch.nn.Module`3..ctor(String name)
   at Microsoft.ML.TorchSharp.NasBert.Models.BaseModel..ctor(NasBertOptions options) in D:\a\_work\1\s\src\Microsoft.ML.TorchSharp\NasBert\Models\BaseModel.cs:line 25
   at Microsoft.ML.TorchSharp.NasBert.Models.NasBertModel..ctor(NasBertOptions options, Int32 padIndex, Int32 symbolsCount) in D:\a\_work\1\s\src\Microsoft.ML.TorchSharp\NasBert\Models\NasBertModel.cs:line 18
   at Microsoft.ML.TorchSharp.NasBert.Models.ModelForPrediction..ctor(NasBertOptions options, Int32 padIndex, Int32 symbolsCount, Int32 numClasses) in D:\a\_work\1\s\src\Microsoft.ML.TorchSharp\NasBert\Models\ModelPrediction.cs:line 17
   at Microsoft.ML.TorchSharp.NasBert.NasBertTrainer`2.NasBertTrainerBase.CreateModule(IChannel ch, IDataView input) in D:\a\_work\1\s\src\Microsoft.ML.TorchSharp\NasBert\NasBertTrainer.cs:line 210
   at Microsoft.ML.TorchSharp.TorchSharpBaseTrainer`2.TrainerBase..ctor(TorchSharpBaseTrainer`2 parent, IChannel ch, IDataView input, String modelUrl) in D:\a\_work\1\s\src\Microsoft.ML.TorchSharp\TorchSharpBaseTrainer.cs:line 155
   at Microsoft.ML.TorchSharp.NasBert.NasBertTrainer`2.NasBertTrainerBase..ctor(TorchSharpBaseTrainer`2 parent, IChannel ch, IDataView input, String modelUrl) in D:\a\_work\1\s\src\Microsoft.ML.TorchSharp\NasBert\NasBertTrainer.cs:line 185
   at Microsoft.ML.TorchSharp.NasBert.TextClassificationTrainer.Trainer..ctor(TorchSharpBaseTrainer`2 parent, IChannel ch, IDataView input) in D:\a\_work\1\s\src\Microsoft.ML.TorchSharp\NasBert\TextClassificationTrainer.cs:line 116
   at Microsoft.ML.TorchSharp.NasBert.TextClassificationTrainer.CreateTrainer(TorchSharpBaseTrainer`2 parent, IChannel ch, IDataView input) in D:\a\_work\1\s\src\Microsoft.ML.TorchSharp\NasBert\TextClassificationTrainer.cs:line 104
   at Microsoft.ML.TorchSharp.TorchSharpBaseTrainer`2.Fit(IDataView input) in D:\a\_work\1\s\src\Microsoft.ML.TorchSharp\TorchSharpBaseTrainer.cs:line 107
   at Microsoft.ML.Data.EstimatorChain`1.Fit(IDataView input) in D:\a\_work\1\s\src\Microsoft.ML.Data\DataLoadSave\EstimatorChain.cs:line 68
   at Microsoft.ML.RunTests.TestDataPipeBase.TestEstimatorCore(IEstimator`1 estimator, IDataView validFitInput, IDataView validTransformInput, IDataView invalidInput, IDataView validForFitNotValidForTransformInput, Boolean shouldDispose) in D:\a\_work\1\s\test\Microsoft.ML.TestFramework\DataPipe\TestDataPipeBase.cs:line 80
   at Microsoft.ML.TorchSharp.Tests.TextClassificationTests.TestSingleSentence3Classes() in D:\a\_work\1\s\test\Microsoft.ML.TorchSharp.Tests\TextClassificationTests.cs:line 239
codecov[bot] commented 5 months ago

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (d0d8569) 68.80% compared to head (b8f4b4a) 68.80%. Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6954 +/- ## ========================================== - Coverage 68.80% 68.80% -0.01% ========================================== Files 1249 1249 Lines 249644 249686 +42 Branches 25481 25485 +4 ========================================== + Hits 171778 171800 +22 - Misses 71275 71292 +17 - Partials 6591 6594 +3 ``` | [Flag](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | Coverage Δ | | |---|---|---| | [Debug](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | `68.80% <0.00%> (-0.01%)` | :arrow_down: | | [production](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | `63.27% <0.00%> (-0.01%)` | :arrow_down: | | [test](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | `88.41% <0.00%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet) | Coverage Δ | | |---|---|---| | [...t/Microsoft.ML.TensorFlow.Tests/TensorflowTests.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuVGVuc29yRmxvdy5UZXN0cy9UZW5zb3JmbG93VGVzdHMuY3M=) | `91.64% <ø> (-0.08%)` | :arrow_down: | | [test/Microsoft.ML.TorchSharp.Tests/NerTests.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuVG9yY2hTaGFycC5UZXN0cy9OZXJUZXN0cy5jcw==) | `67.02% <ø> (ø)` | | | [...rosoft.ML.TorchSharp.Tests/ObjectDetectionTests.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuVG9yY2hTaGFycC5UZXN0cy9PYmplY3REZXRlY3Rpb25UZXN0cy5jcw==) | `100.00% <ø> (ø)` | | | [test/Microsoft.ML.TorchSharp.Tests/QATests.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuVG9yY2hTaGFycC5UZXN0cy9RQVRlc3RzLmNz) | `40.50% <ø> (ø)` | | | [...oft.ML.TorchSharp.Tests/TextClassificationTests.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-dGVzdC9NaWNyb3NvZnQuTUwuVG9yY2hTaGFycC5UZXN0cy9UZXh0Q2xhc3NpZmljYXRpb25UZXN0cy5jcw==) | `85.17% <0.00%> (ø)` | | | [....TorchSharp/AutoFormerV2/ObjectDetectionTrainer.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-c3JjL01pY3Jvc29mdC5NTC5Ub3JjaFNoYXJwL0F1dG9Gb3JtZXJWMi9PYmplY3REZXRlY3Rpb25UcmFpbmVyLmNz) | `86.57% <0.00%> (ø)` | | | [src/Microsoft.ML.TorchSharp/Roberta/QATrainer.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-c3JjL01pY3Jvc29mdC5NTC5Ub3JjaFNoYXJwL1JvYmVydGEvUUFUcmFpbmVyLmNz) | `78.30% <0.00%> (ø)` | | | [...c/Microsoft.ML.TorchSharp/TorchSharpBaseTrainer.cs](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet#diff-c3JjL01pY3Jvc29mdC5NTC5Ub3JjaFNoYXJwL1RvcmNoU2hhcnBCYXNlVHJhaW5lci5jcw==) | `84.98% <0.00%> (ø)` | | ... and [13 files with indirect coverage changes](https://app.codecov.io/gh/dotnet/machinelearning/pull/6954/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dotnet)
michaelgsharp commented 5 months ago

/backport to release/3.0

github-actions[bot] commented 5 months ago

Started backporting to release/3.0: https://github.com/dotnet/machinelearning/actions/runs/7550850328