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

Add triton server #3

Merged
merged 2 commits into from
May 29, 2022
Merged

Add triton server #3

merged 2 commits into from
May 29, 2022

Conversation

yuekaizhang
Copy link
Collaborator

I added this triton server and client for offline ASR. Moslty following wenet triton server https://github.com/wenet-e2e/wenet/tree/main/runtime/server/x86_gpu

TODO (Maybe after this PR?)

  • Benchmark test
  • Readme Improvement

@csukuangfj
Copy link
Collaborator

Thanks! I am looking at it.

)
from torch import Tensor, nn

#from icefall.utils import make_pad_mask
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This conformer_triton.py is mainly for remove the k2 dependency. Currently, only support greedy_search_batch, so I didn't install k2. It could be removed after dockerfile improvement with k2, lhoste install.

bias=False,
)

def forward(self, y: torch.Tensor) -> torch.Tensor:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

remove need_pad parameters, since it always false when infer, so we don't need to prepare input_need_pad for triton.

self.decoder_proj = ScaledLinear(decoder_dim, joiner_dim)
self.output_linear = ScaledLinear(joiner_dim, vocab_size)

def forward(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

remove projected_input here, I didn't have ForwardEncProj and DecProj outside joiner. Otherwise, it would add two more submodules under triton and make things complicated.


return logit

class AttributeDict(dict):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These duplicate functions below also for avoid k2 dependency. When we add more decoding algorithms like fast_beam_search we would not need these duplicate functions.

self.vocab_size = sp.get_piece_size()
self.sp = sp

def execute(self, requests):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the start of greedy_beam_sarch_batch.

value = value["string_value"]
if key == "num_mel_bins":
opts.mel_opts.num_bins = int(value)
# elif key == "frame_shift_in_ms":
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest either removing frame_shift and frame_length from the config file, or reading them if the config file provides them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I would uncomment them.

@@ -0,0 +1,144 @@
import triton_python_backend_utils as pb_utils
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need to install https://github.com/triton-inference-server/python_backend?
Its readme.md says you have to install it in the docker image.

Correct me if I am wrong.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we don't need to install it. Its readme looks like install a python_backend example. Just tritonserver official docker could offer all triton ensentials we need.

Copy link
Collaborator

@csukuangfj csukuangfj left a comment

Choose a reason for hiding this comment

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

Thanks! Leave some minor comments.

speech[i, 0: f_l, :] = f.to(self.output0_dtype)
speech_lengths[i][0] = f_l
# put speech feature on device will cause empty output
# we will follow this issue and now temporarily put it on cpu
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this mean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, it was triton issue. I have deleted them and tested.

},
{
key: "bpe_model",
value: { string_value: "/ws/yuekaiz/icefall-asr-librispeech-pruned-transducer-stateless3-2022-04-29/data/lang_bpe_500/bpe.model"}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this path available in the docker container?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, would update it.

{
name: "encoder_out__0"
data_type: TYPE_FP32
dims: [-1, 512] # [-1, feature_size]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
dims: [-1, 512] # [-1, feature_size]
dims: [-1, 512] # [-1, encoder_out_dim]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks.

@@ -0,0 +1,59 @@
import numpy as np
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file has no copyright info and it is not clear where it is from.

Could you use https://github.com/pzelasko/kaldialign
to calculate the WER instead of reinventing the wheel.

We are alreadying using it in icefall.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

@@ -0,0 +1,127 @@
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment for the file triton/client/1089-134686-0001.json

Where is it used? Can we remove it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's generated by "python3 generate_perf_input.py test_wavs/1089-134686-0001.wav <input.json>", which is used by perf_anyalzer. I would remove it and update the reademe.md.

@yuekaizhang
Copy link
Collaborator Author

@csukuangfj Thanks for your review. I have commited changes according to your comments, would you mind checking them?

@csukuangfj
Copy link
Collaborator

Thanks! Looks good to me. Is it ready to merge?

@yuekaizhang
Copy link
Collaborator Author

Thanks! Looks good to me. Is it ready to merge?

I think so. I would like add benchmark results in next PR with features like fast beam search algorithms. So we could also have a comparison of WER, throughput. Also, I would update dockerfile to support k2 for fastbeam search.

@csukuangfj csukuangfj merged commit 259d2b9 into k2-fsa:master May 29, 2022
@yuekaizhang yuekaizhang deleted the offline_triton branch May 30, 2022 00:24
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.

2 participants