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

SpeakerClustering: fix tensor dimennsions in forward() #5387

Merged
merged 24 commits into from
Nov 15, 2022

Conversation

virajkarandikar
Copy link
Contributor

For some paramters in SpeakerClustering.forward(), tensor dimensions were not specified and this resulted in zero dimension tensor inputs. This causes error when inferencing exported model in Triton server.

What does this PR do ?

Avoids zero dimension input tensors. Also extracts values from the tensors which have single dim of size 1. This avoids scattered use of item() to extract value from tensor.

Collection: ASR Diarizer

Changelog

  • Add specific line by line info of high level changes in this PR.

Usage

Fix is needed to use exported clustering model in Triton

# Add a code snippet demonstrating how to use this 

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
  • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • Bugfix

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Related to # (issue)

For some paramters in SpeakerClustering.forward(), tensor dimensions
were not specified. This results in error when inferencing exported
model in Triton server.

Signed-off-by: Viraj Karandikar <[email protected]>
@virajkarandikar
Copy link
Contributor Author

@tango4j can you review this?

@tango4j tango4j marked this pull request as ready for review November 10, 2022 21:15
@tango4j
Copy link
Collaborator

tango4j commented Nov 10, 2022

@virajkarandikar The change looks good. I have added unit-test for jit script exporting. However, this can only check problems on the python side, not for triton server cases.

return emb_tensor, segm_tensor, multiscale_segment_counts, multiscale_weights, spk_timestamps


@pytest.mark.skip("test is not intended")
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we skipping this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This function is sub-function for other testcases. This function was included in the test hogging up the time so skipped it.

This allows triton inference using human readable dict keys for parameter
names instead of cryptic INPUT_x notation

Signed-off-by: Viraj Karandikar <[email protected]>
@virajkarandikar
Copy link
Contributor Author

virajkarandikar commented Nov 11, 2022

@tango4j I have changed the forward to use Dict. This allows triton inference by using parameter names instead of INPUT_n notation. See https://github.com/triton-inference-server/server/blob/main/docs/user_guide/model_configuration.md#special-conventions-for-pytorch-backend for details.

Looks like the unit test needs to be updated. Will you do that please? I will try if I can.

@tango4j
Copy link
Collaborator

tango4j commented Nov 12, 2022

@virajkarandikar The cluster inference function should have parameters for re-usability. so I made a wrapper function for the part you created (forward). I made nemo users to use forward_infer to have parameters in the function call. I think this will work out but please let me know if this does not compile

@virajkarandikar
Copy link
Contributor Author

Ok. It works fine.
Can you add test for forward() function also?

@tango4j
Copy link
Collaborator

tango4j commented Nov 12, 2022

@virajkarandikar Sure, I will add a test for forward().

@tango4j
Copy link
Collaborator

tango4j commented Nov 14, 2022

@virajkarandikar I have added the test-case for .forward() (triton env inference). @nithinraok Please approve if there is no issues with this PR. Tutorial notebooks are also tested without errors.

@tango4j tango4j merged commit bd569bf into NVIDIA:main Nov 15, 2022
@virajkarandikar virajkarandikar deleted the vkarandikar_fix_clustering branch November 21, 2022 05:53
hainan-xv pushed a commit to hainan-xv/NeMo that referenced this pull request Nov 29, 2022
* SpeakerClustering: fix tensor dimennsions in forward()

For some paramters in SpeakerClustering.forward(), tensor dimensions
were not specified. This results in error when inferencing exported
model in Triton server.

Signed-off-by: Viraj Karandikar <[email protected]>

* adding tests for clustering

Signed-off-by: Taejin Park <[email protected]>

* removed unused functions

Signed-off-by: Taejin Park <[email protected]>

* removed unused functions 2

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed cpu/gpu test decorator for unittests

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* clustering: use dict in forward

This allows triton inference using human readable dict keys for parameter
names instead of cryptic INPUT_x notation

Signed-off-by: Viraj Karandikar <[email protected]>

* created a wrapper for param_dicts for triton infer

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed docstrings

Signed-off-by: Taejin Park <[email protected]>

* fixed docstring

