Skip to content

Conversation

@nfelt
Copy link
Contributor

@nfelt nfelt commented Mar 4, 2021

Implements RPC-level support for the tensor data class in Rustboard (part of #4422). In particular we include tensor time series when generating the ListPlugins response, and we wire up ListTensors and ReadTensors on both the server and client. The latter RPCs are almost identical to the scalars ones; the only nontrivial differences involve handling the actual TensorProto values, where we have to explicitly clone them out of the Commit on the server side, and convert them into numpy arrays on the client side.

This doesn't yet render any data on its own, since nothing populates the tensors fields in the commit (which were introduced by #4710), but with coming PRs that implement the population side, I've tested end-to-end that this correctly renders the expected dashboards. (There are also unit tests for server and client modeled on those for scalars.)

@google-cla google-cla bot added the cla: yes label Mar 4, 2021
@nfelt nfelt added the core:rustboard //tensorboard/data/server/... label Mar 4, 2021
@nfelt nfelt marked this pull request as ready for review March 4, 2021 08:53
@nfelt nfelt requested a review from wchargin March 4, 2021 08:53
Copy link
Contributor

@wchargin wchargin left a comment

Choose a reason for hiding this comment

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

LGTM—a couple passing comments, but no suggestions.

for (step, wall_time, value) in points {
steps.push(step.into());
wall_times.push(wall_time.into());
// Clone the TensorProto to get a copy to send in the response.
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, this seems fine. If we wanted to be really tight with the locks,
we could change the commit’s tensor values to hold Arc<TensorProto>s
and then clone them only after dropping the lock—and maybe one day Prost
and Tonic might learn about Arc<_>s and remove the need to clone
at all. But certainly no action required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I realize it's not exactly ideal to be cloning this here, but SGTM to defer further optimization for now. I'd found myself wondering whether TensorProto was even the right type for the commit to hold in the first place (since we're forcing it into an ndarray ultimately, it could be slimmed down quite a bit, and maybe made more ergonomic to manipulate). If we revisit that, we could also consider reference counting to avoid the clone-inside-critical-section here.


#[tokio::test]
async fn test_read_tensors() {
fn make_string_tensor_proto<T: Into<Bytes>>(value: T) -> pb::TensorProto {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is perfectly fine; it’s also idiomatic to write

fn make_string_tensor_proto(value: impl Into<Bytes>) -> ...

using an existential instead of a type parameter. These are mostly
equivalent; I don’t have a strong preference here.

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; thanks for the tip.

@wchargin wchargin mentioned this pull request Mar 4, 2021
34 tasks
@nfelt nfelt merged commit 3eb2603 into master Mar 5, 2021
@nfelt nfelt deleted the nfelt-rust-tensors-rpcs branch March 5, 2021 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes core:rustboard //tensorboard/data/server/...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants