Commit graph

215 commits

Author SHA1 Message Date
liqunfu
d7233c7c97
Fix training for models with dict input (#4842)
This PR also includes:
	* Remove defaults from named tuples to support python 3.6
	* Allows model which takes dicts as input
	* Adapts BERT finetuning example to run on the new frontend
        * Match numbers for BERT fine tuning model

Co-authored-by: liqun <liqun@OrtTrainingDev4.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>
2020-08-19 18:36:36 -07:00
Thiago Crepaldi
7cc88ef7ed
Port legacy checkpoint API into new front-end (#4855)
* Port legacy checkpoint API into new front-end

This PR also fixes:
	* Warnings on ORTTrainer for improper tensor copies
	* Inaccurate LRScheduler tests using wrong LR
	* Stale DeepSpeed documentation
	* Minor code refactoring for Toy BERT tests
        * Move experimental state_dict() and load_state_dict() into checkpoint ns
2020-08-19 14:27:28 -07:00
Vincent Wang
5eaac31faa
support opset13 on transformers. (#4837)
Co-authored-by: Vincent Wang <weicwang@microsoft.com>
2020-08-19 11:13:37 +08:00
gwang-msft
dee7596724
Add a generic collection of session configurations to the SessionOptions (#4718)
* adding generic configurations for session options

* fix a build break on linux

* fix training ci build break

* fix training ci build break

* addressed CR comments

* fix traning ci build break

* move config_key from enum to string

* add c# api

* add python api

* fix build break

* move prepacking from 2 new api entries to session options configs

* fix traning ci build break

* add python test, update some comments, move const key definition to avoid build break

* addressed comments

* move definitions of keys to common.h

* move api to version 5

* remove accidental change in build.py

* remove pragma to avoid build break

* addressed CR comments

* fix the python build break, and move location of config keys definition

* small typo changes
2020-08-18 13:40:40 -07:00
ytaous
2605af9a0b
Fix for mainz model (#4744)
* fix for mainz model

* fix build

* on comments

* revert the extra check

* on comments

Co-authored-by: Ethan Tao <ettao@microsoft.com>
2020-08-18 11:47:19 -07:00
Thiago Crepaldi
f3b0c93a45
Fix issue preventing loss scaler to run due (#4833)
`LossScaler.update()` was not being properly called due to the incorrect TrainStepInfo.all_finite assignment.

Additionally to this fix, _ORTTrainerModelDesc.is_finite was renamed to _ORTTrainerModelDesc.all_finite to make it more uniform with TrainStepInfo
2020-08-18 10:03:02 -07:00
Hariharan Seshadri
a3c95374c3
Support asymmetric paddings in CUDA Conv kernel (#4627) 2020-08-18 02:09:30 -07:00
Rayan-Krishnan
24d9f4e0c3
Add More Extensive ONNX BERT Tests (#4827)
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>
2020-08-17 19:54:22 -07:00
Thiago Crepaldi
f933910ea3
Update LambConfig defaults to match backend (#4826) 2020-08-17 16:58:14 -07:00
edgchen1
32a5f3d5b6
Check status of element-wise op prepare functions. (#4830)
* Check status of BinaryElementwise::Prepare().

* Add additional status checks for BinaryElementwise::Prepare() and UnaryElementwise::Prepare().

* Add status checks for BinaryElementwisePreparation::BinaryElementwiseBroadcastPrepareHelper().
2020-08-17 16:11:30 -07:00
Thiago Crepaldi
42408aa3ed
Add new PytTrch front-end (#4815)
* Add ORTTrainerOptions class for the new pytorch frontend (#4382)

Add ORTTrainerOptions class and some placeholders

* Add _ORTTrainerModelDesc to perform validation for model description (#4416)

* Add Loss Scaler classes to the new frontend (#4306)

* Add TrainStepInfo used on the new frontend API (#4256)

* Add Optimizer classes to the new frontend (#4280)

* Add LRScheduler implementation (#4357)

* Add basic ORTTrainer API (#4435)

This PR presents the public API for ORTTrainer for the short term
development.

It also validates and saves input parameters, which will be used in the
next stages, such as building ONNX model, post processing the model and
configuring the training session

* Add opset_version into ORTTrainerOptions and change type of ORTTrainer.loss_fn (#4592)

* Update ModelDescription and minor fix on ORTTrainer ctor (#4605)

* Update ModelDescription and minor fix on ORTTrainer/ORTTrainerOptions

This PR keeps the public API intact, but changes how model description is stored on the backend

Currently, users creates a dict with two lists of tuples.
One list called 'inputs' and each tuple has the following format tuple(name, shape).
The second list is called 'outputs' and each tuple can be either tuple(name, shape) or tuple(name, shape, is_loss).

With this PR, when this dict is passed in to ORTTrainer, it is fully validated as usual.
However, tuples are internally replaced by namedtuples and all output tuples will have
tuple(name, shape, is_loss) format instead of is_loss being optionally present.

Additionally to that normalization in the internal representation (which eases coding),
two internal methods were created to replace a namedtuple(name, shape) to namedtuple(name, shape, dtype)
or namedtuple(name, shape, is_loss, dtype) dependeing whether the tuple is an input or output.

This is necessary as ORTTRainer finds out data types of each input/output during model export to onnx.

Finally, a minor fix was done on ORTTrainer. It could initialize ORTTrainerOptions incorrectly when options=None

* Rename input name for test

* Add ONNX Model Export to New Frontend (#4612)

Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>

* Create training session + minor improvements (#4668)

Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>

* Save ONNX model in file (#4671)

Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>

* Add eval step (#4674)

Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>

* Add train_step (#4677)

Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>

* Add LR Scheduler (#4694)

Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>

* Add deterministic compute tests (#4716)


Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>

* Add legacy vs experimental ORTTrainer accuracy comparison (#4727)

Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>

* Add Mixed precision/LossScaler + several fixes (#4739)

Additionally to the mixed precision/loss scaler code, this PR includes:

* Fix CUDA training
* Add optimization_step into TrainStepInfo class
* Refactor LRSCheduler to use optimization_step instead of step
* Updated several default values at ORTTrainerOptions
* Add initial Gradient Accumulation supported. Untested
* Fix ONNX model post processing
* Refactor unit tests

* Add ONNX BERT example + minor fixes (#4757)

* Fix training issue when passing ONNX file into ORTTrainer

Co-authored-by: Thiago Crepaldi <thiago.crepaldi@microsoft.com>
Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>

* Add Dynamic Shape support (#4758)

* Update DeepSpeed Zero Stage option to a separate option group (#4772)

* Add support to fetches (#4777)

* Add Gradient Accumulation Steps support (#4793)

* Fix Dynamic Axes feature and add unit test (#4795)

* Add frozen weights test (#4807)

* Move new pytorch front-end to 'experimental' namespace (#4814)

* Fix build

Co-authored-by: Rayan-Krishnan <rayankrishnan@live.com>
Co-authored-by: Rayan Krishnan <t-rakr@OrtDevTest2v100.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
2020-08-17 09:45:25 -07:00
Tang, Cheng
1b1a6a4ca9
Bump onnx to get bfloat16 in ops, and some update in ort to support bfloat16 (#4791)
* bump onnx to support bfloat16

* sign test code

* fix ut failures

* add bfloat type in gradient schema

* add bfloat16 to gathernd

* add bfloat16 into grad op defs

* temp disable gpu fusing transformers

* bfloat16 support fix

* more fix to bfloat

* bug ifx

* add bfloat16 to transpose matmul

* fix sce loss

* fix cast opset13 and other missing part of bfloat16

* Revert "temp disable gpu fusing transformers"

This reverts commit b627bc9019.

* add SCEloss back

* fix build break

* fix gpu failure due to missing kernel in opset13

* add tile opset 13 kernel

* Revert "fix gpu failure due to missing kernel in opset13"

This reverts commit 661d63d0599029757f240d29afd64b197b76b880.

* fix comments in pr

* fix cuda break due to opset13

* fix missing msdomain

* add nll loss tests into android build's broken list; disable bfloat16 cast tests due to the wrong type saved in onnx test data, will fix it in onnx first

Co-authored-by: Cheng Tang <chenta@microsoft.com>
2020-08-16 17:05:40 -07:00
ashbhandare
5a8962d327
Make grad name unique (#4788)
* Make grad name unique

* Modify for review comment
2020-08-14 15:17:17 -07:00
edgchen1
487665c21f
Transpose MatMul fusion fixes (#4728)
Fix Transpose MatMul fusion handling of existing TransposeScaleMatMul node's attributes and enable support for missing Transpose perm attribute.
Update expected test data to account for floating point calculation differences resulting from the fusion.
2020-08-10 13:00:22 -07:00
Bowen Bao
abbb7f6f5c
Avoid duplicated calls of postprocess in training frontend (#4579) 2020-08-07 21:34:11 -07:00
Sergii Dymchenko
c334b5738e
Remove docstring for removed parameter (#4734) 2020-08-07 11:43:36 -07:00
zhijxu-MS
33fe770037
Support log sigmoid gradient (#4719)
* add log's gradient op and its related gradient test

* support sigmoid's gradient op

* resolve review comments
2020-08-07 11:21:36 +08:00
ashbhandare
fc2f36c608
Shape independent gradient builder for Concat (#4675)
* Add gradient for ConcatTraining

* Graph rewriter changes for concat

* Add generated onnx graph, minor fixes

* Revert unintended change

* Fix for MaxPoolGradTest

* Fix UT

* Review comments, windows tests

* Review comments
2020-08-06 14:39:33 -07:00
suffiank
4d39c6a6cb
Wire log(softmax) grad cuda kernel and add log(softmax) grad cpu kernel (#4726)
* logsoftmax cuda kernel

* add cpu logsoftmaxgrad

* revert debug printout

* revert disable for debug builds

* use /alpha x + y instead

* remove misleading log_softmax_ bool

Co-authored-by: suffian khan <sukha@OrtTrainingDev1.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
2020-08-06 10:49:08 -07:00
KeDengMS
9a73c8f448
ReshapeGrad optimization (#4708)
* Reshape optimization

* Refactor the Reshape optimization to be more generic

Co-authored-by: Ke Deng <kedeng@OrtTrainingDev1.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
2020-08-05 23:26:02 -07:00
Sherlock
eb0f57f0e4
Localized Recompute for Gelu and AttentionDropout (#4402)
* Gelu Activation Recompute Draft

* Prototype for localized recompute

* Introduce localized_recompute rewriter

* Command line args for enabling recompute

* Add logger to Gradient Graph Builder

* use const when possible
2020-08-04 21:48:15 -07:00
edgchen1
9d7284fc3b
Enable MatMul + Scale fusion (#4669)
Update TransposeMatMul to support scaling of the matrix product by a constant scalar value (analogous to the GEMM alpha parameter). Rename TransposeMatMul to TransposeScaleMatMul.
Fuse MatMul with surrounding Mul/Div with constant scalar into TransposeScaleMatMul.
2020-08-04 16:27:22 -07:00
Wei-Sheng Chin
e9d20e9dba
Revise Send and Recv (#4547)
* Add ability to retrieve inferred shapes when executing a kernel.
This ability helps Recv to know its output shapes without doing
actual cummunication. Of course, if the output shapes cannot be
inferred, Recv still needs to do communication to get shapes from
Send.

* Avoid communicating shape information when it can be inferred statically

* Replace unordered_map with thread-safe wrapper.
We don't want to have racing condition and undefined behavior
when using parallel executor.y

* Remove cout

* Add missing file

* Address comments

* Check dim_value. -1 means missing

* lock properly

* Address comments (remove thread-safe map)

* Remove poc header

* Replace Stream with DeferredReleaseCPUPtr
2020-07-30 23:02:45 -07:00
Tixxx
f90a2d46ae
Changes to support TNLRV3 fine-tuning (#4639)
* added reducesumlogexp gradient
added test
fixed type mismatch when calling cudnnreduce kernel
fixed python frontend to remove redundant states to match pytorch state dict
2020-07-29 19:17:59 -07:00
ashbhandare
d4983f83ff
Shape independent gradient builder for ops requiring broadcast (#4586)
* Adding CPU implementation of BroadcastGradientArgs op

Modify to take shape as input instead of tensor

Cleanup

Correct schema

Corrected kernel, added tests, addressed review comments.

Initial change, to add ReduceSumTraining cpu op

cpu support

Initial changes to gradient builder

Non-empty reduction case passing.

Added exception,test for invalid broadcast,addresed review comments.

Initial change, to add ReduceSumTraining cpu op

cpu support

cuda support + more UTs

on comments + UT

no op support for {} axes with new attr - noop_with_empty_axes

Add noop attribute to ReduceSumTraining use

Add testing for no-shape graph, modify AddSub grad builder, logging.:

MulGrad support

Div support

Expand support

Gemm support

MatMul grad change

Transpose Grad change

BiasGeluGrad change.

Fixes after squash

* Remove logging, add specific exception for shape inference error

* fix build

* Review comments

* Review comments

* Fix windows build

Co-authored-by: Ethan Tao <ettao@microsoft.com>
2020-07-28 13:01:07 -07:00
M. Zeeshan Siddiqui
73ad92e773
Change ignore_index to 0 in Bert-Loss. (#4640) 2020-07-28 04:37:11 -07:00
albertomagni-ms
c08e5f55e9
Fix misleading indentation (#4629)
* Adjust indentation of statement, without this fix GCC 7.5 errors
out with:
"this ‘if’ clause does not guard this statement, but the
latter is misleadingly indented as if it were guarded by the ‘if’"

* Add braces around the if-statement for improved clarity.

Co-authored-by: Alberto Magni <alberto.magni@microsoft.com>
2020-07-27 14:42:58 -07:00
ytaous
9888c9e944
SplitTraining op to support split as input (#4597)
* SplitTraining op to support split as input

* on comments and minor refactor

Co-authored-by: Ethan Tao <ettao@microsoft.com>
2020-07-24 12:49:19 -07:00
Sherlock
aa328c2c20
Update GratherGard to accumulate in fp32 (#4601) 2020-07-24 10:54:31 -07:00
ashbhandare
5189530b7b
Create the ConcatTraining op (#4595)
* Working changes for ConcatTraining op

* Refactor to move changes to orttraining

* Fix segfault

* Support -ve axis for shape inferencing

* fix build

Co-authored-by: Ethan Tao <ettao@microsoft.com>
2020-07-24 10:03:58 -07:00
ytaous
d5b98a13c2
Move ReduceSumTraining op under orttraining (#4588)
* move training op under orttraining

* code clean up

* fix build

* on comments

Co-authored-by: Ethan Tao <ettao@microsoft.com>
2020-07-23 21:36:52 -07:00
Xueyun Zhu
e2acb165e9
Add exception check in training_runner when worker runs into error, and misc check on nccl and mpi calls (#4380)
* error check

* fix build warning treated as error
2020-07-22 14:32:19 -07:00
M. Zeeshan Siddiqui
e11629d9e4
Revert "Deprecate TrainableDropout (#4501)" (#4564)
This reverts commit 6eb5549cb9.

# Conflicts:
#	orttraining/orttraining/core/graph/training_op_defs.cc
2020-07-21 06:18:42 -07:00
ashbhandare
ab4be8355f
Add the BroadcastGradientArgs op (#4511)
* Adding CPU implementation of BroadcastGradientArgs op

* Modify to take shape as input instead of tensor

* Cleanup

* Correct schema

* Corrected kernel, added tests, addressed review comments.

* Added exception,test for invalid broadcast,addresed review comments.

* Fix mac build error.
2020-07-20 23:59:10 -07:00
ytaous
0008e92b4e
Internal ReduceSum op that accepts axes as input (#4522)
* Initial change, to add ReduceSumTraining cpu op

* cpu support

* cuda support + more UTs

* on comments + UT

* no op support for {} axes with new attr - noop_with_empty_axes

* on comments

* fix build

* on comments

Co-authored-by: aishwarya bhandare <aibhanda@microsoft.com>
Co-authored-by: Ethan Tao <ettao@microsoft.com>
2020-07-20 21:05:00 -07:00
M. Zeeshan Siddiqui
9d80235607
Reshape inputs for SoftmaxCrossEntropyLoss instead of transposing them. (#4551) 2020-07-20 06:33:40 -07:00
M. Zeeshan Siddiqui
6c950a1df0
Exclude weight related types/shapes from bert loss. (#4548) 2020-07-18 08:27:02 -07:00
M. Zeeshan Siddiqui
6eb5549cb9
Deprecate TrainableDropout (#4501)
* Deprecate TrainableDropout.

* Add Dropout(12) back into Megatron transformer.

* Remove TrainableDropout from front-end test models.

* Update baseline for front-end tests after converting test models to opset-12.

* Update baseline for front-end tests after converting test models to opset-12.
2020-07-17 13:43:25 -07:00
Wei-Sheng Chin
21d2728974
Revise pipeline schedule to consider communication ops (#4524)
* Revise pipeline schedule to consider communication ops

* Add test

* Fix warning

* inline some short functions

* Fix warnings

* Rename a class

* Add comment for test

* op renamed to task

* Fix NVTX wrapper's bug
2020-07-17 10:04:56 -07:00
Xueyun Zhu
183098e344
adding concat logic when initial path is empty (#4525)
* concat

* add path_utils

* address feedback

* use string in test

* convert wstring to sting in windows

* address feedback

* address feedback

* fix comment
2020-07-16 23:46:12 -07:00
M. Zeeshan Siddiqui
b43ce2d7ad
Replace loss function in BERT_LOSS with SoftmaxCrossEntropyLoss. (#4509)
* Replace loss function in BERT_LOSS with SoftmaxCrossEntropyLoss.

* Update BERT loss function with correct logit shapes for softmax cross entropy loss.

* fix test and PR comments.
2020-07-16 15:28:24 -07:00
Xueyun Zhu
5f188f4cf4
ci fix (#4519) 2020-07-15 12:05:24 -07:00
liqunfu
f721f5f1cd
Liqun/multiple choice (#4480)
* multiple choice runner

* add docker cleanup task to frontent pipeline
2020-07-14 17:57:58 -07:00
Xueyun Zhu
7d96960ec8
support pipeline partition with shared initializer (#4321)
* support bert partition with shared initializer

* address feedback

* address feedback

* address feedback

* add more test

* remove bert-tiny model

* address feedback

* address function comment

* move CreateNodeArg to graph_utils

* rename function name

* rename function name

* fix windows build

* fix windows type conversion warning

* add function comment
2020-07-14 17:21:40 -07:00
liqunfu
0bff55512e
updated expected values for frontend test to pass frontend e2e pipeline. raise tolerance to reduce future risk of failure (#4497)
* updated expected values for frontend test, raise tol
2020-07-13 19:25:54 -07:00
edgchen1
c71c49aaa0
Make TArray safer to use and update method name for consistency. (#4483)
- make size_ and data_ data members private
- rename GetCapacity() to Capacity() to be consistent (e.g., with Size())
- add static_assert for trivially copyable T because it is copied with memcpy
2020-07-13 09:59:56 -07:00
Vincent Wang
7fb194d03d
Update convergence baseline for ci_test. (#4465)
Co-authored-by: Vincent Wang <weicwang@OrtTrainingDev3.af05slrtruoetgaxwwjv5nsq5e.px.internal.cloudapp.net>
2020-07-09 15:29:36 +08:00
Tixxx
b156ae4448
Support training_mode flag in eval (#4324)
* add training_mode feed for evaluation to support opset12
2020-07-08 10:38:54 -07:00
Hariharan Seshadri
6d6b6b54a5
Support binding a graph output to a specific device via the Python binding (#4439) 2020-07-07 21:09:37 -07:00
Ashwini Khade
dd73e8c016
add function initialization back to graph resolve (#4434) 2020-07-06 15:17:27 -07:00