Signed-off-by: Taejin Park <[email protected]>

* fixed test_speaker_counting function in the test

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added a test for Triton server call

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Signed-off-by: Viraj Karandikar <[email protected]>
Signed-off-by: Taejin Park <[email protected]>
Co-authored-by: Taejin Park <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: Hainan Xu <[email protected]>
hainan-xv pushed a commit to hainan-xv/NeMo that referenced this pull request Nov 29, 2022
* SpeakerClustering: fix tensor dimennsions in forward()

For some paramters in SpeakerClustering.forward(), tensor dimensions
were not specified. This results in error when inferencing exported
model in Triton server.

Signed-off-by: Viraj Karandikar <[email protected]>

* adding tests for clustering

Signed-off-by: Taejin Park <[email protected]>

* removed unused functions

Signed-off-by: Taejin Park <[email protected]>

* removed unused functions 2

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed cpu/gpu test decorator for unittests

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* clustering: use dict in forward

This allows triton inference using human readable dict keys for parameter
names instead of cryptic INPUT_x notation

Signed-off-by: Viraj Karandikar <[email protected]>

* created a wrapper for param_dicts for triton infer

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed docstrings

Signed-off-by: Taejin Park <[email protected]>

* fixed docstring

Signed-off-by: Taejin Park <[email protected]>

* fixed test_speaker_counting function in the test

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added a test for Triton server call

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Signed-off-by: Viraj Karandikar <[email protected]>
Signed-off-by: Taejin Park <[email protected]>
Co-authored-by: Taejin Park <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: Hainan Xu <[email protected]>
JimmyZhang12 pushed a commit to JimmyZhang12/NeMo that referenced this pull request Dec 14, 2022
* SpeakerClustering: fix tensor dimennsions in forward()

For some paramters in SpeakerClustering.forward(), tensor dimensions
were not specified. This results in error when inferencing exported
model in Triton server.

Signed-off-by: Viraj Karandikar <[email protected]>

* adding tests for clustering

Signed-off-by: Taejin Park <[email protected]>

* removed unused functions

Signed-off-by: Taejin Park <[email protected]>

* removed unused functions 2

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed cpu/gpu test decorator for unittests

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* clustering: use dict in forward

This allows triton inference using human readable dict keys for parameter
names instead of cryptic INPUT_x notation

Signed-off-by: Viraj Karandikar <[email protected]>

* created a wrapper for param_dicts for triton infer

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed docstrings

Signed-off-by: Taejin Park <[email protected]>

* fixed docstring

Signed-off-by: Taejin Park <[email protected]>

* fixed test_speaker_counting function in the test

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added a test for Triton server call

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Signed-off-by: Viraj Karandikar <[email protected]>
Signed-off-by: Taejin Park <[email protected]>
Co-authored-by: Taejin Park <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
andrusenkoau pushed a commit to andrusenkoau/NeMo that referenced this pull request Jan 5, 2023
* SpeakerClustering: fix tensor dimennsions in forward()

For some paramters in SpeakerClustering.forward(), tensor dimensions
were not specified. This results in error when inferencing exported
model in Triton server.

Signed-off-by: Viraj Karandikar <[email protected]>

* adding tests for clustering

Signed-off-by: Taejin Park <[email protected]>

* removed unused functions

Signed-off-by: Taejin Park <[email protected]>

* removed unused functions 2

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed cpu/gpu test decorator for unittests

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* clustering: use dict in forward

This allows triton inference using human readable dict keys for parameter
names instead of cryptic INPUT_x notation

Signed-off-by: Viraj Karandikar <[email protected]>

* created a wrapper for param_dicts for triton infer

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixed docstrings

Signed-off-by: Taejin Park <[email protected]>

* fixed docstring

Signed-off-by: Taejin Park <[email protected]>

* fixed test_speaker_counting function in the test

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added a test for Triton server call

Signed-off-by: Taejin Park <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Signed-off-by: Viraj Karandikar <[email protected]>
Signed-off-by: Taejin Park <[email protected]>
Co-authored-by: Taejin Park <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: andrusenkoau <[email protected]>
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.

None yet

3 participants