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

feat: Add parameters support to InferResponse #394

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kthui
Copy link
Contributor

@kthui kthui commented Jan 24, 2025

What does the PR do?

Add support for setting response parameters in regular and decoupled Python backend model response(s).

Checklist

  • PR title reflects the change and is of format <commit_type>: <Title>
  • Changes are described in the pull request.
  • Related issues are referenced.
  • Populated github labels field
  • Added test plan and verified test passes.
  • Verified that the PR passes existing CI.
  • Verified copyright is correct on all changed files.
  • Added succinct git squash message before merging ref.
  • All template sections are filled out.
  • Optional: Additional screenshots for behavior/output changes with before/after.

Commit Type:

Check the conventional commit type
box here and add the label to the github PR.

  • build
  • ci
  • docs
  • feat
  • fix
  • perf
  • refactor
  • revert
  • style
  • test

Related PRs:

triton-inference-server/server#7964

Where should the reviewer start?

Start with the test cases on the related server PR, and then pb_stub.cc -> infer_response.cc -> python_be.cc.

Test plan:

New tests are added to the related server PR.

  • CI Pipeline ID: 22965017

Caveats:

Responses to BLS models are not populated with the response parameters, if any. (DLIS-7864)

Background

N/A

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

N/A

@kthui kthui added the PR: feat A new feature label Jan 24, 2025
@kthui kthui force-pushed the jacky-py-res-param branch from 7b63cc9 to c3a9c1b Compare January 24, 2025 01:20
@kthui kthui marked this pull request as ready for review January 24, 2025 02:35
@@ -58,6 +60,12 @@ InferResponse::OutputTensors()
return output_tensors_;
}

std::string&
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be mutable or const?

const bool is_last_response = true, void* id = nullptr);
std::vector<std::shared_ptr<PbTensor>>& OutputTensors();
std::string& Parameters();
Copy link
Contributor

@rmccorm4 rmccorm4 Jan 24, 2025

Choose a reason for hiding this comment

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

Looks like this parameters string is expected to be JSON serializable (unless empty string?) - can you add some docstrings describing that expectation?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a README section for response parameters similar to the one for request parameters? https://github.com/triton-inference-server/python_backend?tab=readme-ov-file#inference-request-parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is added. 816d4ac

src/pb_stub.cc Outdated
Comment on lines 1884 to 1886
if (!py::isinstance<py::bool_>(pair.second) &&
!py::isinstance<py::int_>(pair.second) &&
!py::isinstance<py::str>(pair.second)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have any protection against modifying reserved parameter keys such as triton_final_response from user-code?

kthui added 2 commits January 24, 2025 11:24
* Infer response to track parameters

* Add parameters to binding infer response

* Rank parameters argument up among InferResponse constructor arguments

* Add setting parameters to Triton response

* Send response parameters only on non-error

* Fix double declaration

* Unify py dictionary parameters to json str
@kthui kthui force-pushed the jacky-py-res-param branch from c3a9c1b to 816d4ac Compare January 24, 2025 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: feat A new feature
Development

Successfully merging this pull request may close these issues.

2 participants