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

tf.function not used for model inference #10728

Closed
3 tasks done
mleimeister opened this issue Jan 24, 2022 · 1 comment · Fixed by #10738 or #10739
Closed
3 tasks done

tf.function not used for model inference #10728

mleimeister opened this issue Jan 24, 2022 · 1 comment · Fixed by #10738 or #10739
Assignees
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework area:rasa-oss/performance Issues focused around the performance of `rasa` (e.g.number of handled requests per second) type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@mleimeister
Copy link
Contributor

mleimeister commented Jan 24, 2022

Rasa Open Source version

3.0.x

Rasa SDK version

No response

Rasa X version

No response

Python version

3.8

What operating system are you using?

OSX

What happened?

When running model inference in RasaModel, the predict step being used here is the (eager) Python implementation, not the tf.function created just before that. Therefore, the Tensorflow graph is not used for performance optimization.

Testing a quick fix on the Sara dataset with config from here (limiting training epochs to 20 steps) and timing

rasa test --domain migrated_domain.yml --nlu test --stories test

gave the following inference improvements (tested locally on Macbook Pro 2,4 GHz 8-Core Intel Core i9):

Step main tf.function
Core 05:28 01:41
NLU 02:34 00:50
Total 11:18 5:52

Log output:

test-main.log
test-fix.log

Command / Request

#!/bin/zsh
cd /Users/matthias/Workspace/rasa3
git checkout main
cd /Users/matthias/Workspace/training-data/public/Sara

rasa train --domain migrated_domain.yml --data train

{ time rasa test --domain migrated_domain.yml --nlu test --stories test } &> test-main.log

cd /Users/matthias/Workspace/rasa3
git checkout fix-tf-function
cd /Users/matthias/Workspace/training-data/public/Sara

{ time rasa test --domain migrated_domain.yml --nlu test --stories test } &> test-fix.log

Definition of Done

  • Implement fix on 3.0.x and 2.8.x branches
  • Run regression tests for some datasets/configs to ensure no change in model performance
  • Release in upcoming micro versions
@mleimeister mleimeister added type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors. area:rasa-oss 🎡 Anything related to the open source Rasa framework area:rasa-oss/performance Issues focused around the performance of `rasa` (e.g.number of handled requests per second) labels Jan 24, 2022
@ka-bu ka-bu mentioned this issue Jan 25, 2022
20 tasks
@mleimeister mleimeister self-assigned this Jan 25, 2022
@mleimeister
Copy link
Contributor Author

Results from memory profiling experiments on Carbon bot suggest no overall increase and slightly better utilisation: https://github.com/RasaHQ/research-experiments/tree/kb/tf27/results/2.6vs2.7/results/carbon-bot_tf-function-fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework area:rasa-oss/performance Issues focused around the performance of `rasa` (e.g.number of handled requests per second) type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
1 participant