pytorch / xla

Enabling PyTorch on XLA Devices (e.g. Google TPU)
https://pytorch.org/xla
Other
2.44k stars 453 forks source link

Questions about the return value of lazyTensor pytorch xla subgraph #5569

Open ckfgihub opened 12 months ago

ckfgihub commented 12 months ago

Using lazyTensor, pytorch xla will generate an xla subgraph, and its subgraph will add relevant conditions to the liveTensor trained in the current step as the return of the subgraph. my question is:

  1. What does the LiveTensor here mean, and what is the design basis for the value returned by the xla diagram? That is, what can be returned as an xla diagram. The return here refers to the ROOT node in xla.
  2. What is the concept of xla image return here? Is it the return from the XLA device to the HOST device? Or what does it mean? Below I have given a section on using xm.mark_step() to trigger a compile and run code in the training process.

std::shared_ptr XLAGraphExecutor::SyncTensorsGraphInternal( std::vector tensors, absl::Span devices, const SyncTensorsConfig& config, bool warm_up_cache_only) { tensorflow::profiler::TraceMe activity( "SyncTensorsGraphInternal", tensorflow::profiler::TraceMeLevel::kInfo); SyncTensorCollection coll = CollectSyncTensors(tensors, config); if (coll.indices.empty()) { /* Enure previous execution is complete before exiting this

JackCaoG commented 12 months ago
What does the LiveTensor here mean, and what is the design basis for the value returned by the xla diagram? That is, what can be returned as an xla diagram. The return here refers to the ROOT node in xla.

LiveTensor just means all of the XLATensor that is "valid". For example if you have

a = torch.tensor(100, device = xla_device)
b = a + 2

both a and b are considered live tensors. For each pytorch tensor on XLA device we will create a XLATensor C++ class and getLiveTensor will return that I think, or in some wrapper.

I don't quite get the second question through. The way that LTC works is identify all of the tensors that needs value, for example in above computation a's value is known but b isn't. If you do a xm.mark_step() or just print(b), it will use b as a root Node and do a post-order-traversal to find out the sub graph.

What is the concept of xla image return here? Is it the return from the XLA device to the HOST device? Or what does it mean?

what xla image are you referring to here?

ckfgihub commented 12 months ago
What does the LiveTensor here mean, and what is the design basis for the value returned by the xla diagram? That is, what can be returned as an xla diagram. The return here refers to the ROOT node in xla.

LiveTensor just means all of the XLATensor that is "valid". For example if you have

a = torch.tensor(100, device = xla_device)
b = a + 2

both a and b are considered live tensors. For each pytorch tensor on XLA device we will create a XLATensor C++ class and getLiveTensor will return that I think, or in some wrapper.

I don't quite get the second question through. The way that LTC works is identify all of the tensors that needs value, for example in above computation a's value is known but b isn't. If you do a xm.mark_step() or just print(b), it will use b as a root Node and do a post-order-traversal to find out the sub graph.

What is the concept of xla image return here? Is it the return from the XLA device to the HOST device? Or what does it mean?

what xla image are you referring to here?

what xla image are you referring to here? Sorry, I made a typo. I want to say "xla computation graph"