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

[TVM EP] support of TVM Virtual Machine #10341

Merged
merged 15 commits into from
Mar 2, 2022
Merged

Conversation

vvchernov
Copy link
Contributor

@vvchernov vvchernov commented Jan 20, 2022

Support TVM Virtual Machine on TVM EP side

Waiting for merging of TVM PR (done) and ORT PR#10260 (done) and ORT PR#10505 (done) before check this PR

@vvchernov vvchernov force-pushed the vc/tvm-vm branch 2 times, most recently from 07724d5 to 1ba8fd5 Compare February 4, 2022 06:28
@vvchernov vvchernov changed the title WIP: [TVM EP] support of TVM Virtual Machine [TVM EP] support of TVM Virtual Machine Feb 15, 2022
void TVM_VM_SetInputs(TvmModule& mod,
std::vector<DLTensor>& inputs)
{
// TODO(vvchernov): set_input_zero_copy is more preferable but it does not satisfy alignment conditions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you elaborate more on what these alignment conditions are?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've observed that VM does not support zero copy on TVM side. I've supported zero copy on TVM EP side for GE after data alignment check.

void TVMSetInputs(TvmModule& mod, std::vector<size_t>& inds, std::vector<DLTensor>& inputs);
void TVM_VM_SetInputs(TvmModule& mod, std::vector<DLTensor>& inputs);
void TVMGetOutputs(TvmModule& mod, std::vector<DLTensor>& outputs);
void TVMGet_VM_Outputs(TvmModule& mod, std::vector<DLTensor>& outputs);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should name these functions either TVM_VM_SetInputs and TVM_VM_GetInputs or TVMSet_VM_Inputs and TVMGet_VM_Inputs for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! done

# TODO(vvchernov): replace prints by logger, but investigate ORT logging system for python before
# see lines 69, 77, 119, 136
if executor == "vm":
# print("Build TVM virtual machine")
Copy link
Contributor

Choose a reason for hiding this comment

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

clean up this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

target_host=target_host,
)
elif executor == "graph":
# print("Build TVM graph executor")
Copy link
Contributor

Choose a reason for hiding this comment

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

clean up this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

tvm::TVMSetInputs(*mod_, inds, dl_tensors_inputs);
if (use_vm_) {
tvm::TVM_VM_SetInputs(*mod_, dl_tensors_inputs);
// Infer once for calculating of output shapes
Copy link
Contributor

Choose a reason for hiding this comment

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

How will this affect benchmarking?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first run we should do probe inference to define output tensor shapes. It needs for VM only. It does not affect our benchmarking because of warmup with several inferences is done before performance test.

@vvchernov vvchernov changed the title [TVM EP] support of TVM Virtual Machine WIP: [TVM EP] support of TVM Virtual Machine Feb 16, 2022
@vvchernov vvchernov force-pushed the vc/tvm-vm branch 5 times, most recently from 35e520d to 97da135 Compare February 18, 2022 11:25
@vvchernov
Copy link
Contributor Author

vvchernov commented Feb 22, 2022

Hello @xadupre! Could you review this PR again? I did not skip WIP status due to we are waiting for merging of PR on TVM side, just now ONNX runtime references on TVM on local branch, but further the TVM commit hash will be changed only. I do not think it confuses you.

xadupre
xadupre previously approved these changes Feb 24, 2022
@xadupre
Copy link
Member

xadupre commented Feb 24, 2022

/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux Nuphar CI Pipeline, Linux OpenVINO CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 9 pipeline(s).

@vvchernov vvchernov changed the title WIP: [TVM EP] support of TVM Virtual Machine [TVM EP] support of TVM Virtual Machine Feb 26, 2022
@vvchernov vvchernov changed the title [TVM EP] support of TVM Virtual Machine WIP: [TVM EP] support of TVM Virtual Machine Feb 26, 2022
@vvchernov vvchernov changed the title WIP: [TVM EP] support of TVM Virtual Machine [TVM EP] support of TVM Virtual Machine Mar 1, 2022
@vvchernov
Copy link
Contributor Author

Hello @xadupre, I think the PR is ready to merge. Could you recheck last changes and start CI tests.

@xadupre
Copy link
Member

xadupre commented Mar 1, 2022

/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux Nuphar CI Pipeline, Linux OpenVINO CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 9 pipeline(s).

xadupre
xadupre previously approved these changes Mar 1, 2022
@xadupre
Copy link
Member

xadupre commented Mar 1, 2022

/azp run Windows CPU CI Pipeline, Windows GPU CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows WebAssembly CI Pipeline, orttraining-amd-gpu-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline, orttraining-ortmodule-distributed, onnxruntime-python-checks-ci-pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 8 pipeline(s).

@vvchernov
Copy link
Contributor Author

@xadupre I've fixed flake8 issues, please restart CI pipelines

@xadupre
Copy link
Member

xadupre commented Mar 1, 2022

/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux Nuphar CI Pipeline, Linux OpenVINO CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline

@xadupre
Copy link
Member

xadupre commented Mar 1, 2022

/azp run Windows CPU CI Pipeline, Windows GPU CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows WebAssembly CI Pipeline, orttraining-amd-gpu-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline, orttraining-ortmodule-distributed, onnxruntime-python-checks-ci-pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 9 pipeline(s).

@azure-pipelines
Copy link

Azure Pipelines successfully started running 8 pipeline(s).

@vvchernov
Copy link
Contributor Author

Good evening @xadupre Could you restart orttraining-amd-gpu-ci-pipeline, there is failure due to samples-per-second mismatching for huggingface-gpt2 models. It does not related to the PR in any case.

@xadupre
Copy link
Member

xadupre commented Mar 1, 2022

/azp run orttraining-amd-gpu-ci-pipeline

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vvchernov
Copy link
Contributor Author

Hello @xadupre! All checks have passed successfully, it can be approved.

@xadupre xadupre merged commit 62cc981 into microsoft:master Mar 2, 2022
@vvchernov vvchernov deleted the vc/tvm-vm branch March 5, 2022 11:22
petersalas pushed a commit to octoml/onnxruntime that referenced this pull request Nov 7, 2022
* add executor option (vm or graph) and support virtual machine methods

* nullptr check for compile and run methods (see also PR#10211 from microsoft:onnxruntime)

* get output shapes for VM

* remove run_with_benchmark. remove run methods from python api, get it from native side

* get outputs method for VM was implemented

* support multiple input for VM

* update python logging and exception

* small fix

* update tvm with patch for VM API

* update nhwc transformations for TVM EP

* add data alignment check and support set_input_zero_copy for GE in TVM EP

* fix logger name

* return back to apache/tvm with VM fixes instead of local dev branch

* hide customized tvm logger while issue is not resolved. fix tvm warning related to target_host

* flake8 fix

Co-authored-by: Valery Chernov <valery.chernov@deelvin.com>
(cherry picked from commit 62cc981)
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.

3 participants