question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stateful model example for the python backend

See original GitHub issue

Is your feature request related to a problem? Please describe. I am trying to make a stateful model in Python backend, but I couldn’t find any example to do that.

Describe the solution you’d like It would be great if someone can provide an example with a simple python backend, and ideally with the client code to start with.

More specifically, I wonder how we can access the sequence_id, sequence_start, sequence_end and other control signal information from the request object.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

3reactions
zzk0commented, Nov 17, 2021

I was wrong. sorry 😢

I found it! You can get sequence_id and correlation_id

https://github.com/triton-inference-server/python_backend/blob/main/src/pb_stub.cc#L661

EDIT: SO, Python Backend supports sequence batching. sorry for my misleading answer. 😰

2reactions
oewaycommented, Nov 21, 2021

Hi, I confirm that the python backend supports sequences. Would still be nice to add some documentation for accessing sequence related information.

In the config.pbtxt I added:

sequence_batching {
  max_sequence_idle_microseconds: 30000000
  direct {}
  control_input [
    {
      name: "START"
      control [
        {
          kind: CONTROL_SEQUENCE_START
          fp32_false_true: [ 0, 1 ]
        }
      ]
    },
    {
      name: "END"
      control [
        {
          kind: CONTROL_SEQUENCE_END
          fp32_false_true: [ 0, 1 ]
        }
      ]
    }
  ]
}

And in the python model, I can access them by:

sequence_id = request.correlation_id()
start_flag = pb_utils.get_input_tensor_by_name(request, "START").as_numpy()[0]
end_flag = pb_utils.get_input_tensor_by_name(request, "END").as_numpy()[0]

Will close this issue for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Examples of Stateful vs Stateless web applications with Python
Python on the Backend Course: https://www.husseinnasser.com/coursesWe have made a very popular video on stateless vs stateful application, ...
Read more >
Stateful and Stateless LSTM for Time Series Forecasting with ...
This tutorial assumes you have a Python SciPy environment installed. You can use either Python 2 or 3 with this example. This tutorial...
Read more >
Python functions and stateful objects - PySD - Read the Docs
Implements Vensim's PULSE and PULSE TRAIN functions and Xmile's PULSE function. Parameters. time (pysd.py_backend.components.Time) – Model time object.
Read more >
Stateful LSTM model training in Keras - Yumi's Blog
For example, it might be a part of a larger system that works on video frames. It might be required to perform some...
Read more >
WebFrameworks - Python Wiki
A web application may use a combination of a base HTTP application server, a storage mechanism such as a database, a template engine, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found