Expand description
Shared runtime contracts for the RustTorch workspace.
§rusttorch-core compatibility
This page is generated from compat/pytorch_api.toml against PyTorch v2.13.0 at commit cf30153, through tch 0.26.0.
Each entry is independently scoped. Supported applies only to its written scope; row counts are not a compatibility score.
§Supported
§core.device
- PyTorch:
torch.device,torch.cuda.is_available,torch.backends.mps.is_available - RustTorch:
rusttorch_core::Device,rusttorch_core::DeviceSpec,rusttorch_core::DeviceCapabilities,rusttorch_core::available_devices,rusttorch_core::resolve_device,rusttorch::Device,rusttorch::DeviceSpec,rusttorch::DeviceCapabilities,rusttorch::available_devices,rusttorch::resolve_device - Implementation: RustTorch frontend backed by LibTorch
- Scope: CPU resolution, runtime-reported CUDA and MPS capability mapping, explicit unavailable-device errors, and CUDA-then-MPS-then-CPU automatic selection.
- Pinned source:
torch/__init__.py - Evidence:
tests/device.rs::cpu_resolves_explicitly,tests/device.rs::reported_capabilities_match_resolved_devices,tests/device.rs::unavailable_or_out_of_range_cuda_is_an_error,tests/device.rs::explicit_mps_is_resolved_or_rejected_without_fallback - Notes: rusttorch-core owns the direct surface and the rusttorch facade preserves it. Accelerator branches are conditional on the linked runtime; this row does not claim a CUDA or MPS pass on every host.
§Partial
§autograd.reverse_mode
- PyTorch:
torch.Tensor.backward,torch.no_grad,torch.Tensor.detach - RustTorch:
rusttorch_core::Tensor,rusttorch_core::no_grad,rusttorch_core::no_grad_guard,rusttorch::Tensor,rusttorch::no_grad,rusttorch::no_grad_guard - Implementation: Delegated to LibTorch
- Scope: Reverse-mode gradients through the tested eager and graph operations, plus tested no-grad and detach behavior.
- Pinned source:
torch/autograd/__init__.py - Evidence:
tests/eager.rs::gradients_accumulate_across_eager_residual_branches,tests/eager.rs::no_grad_and_detach_stop_gradient_recording - Notes: rusttorch-core owns these direct reexports and the rusttorch facade preserves them; LibTorch owns autograd, while hooks, custom Function, forward AD, and the rest of the Python surface remain outside this claim.
§core.random
- PyTorch:
torch.manual_seed - RustTorch:
rusttorch_core::manual_seed,rusttorch::manual_seed - Implementation: Delegated to LibTorch
- Scope: A seed can be delegated to LibTorch; deterministic behavior and cross-language stream identity are not yet verified by a focused test.
- Pinned source:
torch/random.py - Evidence: —
- Notes: rusttorch-core owns the direct function and the rusttorch facade preserves it. The function remains partial until executable evidence proves its documented contract.
§core.tensor
- PyTorch:
torch.Tensor,torch.dtype,torch.nn.functional reduction - RustTorch:
rusttorch_core::Tensor,rusttorch_core::Kind,rusttorch_core::Reduction,rusttorch::Tensor,rusttorch::Kind,rusttorch::Reduction - Implementation: Delegated to LibTorch
- Scope: Root type reexports plus the tensor construction, dtype, device, and eager operations exercised by current RustTorch tests.
- Pinned source:
torch/_tensor.py - Evidence:
tests/eager.rs::tensor_core_types_are_reexported - Notes: rusttorch-core owns the direct reexports and the rusttorch facade preserves them. Reexporting tch::Tensor is not evidence that every torch.Tensor method matches PyTorch.
§Planned
§autograd.forward_ad
- PyTorch:
torch.autograd.forward_ad - RustTorch: —
- Implementation: Not implemented
- Scope: Forward-mode automatic differentiation and dual tensors are not exposed.
- Pinned source:
torch/autograd/forward_ad.py - Evidence: —
- Notes: This row is separate from the currently tested reverse-mode subset.
§Python-only
No entries.
§Not supported
No entries.
Re-exports§
pub use device::DeviceCapabilities;pub use device::DeviceSpec;pub use device::available_devices;pub use device::resolve_device;pub use error::Result;pub use error::RustTorchError;
Modules§
- device
- Runtime device discovery and strict device selection.
- error
- Errors returned by the fallible RustTorch API.
Structs§
- Tensor
- A tensor object.
Enums§
Functions§
- manual_
seed - Seeds LibTorch’s random number generator.
- no_grad
- Runs a closure without keeping track of gradients.
- no_
grad_ guard - Disables gradient tracking, this will be enabled back when the
returned value gets deallocated.
Note that it is important to bind this to a name like
_guardand not to_as the latter would immediately drop the guard. See https://internals.rust-lang.org/t/pre-rfc-must-bind/12658/46 for more details.