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

Flag to use CPU on TEDPolicy train #10944

Merged
merged 24 commits into from
Mar 24, 2022
Merged

Flag to use CPU on TEDPolicy train #10944

merged 24 commits into from
Mar 24, 2022

Conversation

WashingtonBispo
Copy link
Contributor

Proposed changes:

Status (please check what you already did):

  • added some tests for the functionality
  • updated the documentation
  • updated the changelog (please check changelog for instructions)
  • reformat files using black (please check Readme for instructions)

dependabot bot and others added 11 commits February 16, 2022 23:43
Bumps [google-github-actions/setup-gcloud](https://github.com/google-github-actions/setup-gcloud) from 0.4.0 to 0.5.1.
- [Release notes](https://github.com/google-github-actions/setup-gcloud/releases)
- [Changelog](https://github.com/google-github-actions/setup-gcloud/blob/master/CHANGELOG.md)
- [Commits](google-github-actions/setup-gcloud@e0f83f2...04141d8)

---
updated-dependencies:
- dependency-name: google-github-actions/setup-gcloud
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [actions/github-script](https://github.com/actions/github-script) from 4.0.2 to 6.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](actions/github-script@a3e7071...9ac0880)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps [pytest-timeout](https://github.com/pytest-dev/pytest-timeout) from 1.4.2 to 2.1.0.
- [Release notes](https://github.com/pytest-dev/pytest-timeout/releases)
- [Commits](pytest-dev/pytest-timeout@1.4.2...2.1.0)

---
updated-dependencies:
- dependency-name: pytest-timeout
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
…e-github-actions-setup-gcloud-0.5.1

Bump google-github-actions/setup-gcloud from 0.4.0 to 0.5.1
….1.0

Bump pytest-timeout from 1.4.2 to 2.1.0
…ns-github-script-6

Bump actions/github-script from 4.0.2 to 6
…tions-actions-github-script-6

Revert "Bump actions/github-script from 4.0.2 to 6"
…tions-google-github-actions-setup-gcloud-0.5.1

Revert "Bump google-github-actions/setup-gcloud from 0.4.0 to 0.5.1"
@WashingtonBispo WashingtonBispo requested review from a team and kedz and removed request for a team February 24, 2022 02:43
@CLAassistant
Copy link

CLAassistant commented Feb 24, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@indam23 indam23 left a comment

Choose a reason for hiding this comment

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

I'll leave it to @kedz to provide a more thorough review, just noted two things to address for now

rasa/core/policies/ted_policy.py Outdated Show resolved Hide resolved
rasa/core/policies/ted_policy.py Outdated Show resolved Hide resolved
@indam23 indam23 requested review from dakshvar22 and removed request for kedz March 2, 2022 10:31
@indam23
Copy link
Contributor

indam23 commented Mar 2, 2022

@SamuelNoB Could you please sign the contributor license agreement in the meantime?
@WashingtonBispo Do the comments left here so far make sense?

Copy link
Contributor

@dakshvar22 dakshvar22 left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fixes. I have made some more suggestions + a couple of things that are pending:

  1. We need to make sure that inference also runs on the requested device. In order to do that, we can wrap the model loading call with the appropriate context manager as you have done in train. The value of USE_GPU would have been persisted during training and will be loaded correctly in the config variable (line 1067), so you can use config to fetch the value of USE_GPU.

  2. Please add a description of use_gpu to the table of parameters of TEDPolicy and UnexpecTEDIntentPolicy

  3. Please add a changelog describing the change made in this PR to the changelog folder. Please refer to the README inside that folder for instructions on the content of the changelog file.

pyproject.toml Outdated Show resolved Hide resolved
rasa/core/policies/ted_policy.py Outdated Show resolved Hide resolved
rasa/core/policies/ted_policy.py Outdated Show resolved Hide resolved
rasa/core/policies/unexpected_intent_policy.py Outdated Show resolved Hide resolved
@WashingtonBispo
Copy link
Contributor Author

I'm not sure if i know how to make this first request.

pyproject.toml Outdated Show resolved Hide resolved
Copy link
Contributor

@ka-bu ka-bu left a comment

Choose a reason for hiding this comment

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

The following still needs to be implemented to make sure that we also switch to CPU when loading and finetuning an existing model:

We need to make sure that inference also runs on the requested device. In order to do that, we can wrap the model loading call with the appropriate context manager as you have done in train. The value of USE_GPU would have been persisted during training and will be loaded correctly in the config variable (line 1067), so you can use config to fetch the value of USE_GPU.

Some more details on that:

  1. If we want to use the CPU for finetuning, then we need to wrap the model = cls._load_tf_model(...) call that Daksh referenced above into a with tf.device(...) as well (because that call will call the RasaModel load function which contains the compile that builds the graph for the loaded model and which will put it on the GPU if not told otherwise)
  2. Since that call happens in a class function, we don't have access to self.config as before and need to get the information whether we want to use the GPU or not from somewhere else. We can get the same information from the config object that is created a few lines above the model = cls._load_tf_model(...) call.

Let me know if this helps or if you have more questions

@dakshvar22
Copy link
Contributor

@WashingtonBispo Can you please merge main into your branch and remove the changes you have made to poetry.lock?

@emysdias
Copy link
Contributor

@WashingtonBispo Can you please merge main into your branch and remove the changes you have made to poetry.lock?

Now it is fixed

@dakshvar22
Copy link
Contributor

Hi @WashingtonBispo @emysdias Added a couple of final suggestions + the code quality check is failing above. Can you please address these?

Co-authored-by: WashingtonBispo <[email protected]>
@emysdias
Copy link
Contributor

Hi @WashingtonBispo @emysdias Added a couple of final suggestions + the code quality check is failing above. Can you please address these?

done

@dakshvar22
Copy link
Contributor

Changes needed still

@emysdias
Copy link
Contributor

Changes needed still

ops, I'm going to change

Co-authored-by: WashingtonBispo <[email protected]>
@dakshvar22
Copy link
Contributor

Running final model regression tests on this PR

@dakshvar22
Copy link
Contributor

hi @emysdias and @WashingtonBispo , all tests seem to be passing now. Can you please merge the base branch once more and then I can enable auto-merge 🎉

@emysdias
Copy link
Contributor

hi @emysdias and @WashingtonBispo , all tests seem to be passing now. Can you please merge the base branch once more and then I can enable auto-merge tada

done

@dakshvar22 dakshvar22 enabled auto-merge (squash) March 24, 2022 11:37
@dakshvar22 dakshvar22 self-requested a review March 24, 2022 11:38
Copy link
Contributor

@dakshvar22 dakshvar22 left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks a lot for your contribution ✨

@emysdias
Copy link
Contributor

Looks great! Thanks a lot for your contribution sparkles

Thank you a lot

@WashingtonBispo
Copy link
Contributor Author

Looks great! Thanks a lot for your contribution ✨

Thank you sir.

@dakshvar22 dakshvar22 merged commit 43b6b9a into RasaHQ:main Mar 24, 2022
@emysdias emysdias deleted the use-gpu branch March 24, 2022 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants