From e02ed6a17c51e168f422e6700f8ae5fde9cfceb5 Mon Sep 17 00:00:00 2001 From: gspark Date: Wed, 4 Nov 2026 11:47:38 +0900 Subject: [PATCH] tests: disable torch device-backend autoload so CUDA backward works (#114) furiosa-torch registers itself through the torch.backends entry point as the PrivateUse1 accelerator. torch then reports rngd as the current accelerator, the autograd engine records no CUDA streams, and every CUDA backward fails the engine.cpp "opt_ready_stream && opt_parent_stream" assert. The tests run on CUDA or the CPU, so conftest turns autoloading off before torch is imported; the rngd backend imports furiosa.torch explicitly and still registers it. Co-Authored-By: Claude Opus 5.5 --- opt_prime/tests/conftest.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/opt_prime/tests/conftest.py b/opt_prime/tests/conftest.py index 53ae4d6a..b99d456b 100644 --- a/opt_prime/tests/conftest.py +++ b/opt_prime/tests/conftest.py @@ -2,8 +2,16 @@ opt_prime.accel targets transformers 5.x. On an older transformers, tests that need a model family or config attribute it does not have are skipped instead of failing. + +An installed NPU torch backend (furiosa-torch) autoloads with torch as the PrivateUse1 accelerator; torch then keeps +no CUDA streams for autograd and every CUDA backward hits the engine.cpp stream assert (#114). Tests run on CUDA or +the CPU, so autoloading is off here; code that needs the rngd device imports furiosa.torch, which still registers it. """ -import pytest +import os + +os.environ.setdefault("TORCH_DEVICE_BACKEND_AUTOLOAD", "0") # before anything imports torch + +import pytest # noqa: E402 try: import transformers