Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Loss Scale ] Enable to define different type of Variable and Gradient for Loss Scale #2562

Merged
merged 4 commits into from
May 4, 2024

Conversation

jijoongmoon
Copy link
Collaborator

In this PR

This PR enables separate definition of variable and gradient of Weight. It's because we have to support different type considering Mixed Precision Training or Quantization.
For example, Variable should be FP16 and Gradient should be FP16 for FP16-FP16 Mixed Precision.
Or Variable should support BCQ3 and Gradient FP16 for BCQ3-FP16 QAT.
Therefore, we need to set update the Variable weight as it is requested.. and for Gradient, we have to set same type of Activation.

This PR enables to set different type between Variable and Gradient.

Commits to be reviewed in this PR

[Property] Add loss scale property

It add loss scale property as model common property.

Signed-off-by: Jiho Chu [email protected]

[ Weight ] Add Loss Scale factor in Weight

This PR enables the loss scale factor in Weight.
. Change the WeightSpec to incluide the loss factor
. Add LossScaleForMixed Property as an layer common property, so that
it can set the scale factor in initContext.
. Add Loss Scale in initContext
. Set the LossScaleForMixed Property when there is LossScale Model
Property

Resolves:

Self evaluation:

  1. Build test: [X]Passed [ ]Failed [ ]Skipped
  2. Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon [email protected]

[ Weight ] split variable dim and grad dim to set separately
This PR split the Variable and Gradient Dim in Var_Grad and Weight. By this way we can set different Variable Type and Gradient in Wegiht. . add dim_g for gradient in WeightSpec. . manager need to update to support WeightSpec. . Create Tensors according to dim_v and dim_g . Create Weight chaged in Weight.h

Resolves:

Self evaluation:

  1. Build test: [X]Passed [ ]Failed [ ]Skipped
  2. Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon [email protected]

[ NEURALNET ] change the loss scale property to Rigid Property
Loss Scale is more like Rigid Property of model, rather than flexible property.

Resolves:

Self evaluation:

  1. Build test: [X]Passed [ ]Failed [ ]Skipped
  2. Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon [email protected]

jihochu and others added 3 commits April 26, 2024 09:44
It add loss scale property as model common property.

Signed-off-by: Jiho Chu <[email protected]>
This PR enables the loss scale factor in Weight.
. Change the WeightSpec to incluide the loss factor
. Add LossScaleForMixed Property as an layer common property, so that
  it can set the scale factor in initContext.
. Add Loss Scale in initContext
. Set the LossScaleForMixed Property when there is LossScale Model
  Property

Resolves:

**Self evaluation:**
1. Build test:	 [X]Passed [ ]Failed [ ]Skipped
2. Run test:	 [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon <[email protected]>
This PR split the Variable and Gradient Dim in Var_Grad and Weight.
By this way we can set different Variable Type and Gradient in Wegiht.
. add dim_g for gradient in WeightSpec.
. manager need to update to support WeightSpec.
. Create Tensors according to dim_v and dim_g
. Create Weight chaged in Weight.h

Resolves:

**Self evaluation:**
1. Build test:	 [X]Passed [ ]Failed [ ]Skipped
2. Run test:	 [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon <[email protected]>
@taos-ci
Copy link

taos-ci commented Apr 30, 2024

📝 TAOS-CI Version: 1.5.20200925. Thank you for submitting PR #2562. Please a submit 1commit/1PR (one commit per one PR) policy to get comments quickly from reviewers. Your PR must pass all verificiation processes of cibot before starting a review process from reviewers. If you are new member to join this project, please read manuals in documentation folder and wiki page. In order to monitor a progress status of your PR in more detail, visit http://ci.nnstreamer.ai/.

Copy link

@taos-ci taos-ci left a comment

Choose a reason for hiding this comment

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

@jijoongmoon, 💯 All CI checkers are successfully verified. Thanks.

@@ -171,7 +172,8 @@ class InitLayerContext {
/**
* @brief Request a new weight for the layer
*
* @param dim dimension of the weight
* @param dim_v dimension of Variagble of the weight
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @param dim_v dimension of Variagble of the weight
* @param dim_v dimension of Variable of the weight

Also, @param dim_v doesn't seem to match the function prototype.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes. My bad. Fixed. Thanks!

Loss Scale is more like Rigid Property of model, rather than flexible
property.

Resolves:

**Self evaluation:**
1. Build test:	 [X]Passed [ ]Failed [ ]Skipped
2. Run test:	 [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon <[email protected]>
@jijoongmoon jijoongmoon force-pushed the add_loss_scale_in_weight branch from 8bb54f3 to cb0f83f Compare May 2, 2024 08:28
Copy link

@taos-ci taos-ci left a comment

Choose a reason for hiding this comment

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

@jijoongmoon, 💯 All CI checkers are successfully verified. Thanks.

Copy link
Member

@SeoHyungjun SeoHyungjun left a comment

Choose a reason for hiding this comment

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

LGTM

@myungjoo myungjoo merged commit 8c2de81 into nnstreamer:main May 4, 2024
31 checks passed
@jijoongmoon jijoongmoon deleted the add_loss_scale_in_weight branch December 24, 2024 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants