CUDA AOTI:`reinterpret_tensor` drops the source tensor's storage offset
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- À l'abandon
- Stack technique
- cpp
- Domaine
- backend, machine-learning
Piste de recherche
Start with backends/cuda/runtime/shims/memory.cpp around aoti_torch__reinterpret_tensor and compare its offset handling with the PyTorch implementation linked in the issue. Then inspect the aoti_torch_as_strided caller, which must pass increment 0 after the offset behavior changes. Done means the reproduction reports offset 6 and first value 6 for increment 2, while increment 0 preserves the source offset; a linked pull request is already open.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
🐛 Describe the bug
The CUDA backend's aoti_torch__reinterpret_tensor uses the supplied offset as an absolute storage offset. PyTorch adds it to the source tensor's existing offset.
With a CPU source tensor at offset 4, ExecuTorch returns success but selects the wrong elements. Offsets below are in elements.
| Increment | Expected offset (PyTorch) | Actual offset (ExecuTorch) |
|---|---|---|
| 2 | 6 | 2 |
| 0 | 4 | 0 |
For increment 2, this reads [2, 3, 4] instead of [6, 7, 8] from storage containing 0, 1, ..., 31.
The ExecuTorch aoti_torch__reinterpret_tensor should add self->storage_offset(), matching PyTorch. Its caller aoti_torch_as_strided must then pass increment 0 to preserve the source offset without adding it twice.
Minimal CPU reproduction
Use a CUDA-enabled editable source build. Save this as minimal_repro.cpp beside the executorch/ clone. The build requires CUDA tooling and runtime libraries but no GPU required for reproduction.
#include <executorch/backends/aoti/slim/factory/from_blob.h>
#include <executorch/backends/cuda/runtime/shims/memory.h>
#include <executorch/runtime/platform/platform.h>
#include <cstdio>
int main() {
using namespace executorch::backends;
using executorch::runtime::Error;
et_pal_init();
float data[32];
for (int i = 0; i < 32; ++i) {
data[i] = static_cast<float>(i);
}
auto source = aoti::slim::from_blob(
data, {3, 4}, {4, 1}, aoti::slim::c10::ScalarType::Float,
aoti::slim::CPU_DEVICE, 4);
const int64_t sizes[] = {3};
const int64_t strides[] = {1};
cuda::SlimTensor* view = nullptr;
auto error = cuda::aoti_torch__reinterpret_tensor(
&source, 1, sizes, strides, 2, &view);
if (error != Error::Ok || view == nullptr) {
return 1;
}
std::printf(
"source_offset=%lld increment=2 expected_offset=6 actual_offset=%lld "
"first_value=%.0f\n",
static_cast<long long>(source.storage_offset()),
static_cast<long long>(view->storage_offset()),
*static_cast<float*>(view->data_ptr()));
return cuda::aoti_torch_delete_tensor_object(view) == Error::Ok ? 0 : 1;
}
From the ExecuTorch clone, compile and run it against the editable build's libraries:
ET_SOURCE="$PWD"
mkdir -p ../artifacts
c++ -std=c++17 -DC10_USING_CUSTOM_GENERATED_MACROS \
-I"$ET_SOURCE/.." -I"$ET_SOURCE" \
-I"$ET_SOURCE/runtime/core/portable_type/c10" \
../minimal_repro.cpp \
"$ET_SOURCE/backends/cuda/libaoti_cuda_shims.so" \
"$ET_SOURCE/src/executorch/lib/libexecutorch.so" \
-Wl,-rpath,"$ET_SOURCE/backends/cuda" \
-Wl,-rpath,"$ET_SOURCE/src/executorch/lib" \
-o ../artifacts/minimal_repro_standalone
../artifacts/minimal_repro_standalone
Observed on the unmodified library:
source_offset=4 increment=2 expected_offset=6 actual_offset=2 first_value=2
Versions
PyTorch version: 2.14.0+cu130
Is debug build: False
CUDA used to build PyTorch: 13.0
ROCM used to build PyTorch: N/A
OS: Ubuntu 24.04.5 LTS (aarch64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0
Clang version: Could not collect
CMake version: version 3.31.10
Libc version: glibc-2.39
Python version: 3.12.13 (main, Apr 14 2026, 14:26:08) [Clang 22.1.3 ] (64-bit runtime)
Python platform: Linux-7.0.0-1024-nvidia-aarch64-with-glibc2.39
Is CUDA available: True
CUDA runtime version: 13.0.88
CUDA_MODULE_LOADING set to:
GPU models and configuration: GPU 0: NVIDIA GB10
Nvidia driver version: 580.178.04
cuDNN version: Probably one of the following:
/usr/lib/aarch64-linux-gnu/libcudnn.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_adv.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_cnn.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_engines_precompiled.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_engines_runtime_compiled.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_engines_tensor_ir.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_ext.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_graph.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_heuristic.so.9.27.0
/usr/lib/aarch64-linux-gnu/libcudnn_ops.so.9.27.0
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: False
Caching allocator config: N/A
CPU:
Architecture: aarch64
CPU op-mode(s): 64-bit
Byte Order: Little Endian
CPU(s): 20
On-line CPU(s) list: 0-19
Vendor ID: ARM
Model name: Cortex-X925
Model: 1
Thread(s) per core: 1
Core(s) per socket: 10
Socket(s): 1
Stepping: r0p1
Frequency boost: disabled
CPU(s) scaling MHz: 100%
CPU max MHz: 3900.0000
CPU min MHz: 1378.0000
BogoMIPS: 2000.00
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti ecv afp wfxt
Model name: Cortex-A725
Model: 1
Thread(s) per core: 1
Core(s) per socket: 10
Socket(s): 1
Stepping: r0p1
CPU(s) scaling MHz: 100%
CPU max MHz: 2808.0000
CPU min MHz: 338.0000
BogoMIPS: 2000.00
Flags: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh bti ecv afp wfxt
L1d cache: 1.3 MiB (20 instances)
L1i cache: 1.3 MiB (20 instances)
L2 cache: 25 MiB (20 instances)
L3 cache: 24 MiB (2 instances)
NUMA node(s): 1
NUMA node0 CPU(s): 0-19
Vulnerability Gather data sampling: Not affected
Vulnerability Ghostwrite: Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Old microcode: Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; __user pointer sanitization
Vulnerability Spectre v2: Mitigation; CSV2, BHB
Vulnerability Srbds: Not affected
Vulnerability Tsa: Not affected
Vulnerability Tsx async abort: Not affected
Vulnerability Vmscape: Not affected
Versions of relevant libraries:
[pip3] executorch==1.6.0+ad3b6d2
[pip3] flake8==6.1.0
[pip3] flake8-breakpoint==1.1.0
[pip3] flake8-bugbear==24.4.26
[pip3] flake8-comprehensions==3.14.0
[pip3] flake8-plugin-utils==1.3.3
[pip3] flake8-pyi==23.5.0
[pip3] mypy==1.14.1
[pip3] mypy_extensions==1.2.0
[pip3] numpy==2.5.4
[pip3] nvidia-cublas==13.1.1.3
[pip3] nvidia-cuda-cupti==13.0.85
[pip3] nvidia-cuda-nvrtc==13.0.88
[pip3] nvidia-cuda-runtime==13.0.96
[pip3] nvidia-cudnn-cu13==9.24.0.43
[pip3] nvidia-cufft==12.0.0.61
[pip3] nvidia-curand==10.4.0.35
[pip3] nvidia-cusolver==12.0.4.66
[pip3] nvidia-cusparse==12.6.3.3
[pip3] nvidia-cusparselt-cu13==0.8.1
[pip3] nvidia-nccl-cu13==2.30.7
[pip3] nvidia-nvjitlink==13.5.37
[pip3] nvidia-nvtx==13.0.85
[pip3] pytorch_tokenizers==1.4.0
[pip3] torch==2.14.0+cu130
[pip3] torchao==0.19.0.dev20261103+cpu
[pip3] triton==3.8.0+gitdf3f91dd
[conda] Could not collect
- Langage dominant
- Python
- Étoiles
- 5.2k
- Forks
- 1.2k
- Merge moyen
- 1 j 23 h
- PR mergées (30 j)
- 696
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de pytorch/executorch
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
pytorch/executorch#24434 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
pytorch/executorch#24410 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement triaged
Difficulté 2/5 Une demi-journée Accessibilité débutants 68/100
pytorch/executorch#21640 ·
Les mainteneurs répondent en général sous 1 jour
-
Qualcomm AI Engine Direct: HTP float16 Concat reads a static bool input of all True as FalseOuvertemodule: qnn partner: qualcomm
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
pytorch/executorch#24750 ·
Les mainteneurs répondent en général sous 1 jour
-
module: qnn partner: qualcomm
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
pytorch/executorch#24749 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de pytorch/executorch
Issues similaires
-
Remove the `pull_request_target` workflow before GitHub blocks itPeut-être pris @jat255 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
IBM/mcp-context-forge#7483 ·
Les mainteneurs répondent en général sous 2 jours
-
bug good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
[Bug Report]: OpenAI 辅助 API 连通性测试因输出上限仅 1 token 误报“未知错误”Peut-être pris @fjfanjian l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Project-N-E-K-O/N.E.K.O#3640 ·
Les mainteneurs répondent en général sous 1 jour
-
author-page correction
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
acl-org/acl-anthology#10808 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour