docstr: Make sure autotuning addmm in sub processes work without crashes.
docstr_tok: ["Make","sure","autotuning","addmm","in","sub","processes","work","without","crashes","."]
code: def test_max_autotune_cutlass_backend_addmm(
      self, dynamic, max_autotune_gemm_backends
  ):
      """
      Make sure autotuning addmm in sub processes work without crashes.
      """
  
      if max_autotune_gemm_backends == "CUTLASS" and torch.version.hip:
          return
  
      torch.backends.cuda.matmul.allow_fp16_reduced_precision_reduction = (
          False
      )
  
      def addmm(x, a, b, alpha, beta):
          return torch.addmm(x, a, b, alpha=alpha, beta=beta)
  
      def compare_results(
          m: int,
          k: int,
          n: int,
          alpha: float,
          beta: float,
          x_shape: List[int],
      ) -> None:
          x = torch.randn(x_shape).cuda().half()
          a = torch.randn(m, k).cuda().half()
          b = torch.randn(k, n).cuda().half()
          y_expected = addmm(x, a, b, alpha, beta)
  
          compiled_fn = torch.compile(addmm, dynamic=dynamic)
          y = compiled_fn(x, a, b, alpha, beta)
          torch.testing.assert_close(y, y_expected)
  
      with config.patch(
          {
              "max_autotune": True,
              "autotune_in_subproc": False,
              "max_autotune_gemm_backends": max_autotune_gemm_backends,
              "cuda.cutlass_dir": _CUTLASS_DIR,
              "cuda.cutlass_max_profiling_configs": 2,
          }
      ):
          # No broadcast
          compare_results(4096, 25728, 2048, 2.0, 0.4, [4096, 2048])
          # Broadcast first dim.
          compare_results(4096, 25728, 2048, 2.0, 0.4, [2048])
          # Broadcast last dim.
          if (
              not SM90OrLater
              and max_autotune_gemm_backends == "CUTLASS"
          ):
              with self.assertRaisesRegex(
                  RuntimeError, "No choices to select"
              ):
                  # CUTLASS2 doesn't support Bias last-dim broadcast.
                  compare_results(
                      4096, 25728, 2048, 2.0, 0.4, [4096, 1]
                  )
          else:
              compare_results(4096, 25728, 2048, 2.0, 0.4, [4096, 1])
  
imports: import os
  import unittest
  from typing import Callable, List, Optional
  import torch
  from torch import multiprocessing
  from torch._dynamo.test_case import run_tests, TestCase
  from torch._dynamo.testing import reset_rng_state
  from torch._dynamo.utils import counters
  from torch._inductor import config
  from torch._inductor.autotune_process import BenchmarkRequest, CUDA_VISIBLE_DEVICES, TuningProcessPool
  from torch._inductor.graph import GraphLowering
  from torch._inductor.ir import Buffer, FixedLayout
  from torch._inductor.kernel.mm_plus_mm import aten_mm_plus_mm
  from torch._inductor.select_algorithm import AlgorithmSelectorCache, ChoiceCaller, TritonTemplateCaller
  from torch._inductor.utils import run_and_get_code
  from torch._inductor.virtualized import V
  from torch.fx.experimental.proxy_tensor import make_fx
  from torch.testing import FileCheck
  from torch.testing._internal.common_cuda import SM75OrLater, SM90OrLater
  from torch.testing._internal.common_utils import instantiate_parametrized_tests, parametrize, skipIfRocm
  from torch.testing._internal.inductor_utils import HAS_CPU, HAS_CUDA
label_desc: Use image node_id 22 for calling the TestMaxAutotune obj's underlying member method code with example usage: obj.test_max_autotune_cutlass_backend_addmm(dynamic, max_autotune_gemm_backends) and returns: torch