Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion requirements/notebooks.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# just reuse the base requirements
-r base.txt

ipython[all] ~=8.37.0
# all but the test extras, which pull in jupyter-ai and upgrade apt-owned packages in the GPU image
ipython[black,doc,kernel,matplotlib,nbconvert,nbformat,notebook,parallel,qtconsole] ~=8.37.0
numpy
liger-kernel == 0.4.0
cuda-python >=12.6.1, <14.0.0
Expand Down
1 change: 1 addition & 0 deletions thunder/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
# PyTorch version constants
# `use_base_version` so that dev builds like "2.13.0a0+gitabc123" compare as "2.13.0"
_TORCH_GREATER_EQUAL_2_13 = compare_version("torch", operator.ge, "2.13.0", use_base_version=True)
_TORCH_GREATER_EQUAL_2_14 = compare_version("torch", operator.ge, "2.14.0", use_base_version=True)
6 changes: 5 additions & 1 deletion thunder/core/jit_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,11 @@ def _generate_random_str_id() -> str:
continue
trace_of_forward.bound_symbols.append(bsym.from_bsym())
with tracectx(trace_of_forward):
prims.python_return(*(sequencify(output)))
# Keep the fwd graph's output structure. Since torch 2.12 it returns a tuple, which the caller indexes
if isinstance(output, (tuple, list)):
prims.python_return(tuple(output))
else:
prims.python_return(output)

# See NOTE: `autograd_function_apply` and `no_grad` interaction for details about
# `thunder.torch.call_higher_order_function_and_consider_outer_autograd_setting`
Expand Down
6 changes: 6 additions & 0 deletions thunder/tests/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class NOTHING:
)
IS_WINDOWS = platform.system() == "Windows"

# NOTE Running these models in bfloat16 on CPU intermittently kills the process on Windows with an
# illegal instruction, inside eager torch rather than anything of ours. The fp32 variants of the
# same models still run there, and these still run on Linux and macOS.
# TODO: Remove this skip once the crash is fixed upstream, or pinned to a oneDNN/MKL code path we can avoid.
WINDOWS_GPT_CRASH_REASON = "bfloat16 CPU model intermittently crashes the process on Windows (0xc000001d)"


def _bitsandbytes_available():
if not package_available("bitsandbytes"):
Expand Down
5 changes: 5 additions & 0 deletions thunder/tests/opinfos.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import thunder.core.prims as prims
from thunder.core.pytree import tree_map
from thunder.core.symbol import Symbol
from thunder.constants import _TORCH_GREATER_EQUAL_2_14
import thunder.executors as executors
from thunder.tests.framework import _all_devicetypes, custom_comparator, IS_WINDOWS
from thunder.tests.make_tensor import make_tensor, make_tensor_like
Expand Down Expand Up @@ -8574,6 +8575,10 @@ def group_norm_sample_generator(op, device, dtype, requires_grad, **kwargs):
if torch.device(device).type == "cuda" and ndim >= 3 and num_channels == 0:
continue

# torch 2.14 rejects empty channel or spatial dims (an empty batch is still fine)
if _TORCH_GREATER_EQUAL_2_14 and (num_channels == 0 or math.prod(inner_dims) == 0):
continue

a = make(shape)

for weight, bias in itertools.product((False, True), repeat=2):
Expand Down
4 changes: 3 additions & 1 deletion thunder/tests/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pytest
import torch
from torch.testing import assert_close
from thunder.tests.framework import IS_WINDOWS
from thunder.tests.framework import IS_WINDOWS, WINDOWS_GPT_CRASH_REASON

import thunder
from thunder.core.interpreter import (
Expand Down Expand Up @@ -3413,6 +3413,7 @@ def test_nanogpt_block(jit):
assert_close(result, fn(*args, **kwargs))


@pytest.mark.skipif(IS_WINDOWS, reason=WINDOWS_GPT_CRASH_REASON)
def test_nanogpt(jit):
from thunder.benchmarks import NanoGPTBenchmark, NanoGPTConfig, _nanogpt_configs

Expand All @@ -3428,6 +3429,7 @@ def test_nanogpt(jit):
assert_close(result, fn(*args, **kwargs))


@pytest.mark.skipif(IS_WINDOWS, reason=WINDOWS_GPT_CRASH_REASON)
def test_litgpt(jit):
from thunder.benchmarks import LitGPTBenchmark
from thunder.tests.litgpt_model import Config
Expand Down
7 changes: 6 additions & 1 deletion thunder/tests/test_jit_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import thunder

from thunder.tests.framework import requiresCUDA, IS_WINDOWS
from thunder.tests.framework import requiresCUDA, IS_WINDOWS, WINDOWS_GPT_CRASH_REASON
from thunder.core.options import CACHE_OPTIONS
import thunder.core.prims as prims
from thunder import pytorch_executor, nvfuser_executor
Expand Down Expand Up @@ -47,6 +47,9 @@ def _autograd_function_apply_kwargs(args_tensor_mask, non_differentiable_idx=Non
kwargs = {}
if _HAS_ARGS_TENSOR_MASK:
kwargs["args_tensor_mask"] = args_tensor_mask
else:
# required since torch 2.11; the tests here save only x
kwargs["saved_for_backward_idx"] = [0]
if non_differentiable_idx is not None:
kwargs["non_differentiable_idx"] = non_differentiable_idx
return kwargs
Expand Down Expand Up @@ -581,6 +584,7 @@ def h(d, c):
assert args_names == ("a", "b", "c", "d")


@pytest.mark.skipif(IS_WINDOWS, reason=WINDOWS_GPT_CRASH_REASON)
def test_litgpt():
from thunder.benchmarks import LitGPTBenchmark
from thunder.tests.litgpt_model import Config
Expand Down Expand Up @@ -661,6 +665,7 @@ def test_nanogpt_mlp():
assert_close(result, module(*args, **kwargs))


@pytest.mark.skipif(IS_WINDOWS, reason=WINDOWS_GPT_CRASH_REASON)
def test_nanogpt():
from thunder.benchmarks import NanoGPTBenchmark, NanoGPTConfig, _nanogpt_configs

Expand Down
4 changes: 4 additions & 0 deletions thunder/torch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6715,6 +6715,8 @@ def autograd_function_apply(
*args: Any,
args_tensor_mask: Sequence[bool] | None = None,
non_differentiable_idx: Sequence[int] | None = None,
saved_for_backward_idx: Sequence[int] | None = None, # unused, passed by torch >= 2.11
dirty_idx: Sequence[int] | None = None, # unused, passed by torch >= 2.13
) -> TensorProxy | tuple[TensorProxy, ...]:
# TODO: Remove this once this autograd API becomes stable.
# On stable PyTorch, fwd expects ctx as first argument
Expand All @@ -6733,6 +6735,8 @@ def augmented_forward_autograd_function_apply(
*args: Any,
args_tensor_mask: Sequence[bool] | None = None,
non_differentiable_idx: Sequence[int] | None = None,
saved_for_backward_idx: Sequence[int] | None = None, # unused, passed by torch >= 2.11
dirty_idx: Sequence[int] | None = None, # unused, passed by torch >= 2.13
) -> tuple[TensorProxy | tuple[TensorProxy, ...], tuple[Any, ...]]:
# TODO: Remove this once this autograd API becomes stable.
# On stable PyTorch, fwd expects ctx as first argument
Expand Down
Loading