# AOT ID: ['0_forward']
from ctypes import c_void_p, c_long, c_int
import torch
import math
import random
import os
import tempfile
from math import inf, nan
from torch._inductor.hooks import run_intermediate_hooks
from torch._inductor.utils import maybe_profile
from torch._inductor.codegen.memory_planning import _align as align
from torch import device, empty_strided
from torch._inductor.async_compile import AsyncCompile
from torch._inductor.select_algorithm import extern_kernels
from torch._inductor.codegen.multi_kernel import MultiKernelCall
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid, split_scan_grid, grid_combo_kernels, start_graph, end_graph
from torch._C import _cuda_getCurrentRawStream as get_raw_stream

aten = torch.ops.aten
inductor_ops = torch.ops.inductor
_quantized = torch.ops._quantized
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cpu = torch._C._dynamo.guards._empty_strided_cpu
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
empty_strided_xpu = torch._C._dynamo.guards._empty_strided_xpu
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor
alloc_from_pool = torch.ops.inductor._alloc_from_pool
async_compile = AsyncCompile()


# kernel path: runs/run_shard_7/inductor_cache/7r/c7ro6rxiigiepcbzbff4nww6gltt467oipk63naj2aqqrmk5eo55.py
# Topologically Sorted Source Nodes: [mask_s, lt], Original ATen: [aten.stack, aten.lt]
# Source node to ATen node mapping:
#   lt => lt
#   mask_s => cat
# Graph fragment:
#   %cat : [num_users=1] = call_function[target=torch.ops.aten.cat.default](args = ([%sub_1, %sub_3, %sub_5, %sub_7], 1), kwargs = {})
#   %lt : [num_users=2] = call_function[target=torch.ops.aten.lt.Scalar](args = (%view, 0.5), kwargs = {})
triton_poi_fused_lt_stack_0 = async_compile.triton('triton_poi_fused_lt_stack_0', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*i1', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_lt_stack_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_lt_stack_0(in_ptr0, out_ptr1, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = (xindex // 4) % 16
    x0 = xindex % 4
    x2 = (xindex // 64)
    x3 = xindex
    tmp0 = x1
    tmp1 = tl.full([1], 0, tl.int64)
    tmp2 = tmp0 >= tmp1
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + (4*x1) + (16*x2)), tmp4 & xmask, other=0.0)
    tmp6 = 8.0
    tmp7 = tmp5 - tmp6
    tmp8 = tl.sigmoid(tmp7)
    tmp9 = 1.0
    tmp10 = tmp9 - tmp8
    tmp11 = tl.full(tmp10.shape, 0.0, tmp10.dtype)
    tmp12 = tl.where(tmp4, tmp10, tmp11)
    tmp13 = tmp0 >= tmp3
    tmp14 = tl.full([1], 8, tl.int64)
    tmp15 = tmp0 < tmp14
    tmp16 = tmp13 & tmp15
    tmp17 = tl.load(in_ptr0 + (x0 + (4*((-4) + x1)) + (16*x2)), tmp16 & xmask, other=0.0)
    tmp18 = 12.0
    tmp19 = tmp17 - tmp18
    tmp20 = tl.sigmoid(tmp19)
    tmp21 = tmp9 - tmp20
    tmp22 = tl.full(tmp21.shape, 0.0, tmp21.dtype)
    tmp23 = tl.where(tmp16, tmp21, tmp22)
    tmp24 = tmp0 >= tmp14
    tmp25 = tl.full([1], 12, tl.int64)
    tmp26 = tmp0 < tmp25
    tmp27 = tmp24 & tmp26
    tmp28 = tl.load(in_ptr0 + (x0 + (4*((-8) + x1)) + (16*x2)), tmp27 & xmask, other=0.0)
    tmp29 = 16.0
    tmp30 = tmp28 - tmp29
    tmp31 = tl.sigmoid(tmp30)
    tmp32 = tmp9 - tmp31
    tmp33 = tl.full(tmp32.shape, 0.0, tmp32.dtype)
    tmp34 = tl.where(tmp27, tmp32, tmp33)
    tmp35 = tmp0 >= tmp25
    tmp36 = tl.full([1], 16, tl.int64)
    tmp37 = tmp0 < tmp36
    tmp38 = tl.load(in_ptr0 + (x0 + (4*((-12) + x1)) + (16*x2)), tmp35 & xmask, other=0.0)
    tmp39 = 20.0
    tmp40 = tmp38 - tmp39
    tmp41 = tl.sigmoid(tmp40)
    tmp42 = tmp9 - tmp41
    tmp43 = tl.full(tmp42.shape, 0.0, tmp42.dtype)
    tmp44 = tl.where(tmp35, tmp42, tmp43)
    tmp45 = tl.where(tmp27, tmp34, tmp44)
    tmp46 = tl.where(tmp16, tmp23, tmp45)
    tmp47 = tl.where(tmp4, tmp12, tmp46)
    tmp48 = 0.5
    tmp49 = tmp47 < tmp48
    tl.store(out_ptr1 + (x3), tmp49, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/vk/cvkv6sboiitypmnyxfoq5lxlbcpaztaxqfkyjuv75l2bihdebyda.py
# Topologically Sorted Source Nodes: [mean, var, add, std, sub_8, x, x_1, x_2], Original ATen: [aten.mean, aten.var, aten.add, aten.sqrt, aten.sub, aten.mul, aten.div]
# Source node to ATen node mapping:
#   add => add
#   mean => mean
#   std => sqrt
#   sub_8 => sub_8
#   var => var
#   x => mul
#   x_1 => div
#   x_2 => add_1
# Graph fragment:
#   %mean : [num_users=2] = call_function[target=torch.ops.aten.mean.dim](args = (%primals_2, [-1], True), kwargs = {})
#   %var : [num_users=1] = call_function[target=torch.ops.aten.var.correction](args = (%primals_2, [-1]), kwargs = {correction: 0, keepdim: True})
#   %add : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%var, 1e-05), kwargs = {})
#   %sqrt : [num_users=2] = call_function[target=torch.ops.aten.sqrt.default](args = (%add,), kwargs = {})
#   %sub_8 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%primals_2, %mean), kwargs = {})
#   %mul : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%primals_3, %sub_8), kwargs = {})
#   %div : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%mul, %sqrt), kwargs = {})
#   %add_1 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div, %primals_4), kwargs = {})
triton_per_fused_add_div_mean_mul_sqrt_sub_var_1 = async_compile.triton('triton_per_fused_add_div_mean_mul_sqrt_sub_var_1', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.persistent_reduction(
    size_hints=[64, 32],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: 'i32', 7: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6, 7), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_add_div_mean_mul_sqrt_sub_var_1', 'mutated_arg_names': ['in_out_ptr0', 'in_out_ptr1'], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 4, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused_add_div_mean_mul_sqrt_sub_var_1(in_out_ptr0, in_out_ptr1, in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    rnumel = 32
    RBLOCK: tl.constexpr = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + (32*x0)), xmask, other=0.0)
    tmp25 = tl.load(in_ptr1 + (r1), None, eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr2 + (r1), None, eviction_policy='evict_last')
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.where(xmask, tmp1, 0)
    tmp4 = tl.sum(tmp3, 1)[:, None]
    tmp6 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
    tmp8 = tl.where(xmask, tmp6, 0)
    tmp9 = tl.sum(tmp8, 1)[:, None]
    tmp10 = tl.full([XBLOCK, 1], 32, tl.int32)
    tmp11 = tmp10.to(tl.float32)
    tmp12 = tmp9 / tmp11
    tmp13 = tmp1 - tmp12
    tmp14 = tmp13 * tmp13
    tmp15 = tl.broadcast_to(tmp14, [XBLOCK, RBLOCK])
    tmp17 = tl.where(xmask, tmp15, 0)
    tmp18 = tl.sum(tmp17, 1)[:, None]
    tmp19 = 32.0
    tmp20 = tmp4 / tmp19
    tmp21 = tmp18 / tmp19
    tmp22 = 1e-05
    tmp23 = tmp21 + tmp22
    tmp24 = libdevice.sqrt(tmp23)
    tmp26 = tmp0 - tmp20
    tmp27 = tmp25 * tmp26
    tmp28 = tmp27 / tmp24
    tmp30 = tmp28 + tmp29
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (x0), tmp20, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + (x0), tmp24, xmask)
    tl.store(out_ptr0 + (r1 + (32*x0)), tmp30, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/pl/cplaegylqzwimiascwxpzxkzv6wll2horn756obggce4zcrfzgrt.py
# Topologically Sorted Source Nodes: [mean_2, var_1, add_1, std_1, sub_9, x_3, x_4, x_5], Original ATen: [aten.mean, aten.var, aten.add, aten.sqrt, aten.sub, aten.mul, aten.div]
# Source node to ATen node mapping:
#   add_1 => add_2
#   mean_2 => mean_1
#   std_1 => sqrt_1
#   sub_9 => sub_9
#   var_1 => var_1
#   x_3 => mul_1
#   x_4 => div_1
#   x_5 => add_3
# Graph fragment:
#   %mean_1 : [num_users=2] = call_function[target=torch.ops.aten.mean.dim](args = (%primals_5, [-1], True), kwargs = {})
#   %var_1 : [num_users=1] = call_function[target=torch.ops.aten.var.correction](args = (%primals_5, [-1]), kwargs = {correction: 0, keepdim: True})
#   %add_2 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%var_1, 1e-05), kwargs = {})
#   %sqrt_1 : [num_users=2] = call_function[target=torch.ops.aten.sqrt.default](args = (%add_2,), kwargs = {})
#   %sub_9 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%primals_5, %mean_1), kwargs = {})
#   %mul_1 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%primals_6, %sub_9), kwargs = {})
#   %div_1 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%mul_1, %sqrt_1), kwargs = {})
#   %add_3 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_1, %primals_7), kwargs = {})
triton_per_fused_add_div_mean_mul_sqrt_sub_var_2 = async_compile.triton('triton_per_fused_add_div_mean_mul_sqrt_sub_var_2', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.persistent_reduction(
    size_hints=[64, 64],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: 'i32', 7: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6, 7), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_add_div_mean_mul_sqrt_sub_var_2', 'mutated_arg_names': ['in_out_ptr0', 'in_out_ptr1'], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 4, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused_add_div_mean_mul_sqrt_sub_var_2(in_out_ptr0, in_out_ptr1, in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    rnumel = 64
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + (64*x0)), xmask, other=0.0)
    tmp25 = tl.load(in_ptr1 + (r1), None, eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr2 + (r1), None, eviction_policy='evict_last')
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.where(xmask, tmp1, 0)
    tmp4 = tl.sum(tmp3, 1)[:, None]
    tmp6 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
    tmp8 = tl.where(xmask, tmp6, 0)
    tmp9 = tl.sum(tmp8, 1)[:, None]
    tmp10 = tl.full([XBLOCK, 1], 64, tl.int32)
    tmp11 = tmp10.to(tl.float32)
    tmp12 = tmp9 / tmp11
    tmp13 = tmp1 - tmp12
    tmp14 = tmp13 * tmp13
    tmp15 = tl.broadcast_to(tmp14, [XBLOCK, RBLOCK])
    tmp17 = tl.where(xmask, tmp15, 0)
    tmp18 = tl.sum(tmp17, 1)[:, None]
    tmp19 = 64.0
    tmp20 = tmp4 / tmp19
    tmp21 = tmp18 / tmp19
    tmp22 = 1e-05
    tmp23 = tmp21 + tmp22
    tmp24 = libdevice.sqrt(tmp23)
    tmp26 = tmp0 - tmp20
    tmp27 = tmp25 * tmp26
    tmp28 = tmp27 / tmp24
    tmp30 = tmp28 + tmp29
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (x0), tmp20, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + (x0), tmp24, xmask)
    tl.store(out_ptr0 + (r1 + (64*x0)), tmp30, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/5p/c5pibcu5puwpuh4keg4u5q6a3og6tddx2p4gwu2eiz33bu7uevc4.py
# Topologically Sorted Source Nodes: [q_1, attention], Original ATen: [aten.mul, aten.clone]
# Source node to ATen node mapping:
#   attention => clone
#   q_1 => mul_2
# Graph fragment:
#   %mul_2 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%permute_1, 0.17677669529663687), kwargs = {})
#   %clone : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%expand,), kwargs = {memory_format: torch.contiguous_format})
triton_poi_fused_clone_mul_3 = async_compile.triton('triton_poi_fused_clone_mul_3', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[8192], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clone_mul_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_clone_mul_3(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 8192
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 128
    x1 = (xindex // 128) % 4
    x2 = (xindex // 512) % 4
    x3 = (xindex // 2048)
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + (128*x2) + (512*x1) + (2048*x3)), None)
    tmp1 = tl.load(in_ptr1 + (x0), None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = 0.17677669529663687
    tmp4 = tmp2 * tmp3
    tl.store(out_ptr0 + (x4), tmp4, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/eb/cebhq2wzqzzoga3nzeuthh267dho2v4y5qhop5lvv2hdwvyz2cju.py
# Topologically Sorted Source Nodes: [attention], Original ATen: [aten.clone]
# Source node to ATen node mapping:
#   attention => clone_1
# Graph fragment:
#   %clone_1 : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%expand_1,), kwargs = {memory_format: torch.contiguous_format})
triton_poi_fused_clone_4 = async_compile.triton('triton_poi_fused_clone_4', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[2048, 4], tile_hint=TileHint.DEFAULT,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clone_4', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_clone_4(in_ptr0, in_ptr1, out_ptr0, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
    ynumel = 2048
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    ymask = tl.full([XBLOCK, YBLOCK], True, tl.int1)
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x3 = xindex
    y2 = (yindex // 512)
    y4 = yindex % 512
    y0 = yindex % 128
    y5 = yindex
    tmp0 = tl.load(in_ptr0 + (y4 + (512*x3) + (2048*y2)), xmask, eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + (y0), None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(out_ptr0 + (x3 + (4*y5)), tmp2, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/3a/c3alfyfsoya27hzppi42pior7fgqmuicqa4rly5son4scj57qalq.py
# Topologically Sorted Source Nodes: [attention_1, attention_2], Original ATen: [aten.masked_fill, aten._softmax]
# Source node to ATen node mapping:
#   attention_1 => full_default, where
#   attention_2 => amax, exp, sub_10, sum_1
# Graph fragment:
#   %full_default : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], -3.4028234663852886e+38), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%lt, %full_default, %view_15), kwargs = {})
#   %amax : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%where, [-1], True), kwargs = {})
#   %sub_10 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%where, %amax), kwargs = {})
#   %exp : [num_users=2] = call_function[target=torch.ops.aten.exp.default](args = (%sub_10,), kwargs = {})
#   %sum_1 : [num_users=1] = call_function[target=torch.ops.aten.sum.dim_IntList](args = (%exp, [-1], True), kwargs = {})
triton_poi_fused__softmax_masked_fill_5 = async_compile.triton('triton_poi_fused__softmax_masked_fill_5', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[64], 
    filename=__file__,
    triton_meta={'signature': {0: '*i1', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__softmax_masked_fill_5', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 8, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused__softmax_masked_fill_5(in_ptr0, in_ptr1, out_ptr0, out_ptr1, xnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (4*x0), xmask, eviction_policy='evict_last').to(tl.int1)
    tmp1 = tl.load(in_ptr1 + (4*x0), xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (1 + (4*x0)), xmask, eviction_policy='evict_last').to(tl.int1)
    tmp5 = tl.load(in_ptr1 + (1 + (4*x0)), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr0 + (2 + (4*x0)), xmask, eviction_policy='evict_last').to(tl.int1)
    tmp9 = tl.load(in_ptr1 + (2 + (4*x0)), xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr0 + (3 + (4*x0)), xmask, eviction_policy='evict_last').to(tl.int1)
    tmp13 = tl.load(in_ptr1 + (3 + (4*x0)), xmask, eviction_policy='evict_last')
    tmp2 = -3.4028234663852886e+38
    tmp3 = tl.where(tmp0, tmp2, tmp1)
    tmp6 = tl.where(tmp4, tmp2, tmp5)
    tmp7 = triton_helpers.maximum(tmp3, tmp6)
    tmp10 = tl.where(tmp8, tmp2, tmp9)
    tmp11 = triton_helpers.maximum(tmp7, tmp10)
    tmp14 = tl.where(tmp12, tmp2, tmp13)
    tmp15 = triton_helpers.maximum(tmp11, tmp14)
    tmp16 = tmp3 - tmp15
    tmp17 = tl_math.exp(tmp16)
    tmp18 = tmp6 - tmp15
    tmp19 = tl_math.exp(tmp18)
    tmp20 = tmp17 + tmp19
    tmp21 = tmp10 - tmp15
    tmp22 = tl_math.exp(tmp21)
    tmp23 = tmp20 + tmp22
    tmp24 = tmp14 - tmp15
    tmp25 = tl_math.exp(tmp24)
    tmp26 = tmp23 + tmp25
    tl.store(out_ptr0 + (x0), tmp15, xmask)
    tl.store(out_ptr1 + (x0), tmp26, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/me/cme7rwkpnkxnmmvnegbcsfbjinkqvdoz6iwka57dxuw6xlx2wczs.py
# Topologically Sorted Source Nodes: [attention_1, attention_2], Original ATen: [aten.masked_fill, aten._softmax]
# Source node to ATen node mapping:
#   attention_1 => full_default, where
#   attention_2 => amax, div_2, exp, sub_10
# Graph fragment:
#   %full_default : [num_users=1] = call_function[target=torch.ops.aten.full.default](args = ([], -3.4028234663852886e+38), kwargs = {dtype: torch.float32, layout: torch.strided, device: cuda:0, pin_memory: False})
#   %where : [num_users=2] = call_function[target=torch.ops.aten.where.self](args = (%lt, %full_default, %view_15), kwargs = {})
#   %amax : [num_users=1] = call_function[target=torch.ops.aten.amax.default](args = (%where, [-1], True), kwargs = {})
#   %sub_10 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%where, %amax), kwargs = {})
#   %exp : [num_users=2] = call_function[target=torch.ops.aten.exp.default](args = (%sub_10,), kwargs = {})
#   %div_2 : [num_users=2] = call_function[target=torch.ops.aten.div.Tensor](args = (%exp, %sum_1), kwargs = {})
triton_poi_fused__softmax_masked_fill_6 = async_compile.triton('triton_poi_fused__softmax_masked_fill_6', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[256], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*i1', 2: '*fp32', 3: '*fp32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__softmax_masked_fill_6', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused__softmax_masked_fill_6(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, xnumel, XBLOCK : tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = (xindex // 4)
    tmp0 = tl.load(in_ptr0 + (x2), xmask).to(tl.int1)
    tmp1 = tl.load(in_out_ptr0 + (x2), xmask)
    tmp4 = tl.load(in_ptr1 + (x1), xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr2 + (x1), xmask, eviction_policy='evict_last')
    tmp2 = -3.4028234663852886e+38
    tmp3 = tl.where(tmp0, tmp2, tmp1)
    tmp5 = tmp3 - tmp4
    tmp6 = tl_math.exp(tmp5)
    tmp8 = tmp6 / tmp7
    tl.store(in_out_ptr0 + (x2), tmp8, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/ee/ceevecisn47duwls63zer6rib567awr4dcrak3hmiibwxfbwmytd.py
# Topologically Sorted Source Nodes: [out], Original ATen: [aten.clone]
# Source node to ATen node mapping:
#   out => clone_2
# Graph fragment:
#   %clone_2 : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%permute_10,), kwargs = {memory_format: torch.contiguous_format})
triton_poi_fused_clone_7 = async_compile.triton('triton_poi_fused_clone_7', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[4096], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clone_7', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_clone_7(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4096
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 16
    x1 = (xindex // 16) % 4
    x2 = (xindex // 64) % 4
    x3 = (xindex // 256) % 4
    x4 = (xindex // 1024)
    x6 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + (16*x3) + (64*x2) + (256*x1) + (1024*x4)), None)
    tmp1 = tl.load(in_ptr1 + (x0 + (16*x3)), None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(out_ptr0 + (x6), tmp2, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/qk/cqkv6yylcqvjh44xvdqzugpr6swgybxmvuj6md2wytdzfm5foaxn.py
# Topologically Sorted Source Nodes: [contiguous], Original ATen: [aten.clone]
# Source node to ATen node mapping:
#   contiguous => clone_3
# Graph fragment:
#   %clone_3 : [num_users=1] = call_function[target=torch.ops.aten.clone.default](args = (%permute_12,), kwargs = {memory_format: torch.contiguous_format})
triton_poi_fused_clone_8 = async_compile.triton('triton_poi_fused_clone_8', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[4096], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clone_8', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_clone_8(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4096
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 16
    x1 = (xindex // 16) % 4
    x2 = (xindex // 64) % 4
    x3 = (xindex // 256) % 4
    x4 = (xindex // 1024)
    x5 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + (16*x3) + (64*x2) + (256*x1) + (1024*x4)), None)
    tl.store(out_ptr0 + (x5), tmp0, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/xj/cxjgml7brgyfptvdviubjhpqbykv4tqbxnuyvupgox6h4qoja4p5.py
# Topologically Sorted Source Nodes: [msa, mean_4, var_2, add_3, std_2, sub_10, x_6, x_7, x_8], Original ATen: [aten.add, aten.mean, aten.var, aten.sqrt, aten.sub, aten.mul, aten.div]
# Source node to ATen node mapping:
#   add_3 => add_5
#   mean_4 => mean_2
#   msa => add_4
#   std_2 => sqrt_2
#   sub_10 => sub_11
#   var_2 => var_2
#   x_6 => mul_3
#   x_7 => div_3
#   x_8 => add_6
# Graph fragment:
#   %add_4 : [num_users=4] = call_function[target=torch.ops.aten.add.Tensor](args = (%primals_5, %view_22), kwargs = {})
#   %mean_2 : [num_users=2] = call_function[target=torch.ops.aten.mean.dim](args = (%add_4, [-1], True), kwargs = {})
#   %var_2 : [num_users=1] = call_function[target=torch.ops.aten.var.correction](args = (%add_4, [-1]), kwargs = {correction: 0, keepdim: True})
#   %add_5 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%var_2, 1e-05), kwargs = {})
#   %sqrt_2 : [num_users=2] = call_function[target=torch.ops.aten.sqrt.default](args = (%add_5,), kwargs = {})
#   %sub_11 : [num_users=1] = call_function[target=torch.ops.aten.sub.Tensor](args = (%add_4, %mean_2), kwargs = {})
#   %mul_3 : [num_users=1] = call_function[target=torch.ops.aten.mul.Tensor](args = (%primals_16, %sub_11), kwargs = {})
#   %div_3 : [num_users=1] = call_function[target=torch.ops.aten.div.Tensor](args = (%mul_3, %sqrt_2), kwargs = {})
#   %add_6 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%div_3, %primals_17), kwargs = {})
triton_per_fused_add_div_mean_mul_sqrt_sub_var_9 = async_compile.triton('triton_per_fused_add_div_mean_mul_sqrt_sub_var_9', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.persistent_reduction(
    size_hints=[64, 64],
    reduction_hint=ReductionHint.INNER,
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp32', 5: '*fp32', 6: '*fp32', 7: 'i32', 8: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 6, 7, 8), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_per_fused_add_div_mean_mul_sqrt_sub_var_9', 'mutated_arg_names': ['in_out_ptr0', 'in_out_ptr1'], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 4, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False}
)
@triton.jit
def triton_per_fused_add_div_mean_mul_sqrt_sub_var_9(in_out_ptr0, in_out_ptr1, in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0, xnumel, rnumel, XBLOCK : tl.constexpr):
    xnumel = 64
    rnumel = 64
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    roffset = 0
    rmask = tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + (64*x0)), xmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (r1 + (64*x0)), xmask, other=0.0)
    tmp27 = tl.load(in_ptr2 + (r1), None, eviction_policy='evict_last')
    tmp31 = tl.load(in_ptr3 + (r1), None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK, RBLOCK])
    tmp5 = tl.where(xmask, tmp3, 0)
    tmp6 = tl.sum(tmp5, 1)[:, None]
    tmp8 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp10 = tl.where(xmask, tmp8, 0)
    tmp11 = tl.sum(tmp10, 1)[:, None]
    tmp12 = tl.full([XBLOCK, 1], 64, tl.int32)
    tmp13 = tmp12.to(tl.float32)
    tmp14 = tmp11 / tmp13
    tmp15 = tmp3 - tmp14
    tmp16 = tmp15 * tmp15
    tmp17 = tl.broadcast_to(tmp16, [XBLOCK, RBLOCK])
    tmp19 = tl.where(xmask, tmp17, 0)
    tmp20 = tl.sum(tmp19, 1)[:, None]
    tmp21 = 64.0
    tmp22 = tmp6 / tmp21
    tmp23 = tmp20 / tmp21
    tmp24 = 1e-05
    tmp25 = tmp23 + tmp24
    tmp26 = libdevice.sqrt(tmp25)
    tmp28 = tmp2 - tmp22
    tmp29 = tmp27 * tmp28
    tmp30 = tmp29 / tmp26
    tmp32 = tmp30 + tmp31
    tl.debug_barrier()
    tl.store(in_out_ptr0 + (x0), tmp22, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + (x0), tmp26, xmask)
    tl.store(out_ptr0 + (r1 + (64*x0)), tmp32, xmask)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/3n/c3nobtl75ypqh6uwttv2ohqh6coi5zxkbpfmq6oindp66qdf32fp.py
# Topologically Sorted Source Nodes: [relu_], Original ATen: [aten.relu, aten.threshold_backward]
# Source node to ATen node mapping:
#   relu_ => relu
# Graph fragment:
#   %relu : [num_users=1] = call_function[target=torch.ops.aten.relu.default](args = (%view_25,), kwargs = {})
#   %le : [num_users=1] = call_function[target=torch.ops.aten.le.Scalar](args = (%view_30, 0), kwargs = {})
triton_poi_fused_relu_threshold_backward_10 = async_compile.triton('triton_poi_fused_relu_threshold_backward_10', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[16384], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*i1', 3: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_relu_threshold_backward_10', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_relu_threshold_backward_10(in_out_ptr0, in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16384
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x4 = xindex
    x0 = xindex % 256
    tmp0 = tl.load(in_out_ptr0 + (x4), None)
    tmp1 = tl.load(in_ptr0 + (x0), None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp5 = 0.0
    tmp6 = tmp4 <= tmp5
    tl.store(in_out_ptr0 + (x4), tmp4, None)
    tl.store(out_ptr0 + (x4), tmp6, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/kt/cktem4mm36mu2rsucwojg5yvdn3bhfqskq7cxhglpujhzg7gdof3.py
# Topologically Sorted Source Nodes: [src], Original ATen: [aten.view]
# Source node to ATen node mapping:
#   src => view_31
# Graph fragment:
#   %view_31 : [num_users=2] = call_function[target=torch.ops.aten.reshape.default](args = (%view_30, [64, 256]), kwargs = {})
triton_poi_fused_view_11 = async_compile.triton('triton_poi_fused_view_11', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[16384], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_view_11', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_view_11(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
    xnumel = 16384
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 256
    x1 = (xindex // 256)
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + (256*x1) + (1024*((x1 % 4) // 4)) + (4096*(((4*((x1 // 4) % 4)) + (x1 % 4)) // 16))), None)
    tl.store(out_ptr0 + (x2), tmp0, None)
''', device_str='cuda')


# kernel path: runs/run_shard_7/inductor_cache/ji/cjigcf3tl3mgt3p5in4eqr5xxvipm6a4n2yw6qeoi3b3rk3fmgma.py
# Topologically Sorted Source Nodes: [msa, msa_1], Original ATen: [aten.add]
# Source node to ATen node mapping:
#   msa => add_4
#   msa_1 => add_7
# Graph fragment:
#   %add_4 : [num_users=4] = call_function[target=torch.ops.aten.add.Tensor](args = (%primals_5, %view_22), kwargs = {})
#   %add_7 : [num_users=1] = call_function[target=torch.ops.aten.add.Tensor](args = (%add_4, %view_32), kwargs = {})
triton_poi_fused_add_12 = async_compile.triton('triton_poi_fused_add_12', '''
import triton
import triton.language as tl
from triton.compiler.compiler import AttrsDescriptor

from torch._inductor.runtime import triton_helpers, triton_heuristics
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
from torch._inductor.runtime.hints import AutotuneHint, ReductionHint, TileHint, instance_descriptor, DeviceProperties

@triton_heuristics.pointwise(
    size_hints=[4096], 
    filename=__file__,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=80, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=2048, multi_processor_count=108), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4), equal_to_1=())]},
    inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_12', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 0, 'backend_hash': 'A9C866B4A14FD3277824029365D703C2427B2E685E54EC9B3EF4ADC8D1EEAC1D', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': None, 'force_disable_caches': False, 'dynamic_scale_rblock': True, 'max_autotune': False, 'max_autotune_pointwise': False, 'min_split_scan_rblock': 256, 'spill_threshold': 16, 'store_cubin': False},
    min_elem_per_thread=0
)
@triton.jit
def triton_poi_fused_add_12(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, xnumel, XBLOCK : tl.constexpr):
    xnumel = 4096
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = tl.full([XBLOCK], True, tl.int1)
    x2 = xindex
    x0 = xindex % 64
    tmp0 = tl.load(in_ptr0 + (x2), None)
    tmp1 = tl.load(in_ptr1 + (x2), None)
    tmp3 = tl.load(in_out_ptr0 + (x2), None)
    tmp4 = tl.load(in_ptr2 + (x0), None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp5 = tmp3 + tmp4
    tmp6 = tmp2 + tmp5
    tl.store(in_out_ptr0 + (x2), tmp6, None)
''', device_str='cuda')


async_compile.wait(globals())
del async_compile

def call(args):
    primals_1, primals_2, primals_3, primals_4, primals_5, primals_6, primals_7, primals_8, primals_9, primals_10, primals_11, primals_12, primals_13, primals_14, primals_15, primals_16, primals_17, primals_18, primals_19, primals_20, primals_21 = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_2, (4, 4, 4, 32), (512, 128, 32, 1))
    assert_size_stride(primals_3, (32, ), (1, ))
    assert_size_stride(primals_4, (32, ), (1, ))
    assert_size_stride(primals_5, (4, 4, 4, 64), (1024, 256, 64, 1))
    assert_size_stride(primals_6, (64, ), (1, ))
    assert_size_stride(primals_7, (64, ), (1, ))
    assert_size_stride(primals_8, (128, 32), (32, 1))
    assert_size_stride(primals_9, (128, ), (1, ))
    assert_size_stride(primals_10, (128, 32), (32, 1))
    assert_size_stride(primals_11, (128, ), (1, ))
    assert_size_stride(primals_12, (64, 64), (64, 1))
    assert_size_stride(primals_13, (64, ), (1, ))
    assert_size_stride(primals_14, (64, 64), (64, 1))
    assert_size_stride(primals_15, (64, ), (1, ))
    assert_size_stride(primals_16, (64, ), (1, ))
    assert_size_stride(primals_17, (64, ), (1, ))
    assert_size_stride(primals_18, (256, 64), (64, 1))
    assert_size_stride(primals_19, (256, ), (1, ))
    assert_size_stride(primals_20, (64, 256), (256, 1))
    assert_size_stride(primals_21, (64, ), (1, ))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        # Topologically Sorted Source Nodes: [dist], Original ATen: [aten._cdist_forward]
        buf0 = torch.ops.aten._cdist_forward.default(reinterpret_tensor(primals_1, (4, 4, 4), (64, 16, 1), 4), reinterpret_tensor(primals_1, (4, 4, 4), (64, 16, 1), 4), 2.0, None)
        del primals_1
        buf1 = buf0
        del buf0
        buf23 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        # Topologically Sorted Source Nodes: [mask_s, lt], Original ATen: [aten.stack, aten.lt]
        stream0 = get_raw_stream(0)
        triton_poi_fused_lt_stack_0.run(buf1, buf23, 256, grid=grid(256), stream=stream0)
        buf3 = reinterpret_tensor(buf1, (4, 4, 4, 1), (16, 4, 1, 64), 0); del buf1  # reuse
        buf6 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        buf4 = reinterpret_tensor(buf3, (4, 4, 4, 1), (16, 4, 1, 1), 0); del buf3  # reuse
        buf8 = reinterpret_tensor(buf6, (4, 4, 4, 1), (16, 4, 1, 1), 0); del buf6  # reuse
        buf15 = empty_strided_cuda((4, 4, 4, 32), (512, 128, 32, 1), torch.float32)
        # Topologically Sorted Source Nodes: [mean, var, add, std, sub_8, x, x_1, x_2], Original ATen: [aten.mean, aten.var, aten.add, aten.sqrt, aten.sub, aten.mul, aten.div]
        triton_per_fused_add_div_mean_mul_sqrt_sub_var_1.run(buf4, buf8, primals_2, primals_3, primals_4, buf15, 64, 32, grid=grid(64), stream=stream0)
        del primals_3
        del primals_4
        buf9 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        buf12 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        buf10 = reinterpret_tensor(buf9, (4, 4, 4, 1), (16, 4, 1, 1), 0); del buf9  # reuse
        buf14 = reinterpret_tensor(buf12, (4, 4, 4, 1), (16, 4, 1, 1), 0); del buf12  # reuse
        buf18 = empty_strided_cuda((4, 4, 4, 64), (1024, 256, 64, 1), torch.float32)
        # Topologically Sorted Source Nodes: [mean_2, var_1, add_1, std_1, sub_9, x_3, x_4, x_5], Original ATen: [aten.mean, aten.var, aten.add, aten.sqrt, aten.sub, aten.mul, aten.div]
        triton_per_fused_add_div_mean_mul_sqrt_sub_var_2.run(buf10, buf14, primals_5, primals_6, primals_7, buf18, 64, 64, grid=grid(64), stream=stream0)
        del primals_6
        del primals_7
        buf16 = empty_strided_cuda((64, 128), (128, 1), torch.float32)
        # Topologically Sorted Source Nodes: [], Original ATen: []
        extern_kernels.mm(reinterpret_tensor(buf15, (64, 32), (32, 1), 0), reinterpret_tensor(primals_8, (32, 128), (1, 32), 0), out=buf16)
        buf17 = empty_strided_cuda((64, 128), (128, 1), torch.float32)
        # Topologically Sorted Source Nodes: [], Original ATen: []
        extern_kernels.mm(reinterpret_tensor(buf15, (64, 32), (32, 1), 0), reinterpret_tensor(primals_10, (32, 128), (1, 32), 0), out=buf17)
        buf19 = empty_strided_cuda((64, 64), (64, 1), torch.float32)
        # Topologically Sorted Source Nodes: [], Original ATen: []
        extern_kernels.mm(reinterpret_tensor(buf18, (64, 64), (64, 1), 0), reinterpret_tensor(primals_12, (64, 64), (1, 64), 0), out=buf19)
        buf20 = empty_strided_cuda((4, 4, 4, 128), (2048, 512, 128, 1), torch.float32)
        # Topologically Sorted Source Nodes: [q_1, attention], Original ATen: [aten.mul, aten.clone]
        triton_poi_fused_clone_mul_3.run(buf16, primals_9, buf20, 8192, grid=grid(8192), stream=stream0)
        del primals_9
        buf21 = reinterpret_tensor(buf16, (4, 4, 128, 4), (2048, 512, 4, 1), 0); del buf16  # reuse
        # Topologically Sorted Source Nodes: [attention], Original ATen: [aten.clone]
        triton_poi_fused_clone_4.run(buf17, primals_11, buf21, 2048, 4, grid=grid(2048, 4), stream=stream0)
        del buf17
        del primals_11
        buf22 = empty_strided_cuda((16, 4, 4), (16, 4, 1), torch.float32)
        # Topologically Sorted Source Nodes: [attention], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf20, (16, 4, 128), (512, 128, 1), 0), reinterpret_tensor(buf21, (16, 128, 4), (512, 4, 1), 0), out=buf22)
        buf24 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        buf25 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        # Topologically Sorted Source Nodes: [attention_1, attention_2], Original ATen: [aten.masked_fill, aten._softmax]
        triton_poi_fused__softmax_masked_fill_5.run(buf23, buf22, buf24, buf25, 64, grid=grid(64), stream=stream0)
        buf26 = reinterpret_tensor(buf22, (4, 4, 4, 4), (64, 16, 4, 1), 0); del buf22  # reuse
        # Topologically Sorted Source Nodes: [attention_1, attention_2], Original ATen: [aten.masked_fill, aten._softmax]
        triton_poi_fused__softmax_masked_fill_6.run(buf26, buf23, buf24, buf25, 256, grid=grid(256), stream=stream0)
        buf27 = empty_strided_cuda((4, 4, 4, 4, 16, 1), (1024, 256, 64, 16, 1, 1), torch.float32)
        # Topologically Sorted Source Nodes: [out], Original ATen: [aten.clone]
        triton_poi_fused_clone_7.run(buf19, primals_13, buf27, 4096, grid=grid(4096), stream=stream0)
        del primals_13
        buf28 = reinterpret_tensor(buf19, (16, 4, 64), (256, 64, 1), 0); del buf19  # reuse
        # Topologically Sorted Source Nodes: [out], Original ATen: [aten.bmm]
        extern_kernels.bmm(reinterpret_tensor(buf26, (16, 4, 4), (16, 4, 1), 0), reinterpret_tensor(buf27, (16, 4, 64), (256, 64, 1), 0), out=buf28)
        buf29 = empty_strided_cuda((4, 4, 4, 4, 16), (1024, 256, 64, 16, 1), torch.float32)
        # Topologically Sorted Source Nodes: [contiguous], Original ATen: [aten.clone]
        triton_poi_fused_clone_8.run(buf28, buf29, 4096, grid=grid(4096), stream=stream0)
        buf30 = reinterpret_tensor(buf28, (64, 64), (64, 1), 0); del buf28  # reuse
        # Topologically Sorted Source Nodes: [out_2], Original ATen: [aten.addmm]
        extern_kernels.addmm(primals_15, reinterpret_tensor(buf29, (64, 64), (64, 1), 0), reinterpret_tensor(primals_14, (64, 64), (1, 64), 0), alpha=1, beta=1, out=buf30)
        del primals_15
        buf31 = buf25; del buf25  # reuse
        buf34 = buf24; del buf24  # reuse
        buf32 = reinterpret_tensor(buf31, (4, 4, 4, 1), (16, 4, 1, 1), 0); del buf31  # reuse
        buf36 = reinterpret_tensor(buf34, (4, 4, 4, 1), (16, 4, 1, 1), 0); del buf34  # reuse
        buf37 = empty_strided_cuda((4, 4, 4, 64), (1024, 256, 64, 1), torch.float32)
        # Topologically Sorted Source Nodes: [msa, mean_4, var_2, add_3, std_2, sub_10, x_6, x_7, x_8], Original ATen: [aten.add, aten.mean, aten.var, aten.sqrt, aten.sub, aten.mul, aten.div]
        triton_per_fused_add_div_mean_mul_sqrt_sub_var_9.run(buf32, buf36, primals_5, buf30, primals_16, primals_17, buf37, 64, 64, grid=grid(64), stream=stream0)
        del primals_17
        buf38 = empty_strided_cuda((64, 256), (256, 1), torch.float32)
        # Topologically Sorted Source Nodes: [], Original ATen: []
        extern_kernels.mm(reinterpret_tensor(buf37, (64, 64), (64, 1), 0), reinterpret_tensor(primals_18, (64, 256), (1, 64), 0), out=buf38)
        buf39 = reinterpret_tensor(buf38, (4, 4, 4, 256), (4096, 1024, 256, 1), 0); del buf38  # reuse
        buf43 = empty_strided_cuda((4, 4, 4, 256), (4096, 1024, 256, 1), torch.bool)
        # Topologically Sorted Source Nodes: [relu_], Original ATen: [aten.relu, aten.threshold_backward]
        triton_poi_fused_relu_threshold_backward_10.run(buf39, primals_19, buf43, 16384, grid=grid(16384), stream=stream0)
        del primals_19
        buf40 = empty_strided_cuda((64, 256), (256, 1), torch.float32)
        # Topologically Sorted Source Nodes: [src], Original ATen: [aten.view]
        triton_poi_fused_view_11.run(buf39, buf40, 16384, grid=grid(16384), stream=stream0)
        del buf39
        buf41 = empty_strided_cuda((64, 64), (64, 1), torch.float32)
        # Topologically Sorted Source Nodes: [], Original ATen: []
        extern_kernels.mm(buf40, reinterpret_tensor(primals_20, (256, 64), (1, 256), 0), out=buf41)
        buf42 = reinterpret_tensor(buf41, (4, 4, 4, 64), (1024, 256, 64, 1), 0); del buf41  # reuse
        # Topologically Sorted Source Nodes: [msa, msa_1], Original ATen: [aten.add]
        triton_poi_fused_add_12.run(buf42, primals_5, buf30, primals_21, 4096, grid=grid(4096), stream=stream0)
        del primals_21
    return (buf42, primals_2, primals_5, primals_16, buf4, buf8, buf10, buf14, reinterpret_tensor(buf15, (64, 32), (32, 1), 0), reinterpret_tensor(buf18, (64, 64), (64, 1), 0), buf23, buf26, reinterpret_tensor(buf29, (64, 64), (64, 1), 0), buf30, buf32, buf36, reinterpret_tensor(buf37, (64, 64), (64, 1), 0), buf40, primals_20, buf43, primals_18, primals_14, reinterpret_tensor(buf27, (16, 64, 4), (256, 1, 64), 0), reinterpret_tensor(buf20, (16, 128, 4), (512, 1, 128), 0), reinterpret_tensor(buf21, (16, 4, 128), (512, 1, 4), 0), primals_12, primals_10, primals_8, )


def benchmark_compiled_module(times=10, repeat=10):
    from torch._dynamo.testing import rand_strided
    from torch._inductor.utils import print_performance
    primals_1 = rand_strided((4, 4, 4, 4), (64, 16, 4, 1), device='cuda:0', dtype=torch.float32)
    primals_2 = rand_strided((4, 4, 4, 32), (512, 128, 32, 1), device='cuda:0', dtype=torch.float32)
    primals_3 = rand_strided((32, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_4 = rand_strided((32, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_5 = rand_strided((4, 4, 4, 64), (1024, 256, 64, 1), device='cuda:0', dtype=torch.float32)
    primals_6 = rand_strided((64, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_7 = rand_strided((64, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_8 = rand_strided((128, 32), (32, 1), device='cuda:0', dtype=torch.float32)
    primals_9 = rand_strided((128, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_10 = rand_strided((128, 32), (32, 1), device='cuda:0', dtype=torch.float32)
    primals_11 = rand_strided((128, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_12 = rand_strided((64, 64), (64, 1), device='cuda:0', dtype=torch.float32)
    primals_13 = rand_strided((64, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_14 = rand_strided((64, 64), (64, 1), device='cuda:0', dtype=torch.float32)
    primals_15 = rand_strided((64, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_16 = rand_strided((64, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_17 = rand_strided((64, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_18 = rand_strided((256, 64), (64, 1), device='cuda:0', dtype=torch.float32)
    primals_19 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
    primals_20 = rand_strided((64, 256), (256, 1), device='cuda:0', dtype=torch.float32)
    primals_21 = rand_strided((64, ), (1, ), device='cuda:0', dtype=torch.float32)
    fn = lambda: call([primals_1, primals_2, primals_3, primals_4, primals_5, primals_6, primals_7, primals_8, primals_9, primals_10, primals_11, primals_12, primals_13, primals_14, primals_15, primals_16, primals_17, primals_18, primals_19, primals_20, primals_21])
    return print_performance(fn, times=times, repeat=repeat)


if __name__ == "__main__":
    from torch._inductor.wrapper_benchmark import compiled_module_main
    compiled_module_main('None', benchmark_compiled_module)

import math
import torch
import torch.nn as nn
import torch.nn.functional as F


class LayerNorm(nn.Module):

    def __init__(self, d_model, eps=1e-05):
        super(LayerNorm, self).__init__()
        self.a_2 = nn.Parameter(torch.ones(d_model))
        self.b_2 = nn.Parameter(torch.zeros(d_model))
        self.eps = eps

    def forward(self, x):
        mean = x.mean(-1, keepdim=True)
        std = torch.sqrt(x.var(dim=-1, keepdim=True, unbiased=False) + self.eps
            )
        x = self.a_2 * (x - mean)
        x /= std
        x += self.b_2
        return x


class FeedForwardLayer(nn.Module):

    def __init__(self, d_model, d_ff, p_drop=0.1):
        super(FeedForwardLayer, self).__init__()
        self.linear1 = nn.Linear(d_model, d_ff)
        self.dropout = nn.Dropout(p_drop, inplace=True)
        self.linear2 = nn.Linear(d_ff, d_model)

    def forward(self, src):
        src = self.linear2(self.dropout(F.relu_(self.linear1(src))))
        return src


class MaskedDirectMultiheadAttention(nn.Module):

    def __init__(self, d_in, d_out, heads, d_k=32, dropout=0.1):
        super(MaskedDirectMultiheadAttention, self).__init__()
        self.heads = heads
        self.scaling = 1 / math.sqrt(d_k)
        self.to_query = nn.Linear(d_in, heads * d_k)
        self.to_key = nn.Linear(d_in, heads * d_k)
        self.to_value = nn.Linear(d_out, d_out)
        self.to_out = nn.Linear(d_out, d_out)
        self.dropout = nn.Dropout(dropout, inplace=True)

    def forward(self, query, key, value, mask):
        batch, N, L = value.shape[:3]
        q = self.to_query(query).view(batch, L, self.heads, -1).permute(0, 
            2, 1, 3)
        k = self.to_key(key).view(batch, L, self.heads, -1).permute(0, 2, 1, 3)
        v = self.to_value(value).view(batch, N, L, self.heads, -1).permute(
            0, 3, 1, 2, 4)
        q = q * self.scaling
        attention = torch.matmul(q, k.transpose(-2, -1))
        attention = attention.masked_fill(mask < 0.5, torch.finfo(q.dtype).min)
        attention = F.softmax(attention, dim=-1)
        attention = self.dropout(attention)
        out = torch.einsum('bhij,bhnjk->bhnik', attention, v)
        out = out.permute(0, 2, 3, 1, 4).contiguous().view(batch, N, L, -1)
        out = self.to_out(out)
        return out


class Str2MSA(nn.Module):

    def __init__(self, d_msa=64, d_state=32, inner_dim=32, r_ff=4, distbin=
        [8.0, 12.0, 16.0, 20.0], p_drop=0.1):
        super(Str2MSA, self).__init__()
        self.distbin = distbin
        n_att_head = len(distbin)
        self.norm_state = LayerNorm(d_state)
        self.norm1 = LayerNorm(d_msa)
        self.attn = MaskedDirectMultiheadAttention(d_state, d_msa,
            n_att_head, d_k=inner_dim, dropout=p_drop)
        self.dropout1 = nn.Dropout(p_drop, inplace=True)
        self.norm2 = LayerNorm(d_msa)
        self.ff = FeedForwardLayer(d_msa, d_msa * r_ff, p_drop=p_drop)
        self.dropout2 = nn.Dropout(p_drop, inplace=True)

    def forward(self, msa, xyz, state):
        dist = torch.cdist(xyz[:, :, 1], xyz[:, :, 1])
        mask_s = list()
        for distbin in self.distbin:
            mask_s.append(1.0 - torch.sigmoid(dist - distbin))
        mask_s = torch.stack(mask_s, dim=1)
        state = self.norm_state(state)
        msa2 = self.norm1(msa)
        msa2 = self.attn(state, state, msa2, mask_s)
        msa = msa + self.dropout1(msa2)
        msa2 = self.norm2(msa)
        msa2 = self.ff(msa2)
        msa = msa + self.dropout2(msa2)
        return msa


def get_inputs():
    return [torch.rand([4, 4, 4, 64]), torch.rand([4, 4, 4, 4]), torch.rand
        ([4, 4, 4, 32])]


def get_init_inputs():
    return [[], {}]

import torch
from torch._inductor.select_algorithm import extern_kernels
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
from torch._inductor.runtime import triton_helpers
from torch._inductor.runtime.triton_helpers import libdevice, math as tl_math
import math
import torch.nn as nn
import torch.nn.functional as F
assert_size_stride = torch._C._dynamo.guards.assert_size_stride
empty_strided_cuda = torch._C._dynamo.guards._empty_strided_cuda
reinterpret_tensor = torch._C._dynamo.guards._reinterpret_tensor


@triton.jit
def triton_poi_fused_lt_stack_0(in_ptr0, out_ptr1, xnumel, XBLOCK: tl.constexpr
    ):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x1 = xindex // 4 % 16
    x0 = xindex % 4
    x2 = xindex // 64
    x3 = xindex
    tmp0 = x1
    tl.full([1], 0, tl.int64)
    tmp3 = tl.full([1], 4, tl.int64)
    tmp4 = tmp0 < tmp3
    tmp5 = tl.load(in_ptr0 + (x0 + 4 * x1 + 16 * x2), tmp4 & xmask, other=0.0)
    tmp6 = 8.0
    tmp7 = tmp5 - tmp6
    tmp8 = tl.sigmoid(tmp7)
    tmp9 = 1.0
    tmp10 = tmp9 - tmp8
    tmp11 = tl.full(tmp10.shape, 0.0, tmp10.dtype)
    tmp12 = tl.where(tmp4, tmp10, tmp11)
    tmp13 = tmp0 >= tmp3
    tmp14 = tl.full([1], 8, tl.int64)
    tmp15 = tmp0 < tmp14
    tmp16 = tmp13 & tmp15
    tmp17 = tl.load(in_ptr0 + (x0 + 4 * (-4 + x1) + 16 * x2), tmp16 & xmask,
        other=0.0)
    tmp18 = 12.0
    tmp19 = tmp17 - tmp18
    tmp20 = tl.sigmoid(tmp19)
    tmp21 = tmp9 - tmp20
    tmp22 = tl.full(tmp21.shape, 0.0, tmp21.dtype)
    tmp23 = tl.where(tmp16, tmp21, tmp22)
    tmp24 = tmp0 >= tmp14
    tmp25 = tl.full([1], 12, tl.int64)
    tmp26 = tmp0 < tmp25
    tmp27 = tmp24 & tmp26
    tmp28 = tl.load(in_ptr0 + (x0 + 4 * (-8 + x1) + 16 * x2), tmp27 & xmask,
        other=0.0)
    tmp29 = 16.0
    tmp30 = tmp28 - tmp29
    tmp31 = tl.sigmoid(tmp30)
    tmp32 = tmp9 - tmp31
    tmp33 = tl.full(tmp32.shape, 0.0, tmp32.dtype)
    tmp34 = tl.where(tmp27, tmp32, tmp33)
    tmp35 = tmp0 >= tmp25
    tl.full([1], 16, tl.int64)
    tmp38 = tl.load(in_ptr0 + (x0 + 4 * (-12 + x1) + 16 * x2), tmp35 &
        xmask, other=0.0)
    tmp39 = 20.0
    tmp40 = tmp38 - tmp39
    tmp41 = tl.sigmoid(tmp40)
    tmp42 = tmp9 - tmp41
    tmp43 = tl.full(tmp42.shape, 0.0, tmp42.dtype)
    tmp44 = tl.where(tmp35, tmp42, tmp43)
    tmp45 = tl.where(tmp27, tmp34, tmp44)
    tmp46 = tl.where(tmp16, tmp23, tmp45)
    tmp47 = tl.where(tmp4, tmp12, tmp46)
    tmp48 = 0.5
    tmp49 = tmp47 < tmp48
    tl.store(out_ptr1 + x3, tmp49, xmask)


@triton.jit
def triton_per_fused_add_div_mean_mul_sqrt_sub_var_1(in_out_ptr0,
    in_out_ptr1, in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, rnumel,
    XBLOCK: tl.constexpr):
    xnumel = 64
    RBLOCK: tl.constexpr = 32
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + 32 * x0), xmask, other=0.0)
    tmp25 = tl.load(in_ptr1 + r1, None, eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr2 + r1, None, eviction_policy='evict_last')
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.where(xmask, tmp1, 0)
    tmp4 = tl.sum(tmp3, 1)[:, None]
    tmp6 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
    tmp8 = tl.where(xmask, tmp6, 0)
    tmp9 = tl.sum(tmp8, 1)[:, None]
    tmp10 = tl.full([XBLOCK, 1], 32, tl.int32)
    tmp11 = tmp10.to(tl.float32)
    tmp12 = tmp9 / tmp11
    tmp13 = tmp1 - tmp12
    tmp14 = tmp13 * tmp13
    tmp15 = tl.broadcast_to(tmp14, [XBLOCK, RBLOCK])
    tmp17 = tl.where(xmask, tmp15, 0)
    tmp18 = tl.sum(tmp17, 1)[:, None]
    tmp19 = 32.0
    tmp20 = tmp4 / tmp19
    tmp21 = tmp18 / tmp19
    tmp22 = 1e-05
    tmp23 = tmp21 + tmp22
    tmp24 = libdevice.sqrt(tmp23)
    tmp26 = tmp0 - tmp20
    tmp27 = tmp25 * tmp26
    tmp28 = tmp27 / tmp24
    tmp30 = tmp28 + tmp29
    tl.debug_barrier()
    tl.store(in_out_ptr0 + x0, tmp20, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + x0, tmp24, xmask)
    tl.store(out_ptr0 + (r1 + 32 * x0), tmp30, xmask)


@triton.jit
def triton_per_fused_add_div_mean_mul_sqrt_sub_var_2(in_out_ptr0,
    in_out_ptr1, in_ptr0, in_ptr1, in_ptr2, out_ptr0, xnumel, rnumel,
    XBLOCK: tl.constexpr):
    xnumel = 64
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + 64 * x0), xmask, other=0.0)
    tmp25 = tl.load(in_ptr1 + r1, None, eviction_policy='evict_last')
    tmp29 = tl.load(in_ptr2 + r1, None, eviction_policy='evict_last')
    tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
    tmp3 = tl.where(xmask, tmp1, 0)
    tmp4 = tl.sum(tmp3, 1)[:, None]
    tmp6 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
    tmp8 = tl.where(xmask, tmp6, 0)
    tmp9 = tl.sum(tmp8, 1)[:, None]
    tmp10 = tl.full([XBLOCK, 1], 64, tl.int32)
    tmp11 = tmp10.to(tl.float32)
    tmp12 = tmp9 / tmp11
    tmp13 = tmp1 - tmp12
    tmp14 = tmp13 * tmp13
    tmp15 = tl.broadcast_to(tmp14, [XBLOCK, RBLOCK])
    tmp17 = tl.where(xmask, tmp15, 0)
    tmp18 = tl.sum(tmp17, 1)[:, None]
    tmp19 = 64.0
    tmp20 = tmp4 / tmp19
    tmp21 = tmp18 / tmp19
    tmp22 = 1e-05
    tmp23 = tmp21 + tmp22
    tmp24 = libdevice.sqrt(tmp23)
    tmp26 = tmp0 - tmp20
    tmp27 = tmp25 * tmp26
    tmp28 = tmp27 / tmp24
    tmp30 = tmp28 + tmp29
    tl.debug_barrier()
    tl.store(in_out_ptr0 + x0, tmp20, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + x0, tmp24, xmask)
    tl.store(out_ptr0 + (r1 + 64 * x0), tmp30, xmask)


@triton.jit
def triton_poi_fused_clone_mul_3(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK:
    tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 128
    x1 = xindex // 128 % 4
    x2 = xindex // 512 % 4
    x3 = xindex // 2048
    x4 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 128 * x2 + 512 * x1 + 2048 * x3), None)
    tmp1 = tl.load(in_ptr1 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = 0.17677669529663687
    tmp4 = tmp2 * tmp3
    tl.store(out_ptr0 + x4, tmp4, None)


@triton.jit
def triton_poi_fused_clone_4(in_ptr0, in_ptr1, out_ptr0, ynumel, xnumel,
    YBLOCK: tl.constexpr, XBLOCK: tl.constexpr):
    xnumel = 4
    yoffset = tl.program_id(1) * YBLOCK
    yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
    tl.full([XBLOCK, YBLOCK], True, tl.int1)
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    x3 = xindex
    y2 = yindex // 512
    y4 = yindex % 512
    y0 = yindex % 128
    y5 = yindex
    tmp0 = tl.load(in_ptr0 + (y4 + 512 * x3 + 2048 * y2), xmask,
        eviction_policy='evict_last')
    tmp1 = tl.load(in_ptr1 + y0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tl.store(out_ptr0 + (x3 + 4 * y5), tmp2, xmask)


@triton.jit
def triton_poi_fused__softmax_masked_fill_5(in_ptr0, in_ptr1, out_ptr0,
    out_ptr1, xnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + 4 * x0, xmask, eviction_policy='evict_last').to(tl
        .int1)
    tmp1 = tl.load(in_ptr1 + 4 * x0, xmask, eviction_policy='evict_last')
    tmp4 = tl.load(in_ptr0 + (1 + 4 * x0), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp5 = tl.load(in_ptr1 + (1 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp8 = tl.load(in_ptr0 + (2 + 4 * x0), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp9 = tl.load(in_ptr1 + (2 + 4 * x0), xmask, eviction_policy='evict_last')
    tmp12 = tl.load(in_ptr0 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        ).to(tl.int1)
    tmp13 = tl.load(in_ptr1 + (3 + 4 * x0), xmask, eviction_policy='evict_last'
        )
    tmp2 = -3.4028234663852886e+38
    tmp3 = tl.where(tmp0, tmp2, tmp1)
    tmp6 = tl.where(tmp4, tmp2, tmp5)
    tmp7 = triton_helpers.maximum(tmp3, tmp6)
    tmp10 = tl.where(tmp8, tmp2, tmp9)
    tmp11 = triton_helpers.maximum(tmp7, tmp10)
    tmp14 = tl.where(tmp12, tmp2, tmp13)
    tmp15 = triton_helpers.maximum(tmp11, tmp14)
    tmp16 = tmp3 - tmp15
    tmp17 = tl_math.exp(tmp16)
    tmp18 = tmp6 - tmp15
    tmp19 = tl_math.exp(tmp18)
    tmp20 = tmp17 + tmp19
    tmp21 = tmp10 - tmp15
    tmp22 = tl_math.exp(tmp21)
    tmp23 = tmp20 + tmp22
    tmp24 = tmp14 - tmp15
    tmp25 = tl_math.exp(tmp24)
    tmp26 = tmp23 + tmp25
    tl.store(out_ptr0 + x0, tmp15, xmask)
    tl.store(out_ptr1 + x0, tmp26, xmask)


@triton.jit
def triton_poi_fused__softmax_masked_fill_6(in_out_ptr0, in_ptr0, in_ptr1,
    in_ptr2, xnumel, XBLOCK: tl.constexpr):
    xnumel = 256
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    xmask = xindex < xnumel
    x2 = xindex
    x1 = xindex // 4
    tmp0 = tl.load(in_ptr0 + x2, xmask).to(tl.int1)
    tmp1 = tl.load(in_out_ptr0 + x2, xmask)
    tmp4 = tl.load(in_ptr1 + x1, xmask, eviction_policy='evict_last')
    tmp7 = tl.load(in_ptr2 + x1, xmask, eviction_policy='evict_last')
    tmp2 = -3.4028234663852886e+38
    tmp3 = tl.where(tmp0, tmp2, tmp1)
    tmp5 = tmp3 - tmp4
    tmp6 = tl_math.exp(tmp5)
    tmp8 = tmp6 / tmp7
    tl.store(in_out_ptr0 + x2, tmp8, xmask)


@triton.jit
def triton_poi_fused_clone_7(in_ptr0, in_ptr1, out_ptr0, xnumel, XBLOCK: tl
    .constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 16
    x1 = xindex // 16 % 4
    x2 = xindex // 64 % 4
    x3 = xindex // 256 % 4
    x4 = xindex // 1024
    x6 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 16 * x3 + 64 * x2 + 256 * x1 + 1024 * x4
        ), None)
    tmp1 = tl.load(in_ptr1 + (x0 + 16 * x3), None, eviction_policy='evict_last'
        )
    tmp2 = tmp0 + tmp1
    tl.store(out_ptr0 + x6, tmp2, None)


@triton.jit
def triton_poi_fused_clone_8(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 16
    x1 = xindex // 16 % 4
    x2 = xindex // 64 % 4
    x3 = xindex // 256 % 4
    x4 = xindex // 1024
    x5 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 16 * x3 + 64 * x2 + 256 * x1 + 1024 * x4
        ), None)
    tl.store(out_ptr0 + x5, tmp0, None)


@triton.jit
def triton_per_fused_add_div_mean_mul_sqrt_sub_var_9(in_out_ptr0,
    in_out_ptr1, in_ptr0, in_ptr1, in_ptr2, in_ptr3, out_ptr0, xnumel,
    rnumel, XBLOCK: tl.constexpr):
    xnumel = 64
    RBLOCK: tl.constexpr = 64
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
    xmask = xindex < xnumel
    rindex = tl.arange(0, RBLOCK)[None, :]
    tl.full([XBLOCK, RBLOCK], True, tl.int1)
    r1 = rindex
    x0 = xindex
    tmp0 = tl.load(in_ptr0 + (r1 + 64 * x0), xmask, other=0.0)
    tmp1 = tl.load(in_ptr1 + (r1 + 64 * x0), xmask, other=0.0)
    tmp27 = tl.load(in_ptr2 + r1, None, eviction_policy='evict_last')
    tmp31 = tl.load(in_ptr3 + r1, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.broadcast_to(tmp2, [XBLOCK, RBLOCK])
    tmp5 = tl.where(xmask, tmp3, 0)
    tmp6 = tl.sum(tmp5, 1)[:, None]
    tmp8 = tl.broadcast_to(tmp3, [XBLOCK, RBLOCK])
    tmp10 = tl.where(xmask, tmp8, 0)
    tmp11 = tl.sum(tmp10, 1)[:, None]
    tmp12 = tl.full([XBLOCK, 1], 64, tl.int32)
    tmp13 = tmp12.to(tl.float32)
    tmp14 = tmp11 / tmp13
    tmp15 = tmp3 - tmp14
    tmp16 = tmp15 * tmp15
    tmp17 = tl.broadcast_to(tmp16, [XBLOCK, RBLOCK])
    tmp19 = tl.where(xmask, tmp17, 0)
    tmp20 = tl.sum(tmp19, 1)[:, None]
    tmp21 = 64.0
    tmp22 = tmp6 / tmp21
    tmp23 = tmp20 / tmp21
    tmp24 = 1e-05
    tmp25 = tmp23 + tmp24
    tmp26 = libdevice.sqrt(tmp25)
    tmp28 = tmp2 - tmp22
    tmp29 = tmp27 * tmp28
    tmp30 = tmp29 / tmp26
    tmp32 = tmp30 + tmp31
    tl.debug_barrier()
    tl.store(in_out_ptr0 + x0, tmp22, xmask)
    tl.debug_barrier()
    tl.store(in_out_ptr1 + x0, tmp26, xmask)
    tl.store(out_ptr0 + (r1 + 64 * x0), tmp32, xmask)


@triton.jit
def triton_poi_fused_relu_threshold_backward_10(in_out_ptr0, in_ptr0,
    out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x4 = xindex
    x0 = xindex % 256
    tmp0 = tl.load(in_out_ptr0 + x4, None)
    tmp1 = tl.load(in_ptr0 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp3 = tl.full([1], 0, tl.int32)
    tmp4 = triton_helpers.maximum(tmp3, tmp2)
    tmp5 = 0.0
    tmp6 = tmp4 <= tmp5
    tl.store(in_out_ptr0 + x4, tmp4, None)
    tl.store(out_ptr0 + x4, tmp6, None)


@triton.jit
def triton_poi_fused_view_11(in_ptr0, out_ptr0, xnumel, XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x0 = xindex % 256
    x1 = xindex // 256
    x2 = xindex
    tmp0 = tl.load(in_ptr0 + (x0 + 256 * x1 + 1024 * (x1 % 4 // 4) + 4096 *
        ((4 * (x1 // 4 % 4) + x1 % 4) // 16)), None)
    tl.store(out_ptr0 + x2, tmp0, None)


@triton.jit
def triton_poi_fused_add_12(in_out_ptr0, in_ptr0, in_ptr1, in_ptr2, xnumel,
    XBLOCK: tl.constexpr):
    xoffset = tl.program_id(0) * XBLOCK
    xindex = xoffset + tl.arange(0, XBLOCK)[:]
    tl.full([XBLOCK], True, tl.int1)
    x2 = xindex
    x0 = xindex % 64
    tmp0 = tl.load(in_ptr0 + x2, None)
    tmp1 = tl.load(in_ptr1 + x2, None)
    tmp3 = tl.load(in_out_ptr0 + x2, None)
    tmp4 = tl.load(in_ptr2 + x0, None, eviction_policy='evict_last')
    tmp2 = tmp0 + tmp1
    tmp5 = tmp3 + tmp4
    tmp6 = tmp2 + tmp5
    tl.store(in_out_ptr0 + x2, tmp6, None)


def call(args):
    (primals_1, primals_2, primals_3, primals_4, primals_5, primals_6,
        primals_7, primals_8, primals_9, primals_10, primals_11, primals_12,
        primals_13, primals_14, primals_15, primals_16, primals_17,
        primals_18, primals_19, primals_20, primals_21) = args
    args.clear()
    assert_size_stride(primals_1, (4, 4, 4, 4), (64, 16, 4, 1))
    assert_size_stride(primals_2, (4, 4, 4, 32), (512, 128, 32, 1))
    assert_size_stride(primals_3, (32,), (1,))
    assert_size_stride(primals_4, (32,), (1,))
    assert_size_stride(primals_5, (4, 4, 4, 64), (1024, 256, 64, 1))
    assert_size_stride(primals_6, (64,), (1,))
    assert_size_stride(primals_7, (64,), (1,))
    assert_size_stride(primals_8, (128, 32), (32, 1))
    assert_size_stride(primals_9, (128,), (1,))
    assert_size_stride(primals_10, (128, 32), (32, 1))
    assert_size_stride(primals_11, (128,), (1,))
    assert_size_stride(primals_12, (64, 64), (64, 1))
    assert_size_stride(primals_13, (64,), (1,))
    assert_size_stride(primals_14, (64, 64), (64, 1))
    assert_size_stride(primals_15, (64,), (1,))
    assert_size_stride(primals_16, (64,), (1,))
    assert_size_stride(primals_17, (64,), (1,))
    assert_size_stride(primals_18, (256, 64), (64, 1))
    assert_size_stride(primals_19, (256,), (1,))
    assert_size_stride(primals_20, (64, 256), (256, 1))
    assert_size_stride(primals_21, (64,), (1,))
    with torch.cuda._DeviceGuard(0):
        torch.cuda.set_device(0)
        buf0 = torch.ops.aten._cdist_forward.default(reinterpret_tensor(
            primals_1, (4, 4, 4), (64, 16, 1), 4), reinterpret_tensor(
            primals_1, (4, 4, 4), (64, 16, 1), 4), 2.0, None)
        del primals_1
        buf1 = buf0
        del buf0
        buf23 = empty_strided_cuda((4, 4, 4, 4), (64, 16, 4, 1), torch.bool)
        get_raw_stream(0)
        triton_poi_fused_lt_stack_0[grid(256)](buf1, buf23, 256, XBLOCK=256,
            num_warps=4, num_stages=1)
        buf3 = reinterpret_tensor(buf1, (4, 4, 4, 1), (16, 4, 1, 64), 0)
        del buf1
        buf6 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        buf4 = reinterpret_tensor(buf3, (4, 4, 4, 1), (16, 4, 1, 1), 0)
        del buf3
        buf8 = reinterpret_tensor(buf6, (4, 4, 4, 1), (16, 4, 1, 1), 0)
        del buf6
        buf15 = empty_strided_cuda((4, 4, 4, 32), (512, 128, 32, 1), torch.
            float32)
        triton_per_fused_add_div_mean_mul_sqrt_sub_var_1[grid(64)](buf4,
            buf8, primals_2, primals_3, primals_4, buf15, 64, 32, XBLOCK=8,
            num_warps=2, num_stages=1)
        del primals_3
        del primals_4
        buf9 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        buf12 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        buf10 = reinterpret_tensor(buf9, (4, 4, 4, 1), (16, 4, 1, 1), 0)
        del buf9
        buf14 = reinterpret_tensor(buf12, (4, 4, 4, 1), (16, 4, 1, 1), 0)
        del buf12
        buf18 = empty_strided_cuda((4, 4, 4, 64), (1024, 256, 64, 1), torch
            .float32)
        triton_per_fused_add_div_mean_mul_sqrt_sub_var_2[grid(64)](buf10,
            buf14, primals_5, primals_6, primals_7, buf18, 64, 64, XBLOCK=8,
            num_warps=4, num_stages=1)
        del primals_6
        del primals_7
        buf16 = empty_strided_cuda((64, 128), (128, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf15, (64, 32), (32, 1), 0),
            reinterpret_tensor(primals_8, (32, 128), (1, 32), 0), out=buf16)
        buf17 = empty_strided_cuda((64, 128), (128, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf15, (64, 32), (32, 1), 0),
            reinterpret_tensor(primals_10, (32, 128), (1, 32), 0), out=buf17)
        buf19 = empty_strided_cuda((64, 64), (64, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf18, (64, 64), (64, 1), 0),
            reinterpret_tensor(primals_12, (64, 64), (1, 64), 0), out=buf19)
        buf20 = empty_strided_cuda((4, 4, 4, 128), (2048, 512, 128, 1),
            torch.float32)
        triton_poi_fused_clone_mul_3[grid(8192)](buf16, primals_9, buf20, 
            8192, XBLOCK=128, num_warps=4, num_stages=1)
        del primals_9
        buf21 = reinterpret_tensor(buf16, (4, 4, 128, 4), (2048, 512, 4, 1), 0)
        del buf16
        triton_poi_fused_clone_4[grid(2048, 4)](buf17, primals_11, buf21, 
            2048, 4, XBLOCK=1, YBLOCK=256, num_warps=4, num_stages=1)
        del buf17
        del primals_11
        buf22 = empty_strided_cuda((16, 4, 4), (16, 4, 1), torch.float32)
        extern_kernels.bmm(reinterpret_tensor(buf20, (16, 4, 128), (512, 
            128, 1), 0), reinterpret_tensor(buf21, (16, 128, 4), (512, 4, 1
            ), 0), out=buf22)
        buf24 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        buf25 = empty_strided_cuda((4, 4, 4, 1), (16, 4, 1, 64), torch.float32)
        triton_poi_fused__softmax_masked_fill_5[grid(64)](buf23, buf22,
            buf24, buf25, 64, XBLOCK=64, num_warps=1, num_stages=1)
        buf26 = reinterpret_tensor(buf22, (4, 4, 4, 4), (64, 16, 4, 1), 0)
        del buf22
        triton_poi_fused__softmax_masked_fill_6[grid(256)](buf26, buf23,
            buf24, buf25, 256, XBLOCK=256, num_warps=4, num_stages=1)
        buf27 = empty_strided_cuda((4, 4, 4, 4, 16, 1), (1024, 256, 64, 16,
            1, 1), torch.float32)
        triton_poi_fused_clone_7[grid(4096)](buf19, primals_13, buf27, 4096,
            XBLOCK=256, num_warps=4, num_stages=1)
        del primals_13
        buf28 = reinterpret_tensor(buf19, (16, 4, 64), (256, 64, 1), 0)
        del buf19
        extern_kernels.bmm(reinterpret_tensor(buf26, (16, 4, 4), (16, 4, 1),
            0), reinterpret_tensor(buf27, (16, 4, 64), (256, 64, 1), 0),
            out=buf28)
        buf29 = empty_strided_cuda((4, 4, 4, 4, 16), (1024, 256, 64, 16, 1),
            torch.float32)
        triton_poi_fused_clone_8[grid(4096)](buf28, buf29, 4096, XBLOCK=256,
            num_warps=4, num_stages=1)
        buf30 = reinterpret_tensor(buf28, (64, 64), (64, 1), 0)
        del buf28
        extern_kernels.addmm(primals_15, reinterpret_tensor(buf29, (64, 64),
            (64, 1), 0), reinterpret_tensor(primals_14, (64, 64), (1, 64), 
            0), alpha=1, beta=1, out=buf30)
        del primals_15
        buf31 = buf25
        del buf25
        buf34 = buf24
        del buf24
        buf32 = reinterpret_tensor(buf31, (4, 4, 4, 1), (16, 4, 1, 1), 0)
        del buf31
        buf36 = reinterpret_tensor(buf34, (4, 4, 4, 1), (16, 4, 1, 1), 0)
        del buf34
        buf37 = empty_strided_cuda((4, 4, 4, 64), (1024, 256, 64, 1), torch
            .float32)
        triton_per_fused_add_div_mean_mul_sqrt_sub_var_9[grid(64)](buf32,
            buf36, primals_5, buf30, primals_16, primals_17, buf37, 64, 64,
            XBLOCK=1, num_warps=2, num_stages=1)
        del primals_17
        buf38 = empty_strided_cuda((64, 256), (256, 1), torch.float32)
        extern_kernels.mm(reinterpret_tensor(buf37, (64, 64), (64, 1), 0),
            reinterpret_tensor(primals_18, (64, 256), (1, 64), 0), out=buf38)
        buf39 = reinterpret_tensor(buf38, (4, 4, 4, 256), (4096, 1024, 256,
            1), 0)
        del buf38
        buf43 = empty_strided_cuda((4, 4, 4, 256), (4096, 1024, 256, 1),
            torch.bool)
        triton_poi_fused_relu_threshold_backward_10[grid(16384)](buf39,
            primals_19, buf43, 16384, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_19
        buf40 = empty_strided_cuda((64, 256), (256, 1), torch.float32)
        triton_poi_fused_view_11[grid(16384)](buf39, buf40, 16384, XBLOCK=
            256, num_warps=4, num_stages=1)
        del buf39
        buf41 = empty_strided_cuda((64, 64), (64, 1), torch.float32)
        extern_kernels.mm(buf40, reinterpret_tensor(primals_20, (256, 64),
            (1, 256), 0), out=buf41)
        buf42 = reinterpret_tensor(buf41, (4, 4, 4, 64), (1024, 256, 64, 1), 0)
        del buf41
        triton_poi_fused_add_12[grid(4096)](buf42, primals_5, buf30,
            primals_21, 4096, XBLOCK=256, num_warps=4, num_stages=1)
        del primals_21
    return (buf42, primals_2, primals_5, primals_16, buf4, buf8, buf10,
        buf14, reinterpret_tensor(buf15, (64, 32), (32, 1), 0),
        reinterpret_tensor(buf18, (64, 64), (64, 1), 0), buf23, buf26,
        reinterpret_tensor(buf29, (64, 64), (64, 1), 0), buf30, buf32,
        buf36, reinterpret_tensor(buf37, (64, 64), (64, 1), 0), buf40,
        primals_20, buf43, primals_18, primals_14, reinterpret_tensor(buf27,
        (16, 64, 4), (256, 1, 64), 0), reinterpret_tensor(buf20, (16, 128, 
        4), (512, 1, 128), 0), reinterpret_tensor(buf21, (16, 4, 128), (512,
        1, 4), 0), primals_12, primals_10, primals_8)


class LayerNorm(nn.Module):

    def __init__(self, d_model, eps=1e-05):
        super(LayerNorm, self).__init__()
        self.a_2 = nn.Parameter(torch.ones(d_model))
        self.b_2 = nn.Parameter(torch.zeros(d_model))
        self.eps = eps

    def forward(self, x):
        mean = x.mean(-1, keepdim=True)
        std = torch.sqrt(x.var(dim=-1, keepdim=True, unbiased=False) + self.eps
            )
        x = self.a_2 * (x - mean)
        x /= std
        x += self.b_2
        return x


class FeedForwardLayer(nn.Module):

    def __init__(self, d_model, d_ff, p_drop=0.1):
        super(FeedForwardLayer, self).__init__()
        self.linear1 = nn.Linear(d_model, d_ff)
        self.dropout = nn.Dropout(p_drop, inplace=True)
        self.linear2 = nn.Linear(d_ff, d_model)

    def forward(self, src):
        src = self.linear2(self.dropout(F.relu_(self.linear1(src))))
        return src


class MaskedDirectMultiheadAttention(nn.Module):

    def __init__(self, d_in, d_out, heads, d_k=32, dropout=0.1):
        super(MaskedDirectMultiheadAttention, self).__init__()
        self.heads = heads
        self.scaling = 1 / math.sqrt(d_k)
        self.to_query = nn.Linear(d_in, heads * d_k)
        self.to_key = nn.Linear(d_in, heads * d_k)
        self.to_value = nn.Linear(d_out, d_out)
        self.to_out = nn.Linear(d_out, d_out)
        self.dropout = nn.Dropout(dropout, inplace=True)

    def forward(self, query, key, value, mask):
        batch, N, L = value.shape[:3]
        q = self.to_query(query).view(batch, L, self.heads, -1).permute(0, 
            2, 1, 3)
        k = self.to_key(key).view(batch, L, self.heads, -1).permute(0, 2, 1, 3)
        v = self.to_value(value).view(batch, N, L, self.heads, -1).permute(
            0, 3, 1, 2, 4)
        q = q * self.scaling
        attention = torch.matmul(q, k.transpose(-2, -1))
        attention = attention.masked_fill(mask < 0.5, torch.finfo(q.dtype).min)
        attention = F.softmax(attention, dim=-1)
        attention = self.dropout(attention)
        out = torch.einsum('bhij,bhnjk->bhnik', attention, v)
        out = out.permute(0, 2, 3, 1, 4).contiguous().view(batch, N, L, -1)
        out = self.to_out(out)
        return out


class Str2MSANew(nn.Module):

    def __init__(self, d_msa=64, d_state=32, inner_dim=32, r_ff=4, distbin=
        [8.0, 12.0, 16.0, 20.0], p_drop=0.1):
        super(Str2MSANew, self).__init__()
        self.distbin = distbin
        n_att_head = len(distbin)
        self.norm_state = LayerNorm(d_state)
        self.norm1 = LayerNorm(d_msa)
        self.attn = MaskedDirectMultiheadAttention(d_state, d_msa,
            n_att_head, d_k=inner_dim, dropout=p_drop)
        self.dropout1 = nn.Dropout(p_drop, inplace=True)
        self.norm2 = LayerNorm(d_msa)
        self.ff = FeedForwardLayer(d_msa, d_msa * r_ff, p_drop=p_drop)
        self.dropout2 = nn.Dropout(p_drop, inplace=True)

    def forward(self, input_0, input_1, input_2):
        primals_3 = self.norm_state.a_2
        primals_4 = self.norm_state.b_2
        primals_6 = self.norm1.a_2
        primals_7 = self.norm1.b_2
        primals_8 = self.attn.to_query.weight
        primals_9 = self.attn.to_query.bias
        primals_10 = self.attn.to_key.weight
        primals_11 = self.attn.to_key.bias
        primals_12 = self.attn.to_value.weight
        primals_13 = self.attn.to_value.bias
        primals_14 = self.attn.to_out.weight
        primals_15 = self.attn.to_out.bias
        primals_16 = self.norm2.a_2
        primals_17 = self.norm2.b_2
        primals_18 = self.ff.linear1.weight
        primals_19 = self.ff.linear1.bias
        primals_20 = self.ff.linear2.weight
        primals_21 = self.ff.linear2.bias
        primals_5 = input_0
        primals_1 = input_1
        primals_2 = input_2
        output = call([primals_1, primals_2, primals_3, primals_4,
            primals_5, primals_6, primals_7, primals_8, primals_9,
            primals_10, primals_11, primals_12, primals_13, primals_14,
            primals_15, primals_16, primals_17, primals_18, primals_19,
            primals_20, primals_21])
        return output[0]
