# AOT ID: ['13_inference']
from ctypes import c_void_p, c_long
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
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
alloc_from_pool = torch.ops.inductor._alloc_from_pool
reinterpret_tensor = torch.ops.inductor._reinterpret_tensor
async_compile = AsyncCompile()
# kernel path: /tmp/torchinductor_root/5z/c5zuztoz7bglzssnsiel4sw3jdyjh5u4mdnzqdksggklxiojjc4p.py
# Source Nodes: [_tgt], Original ATen: [aten.native_layer_norm]
# _tgt => clone, var_mean
triton_red_fused_native_layer_norm_0 = async_compile.triton('triton_', '''
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.reduction(
size_hints=[32768, 256],
reduction_hint=ReductionHint.DEFAULT,
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: 'i32', 4: 'i32', 5: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 5), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_red_fused_native_layer_norm_0', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 2, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, out_ptr0, out_ptr1, ks0, xnumel, rnumel, XBLOCK : tl.constexpr, RBLOCK : tl.constexpr):
rnumel = 256
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
rbase = tl.arange(0, RBLOCK)[None, :]
x0 = xindex
tmp2_mean = tl.zeros([XBLOCK, RBLOCK], tl.float32)
tmp2_m2 = tl.zeros([XBLOCK, RBLOCK], tl.float32)
tmp2_weight = tl.zeros([XBLOCK, RBLOCK], tl.float32)
for roffset in range(0, rnumel, RBLOCK):
rindex = roffset + rbase
rmask = rindex < rnumel
r1 = rindex
tmp0 = tl.load(in_ptr0 + (x0 + (ks0*r1)), rmask & xmask, eviction_policy='evict_first', other=0.0)
tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
tmp2_mean_next, tmp2_m2_next, tmp2_weight_next = triton_helpers.welford_reduce(
tmp1, tmp2_mean, tmp2_m2, tmp2_weight, roffset == 0
)
tmp2_mean = tl.where(rmask & xmask, tmp2_mean_next, tmp2_mean)
tmp2_m2 = tl.where(rmask & xmask, tmp2_m2_next, tmp2_m2)
tmp2_weight = tl.where(rmask & xmask, tmp2_weight_next, tmp2_weight)
tmp2_tmp, tmp3_tmp, tmp4_tmp = triton_helpers.welford(
tmp2_mean, tmp2_m2, tmp2_weight, 1
)
tmp2 = tmp2_tmp[:, None]
tmp3 = tmp3_tmp[:, None]
tmp4 = tmp4_tmp[:, None]
tl.store(out_ptr0 + (x0), tmp2, xmask)
tl.store(out_ptr1 + (x0), tmp3, xmask)
''', device_str='cuda')
import triton
import triton.language as tl
from torch._inductor.runtime.triton_heuristics import grid, split_scan_grid, start_graph, end_graph
from torch._C import _cuda_getCurrentRawStream as get_raw_stream
# kernel path: /tmp/torchinductor_root/vz/cvz2e45ualgamapnnqmrism2mt544ode6peyqz2cucv74yra3d3e.py
# Source Nodes: [_tgt], Original ATen: [aten.native_layer_norm]
# _tgt => add, add_1, clone, mul, mul_1, rsqrt, sub, var_mean
triton_poi_fused_native_layer_norm_1 = async_compile.triton('triton_', '''
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=[8388608],
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=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 5, 7), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_native_layer_norm_1', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 5, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, in_ptr1, in_ptr2, in_ptr3, in_ptr4, out_ptr0, ks0, xnumel, XBLOCK : tl.constexpr):
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x2 = xindex
x0 = xindex % ks0
x1 = (xindex // ks0)
tmp0 = tl.load(in_ptr0 + (x2), xmask, eviction_policy='evict_last')
tmp1 = tl.load(in_ptr1 + (x0), xmask, eviction_policy='evict_last')
tmp3 = tl.load(in_ptr2 + (x0), xmask, eviction_policy='evict_last')
tmp10 = tl.load(in_ptr3 + (x1), xmask, eviction_policy='evict_last')
tmp12 = tl.load(in_ptr4 + (x1), xmask, eviction_policy='evict_last')
tmp2 = tmp0 - tmp1
tmp4 = 256.0
tmp5 = tmp3 / tmp4
tmp6 = 1e-05
tmp7 = tmp5 + tmp6
tmp8 = libdevice.rsqrt(tmp7)
tmp9 = tmp2 * tmp8
tmp11 = tmp9 * tmp10
tmp13 = tmp11 + tmp12
tl.store(out_ptr0 + (x2), tmp13, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/ey/ceyi3gxljun775p3tz5ucspqeydrnqgqbapcogamalwzpxp4wp57.py
# Source Nodes: [Q, q], Original ATen: [aten._to_copy, aten.add]
# Q => convert_element_type_2
# q => add_2
triton_poi_fused__to_copy_add_2 = async_compile.triton('triton_', '''
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=[32768, 256], tile_hint=TileHint.DEFAULT,
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp16', 3: 'i32', 4: 'i32', 5: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 5), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_add_2', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, in_ptr1, out_ptr0, ks0, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
xnumel = 256
yoffset = (tl.program_id(1) + tl.program_id(2) * tl.num_programs(1)) * YBLOCK
yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
ymask = yindex < ynumel
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
x1 = xindex
y0 = yindex
tmp0 = tl.load(in_ptr0 + (y0 + (ks0*x1)), xmask & ymask, eviction_policy='evict_last')
tmp1 = tl.load(in_ptr1 + (x1 + (256*y0)), xmask & ymask, eviction_policy='evict_last')
tmp2 = tmp0 + tmp1
tmp3 = tmp2.to(tl.float32)
tl.store(out_ptr0 + (x1 + (256*y0)), tmp3, xmask & ymask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/kz/ckzduggze346udedgsxmdiricbabx3tfjxwxwwhusjneu3pglj4q.py
# Source Nodes: [Q], Original ATen: [aten._to_copy]
# Q => convert_element_type_1
triton_poi_fused__to_copy_3 = async_compile.triton('triton_', '''
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=[65536],
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp16', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_3', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
xnumel = 65536
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x0 = xindex
tmp0 = tl.load(in_ptr0 + (x0), None)
tmp1 = tmp0.to(tl.float32)
tl.store(out_ptr0 + (x0), tmp1, None)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/by/cbytdd4wxtobfibq26xx4pzxcncwldcnxv26xj6txtsdgqa7yfqc.py
# Source Nodes: [K, V], Original ATen: [aten._to_copy]
# K => convert_element_type_8
# V => convert_element_type_14
triton_poi_fused__to_copy_4 = async_compile.triton('triton_', '''
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=[4194304],
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp16', 3: '*fp16', 4: 'i32', 5: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 5), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_4', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, in_ptr1, out_ptr0, out_ptr1, ks0, xnumel, XBLOCK : tl.constexpr):
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x0 = xindex % 256
x1 = (xindex // 256)
x2 = xindex
tmp0 = tl.load(in_ptr0 + ((2*x1) + (ks0*x0)), xmask, eviction_policy='evict_last')
tmp1 = tl.load(in_ptr1 + (x0 + (512*x1)), xmask)
tmp2 = tmp0 + tmp1
tmp3 = tmp2.to(tl.float32)
tmp4 = tmp0.to(tl.float32)
tl.store(out_ptr0 + (x2), tmp3, xmask)
tl.store(out_ptr1 + (x2), tmp4, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/yn/cynnar772u76tayw2s7wlp7kkpkkhcg4kyvfao6arnoubqq32ivh.py
# Source Nodes: [K], Original ATen: [aten._to_copy]
# K => convert_element_type_6
triton_poi_fused__to_copy_5 = async_compile.triton('triton_', '''
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: '*fp16', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_5', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
xnumel = 256
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x0 = xindex
tmp0 = tl.load(in_ptr0 + (x0), xmask)
tmp1 = tmp0.to(tl.float32)
tl.store(out_ptr0 + (x0), tmp1, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/ya/cyahqbyf4xbavaxwwsj4wnvepo64dfe6k7gn5w5xl4dd6244utdg.py
# Source Nodes: [Q_1], Original ATen: [aten.div]
# Q_1 => div
triton_poi_fused_div_6 = async_compile.triton('triton_', '''
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=[8388608],
filename=__file__,
triton_meta={'signature': {0: '*fp16', 1: '*fp32', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_div_6', 'mutated_arg_names': ['in_out_ptr0'], 'no_x_dim': False, 'num_load': 2, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_out_ptr0, in_ptr0, xnumel, XBLOCK : tl.constexpr):
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x2 = xindex
x0 = xindex % 256
tmp0 = tl.load(in_out_ptr0 + (x2), xmask).to(tl.float32)
tmp1 = tl.load(in_ptr0 + (x0), xmask, eviction_policy='evict_last')
tmp2 = tmp1.to(tl.float32)
tmp3 = tmp0 + tmp2
tmp4 = 0.125
tmp5 = tmp3 * tmp4
tl.store(in_out_ptr0 + (x2), tmp5, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/2c/c2c7qu6ab32lw7hq6r3x3o5yx6jzvxa4qf45wvb3nwkq2dgkfpz3.py
# Source Nodes: [attn, matmul_1], Original ATen: [aten._softmax, aten._to_copy]
# attn => amax, convert_element_type_20, div_1, exp, sub_1, sum_1
# matmul_1 => convert_element_type_21
triton_red_fused__softmax__to_copy_7 = async_compile.triton('triton_', '''
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.reduction(
size_hints=[131072, 16384],
reduction_hint=ReductionHint.INNER,
filename=__file__,
triton_meta={'signature': {0: '*fp16', 1: '*fp16', 2: 'i32', 3: 'i32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_red_fused__softmax__to_copy_7', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 2, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, out_ptr2, ks0, xnumel, rnumel, XBLOCK : tl.constexpr, RBLOCK : tl.constexpr):
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
rbase = tl.arange(0, RBLOCK)[None, :]
x0 = xindex
_tmp3 = tl.full([XBLOCK, RBLOCK], float("-inf"), tl.float32)
for roffset in range(0, rnumel, RBLOCK):
rindex = roffset + rbase
rmask = rindex < rnumel
r1 = rindex
tmp0 = tl.load(in_ptr0 + (r1 + (x0*((1 + ks0) // 2))), rmask & xmask, eviction_policy='evict_last', other=0.0).to(tl.float32)
tmp1 = tmp0.to(tl.float32)
tmp2 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
tmp4 = triton_helpers.maximum(_tmp3, tmp2)
_tmp3 = tl.where(rmask & xmask, tmp4, _tmp3)
tmp3 = triton_helpers.max2(_tmp3, 1)[:, None]
_tmp10 = tl.full([XBLOCK, RBLOCK], 0, tl.float32)
for roffset in range(0, rnumel, RBLOCK):
rindex = roffset + rbase
rmask = rindex < rnumel
r1 = rindex
tmp5 = tl.load(in_ptr0 + (r1 + (x0*((1 + ks0) // 2))), rmask & xmask, eviction_policy='evict_last', other=0.0).to(tl.float32)
tmp6 = tmp5.to(tl.float32)
tmp7 = tmp6 - tmp3
tmp8 = tl_math.exp(tmp7)
tmp9 = tl.broadcast_to(tmp8, [XBLOCK, RBLOCK])
tmp11 = _tmp10 + tmp9
_tmp10 = tl.where(rmask & xmask, tmp11, _tmp10)
tmp10 = tl.sum(_tmp10, 1)[:, None]
for roffset in range(0, rnumel, RBLOCK):
rindex = roffset + rbase
rmask = rindex < rnumel
r1 = rindex
tmp12 = tl.load(in_ptr0 + (r1 + (x0*((1 + ks0) // 2))), rmask & xmask, eviction_policy='evict_first', other=0.0).to(tl.float32)
tmp13 = tmp12.to(tl.float32)
tmp14 = tmp13 - tmp3
tmp15 = tl_math.exp(tmp14)
tmp16 = tmp15 / tmp10
tmp17 = tmp16.to(tl.float32)
tl.store(out_ptr2 + (r1 + (x0*((1 + ks0) // 2))), tmp17, rmask & xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/on/congxac5xtqwq2x3tu4yd5qdgksp4dpwotjywhzr53djh2icqjua.py
# Source Nodes: [outputs_1], Original ATen: [aten.clone]
# outputs_1 => clone_2
triton_poi_fused_clone_8 = async_compile.triton('triton_', '''
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=[8388608],
filename=__file__,
triton_meta={'signature': {0: '*fp16', 1: '*fp16', 2: 'i32', 3: 'i32', 4: 'i32', 5: 'i32', 6: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1), 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': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, out_ptr0, ks0, ks1, ks2, ks3, xnumel, XBLOCK : tl.constexpr):
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x0 = xindex % ks0
x1 = (xindex // ks0) % ks1
x2 = (xindex // ks2)
x3 = xindex
tmp0 = tl.load(in_ptr0 + (x0 + (x2*(256 // ks1)) + (ks3*x1*(256 // ks1))), xmask, eviction_policy='evict_last').to(tl.float32)
tl.store(out_ptr0 + (x3), tmp0, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/ia/ciami6dn6hgwrs47gwjnkla3dmcladyfn5m4hbqfkjnd5upuaxvn.py
# Source Nodes: [tgt], Original ATen: [aten.add]
# tgt => add_3
triton_poi_fused_add_9 = async_compile.triton('triton_', '''
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, 32768], tile_hint=TileHint.DEFAULT,
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp16', 2: '*fp32', 3: '*fp32', 4: 'i32', 5: 'i32', 6: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 5), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_add_9', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, in_ptr1, in_ptr2, out_ptr0, ks0, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
ynumel = 256
yoffset = (tl.program_id(1) + tl.program_id(2) * tl.num_programs(1)) * YBLOCK
yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
ymask = yindex < ynumel
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
x1 = xindex
y0 = yindex
tmp0 = tl.load(in_ptr0 + (x1 + (ks0*y0)), xmask & ymask, eviction_policy='evict_last')
tmp1 = tl.load(in_ptr1 + (y0 + (256*x1)), xmask & ymask, eviction_policy='evict_last').to(tl.float32)
tmp2 = tl.load(in_ptr2 + (y0), ymask, eviction_policy='evict_last')
tmp3 = tmp2.to(tl.float32)
tmp4 = tmp1 + tmp3
tmp5 = tmp4.to(tl.float32)
tmp6 = tmp0 + tmp5
tl.store(out_ptr0 + (x1 + (ks0*y0)), tmp6, xmask & ymask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/uo/cuowok65jn7ilu7p7ecfojzo32vzeobpler3sqxmaeczollmmapo.py
# Source Nodes: [_tgt_1, curr_QV], Original ATen: [aten._to_copy, aten.native_layer_norm]
# _tgt_1 => add_4, add_5, clone_3, mul_4, mul_5, rsqrt_1, sub_2, var_mean_1
# curr_QV => convert_element_type_31
triton_red_fused__to_copy_native_layer_norm_10 = async_compile.triton('triton_', '''
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.reduction(
size_hints=[32768, 256],
reduction_hint=ReductionHint.DEFAULT,
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32', 3: '*fp32', 4: '*fp16', 5: 'i32', 6: 'i32', 7: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 7), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_red_fused__to_copy_native_layer_norm_10', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 4, 'num_reduction': 2, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, in_ptr1, in_ptr2, out_ptr2, out_ptr3, ks0, xnumel, rnumel, XBLOCK : tl.constexpr, RBLOCK : tl.constexpr):
rnumel = 256
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
rbase = tl.arange(0, RBLOCK)[None, :]
x0 = xindex
tmp2_mean = tl.zeros([XBLOCK, RBLOCK], tl.float32)
tmp2_m2 = tl.zeros([XBLOCK, RBLOCK], tl.float32)
tmp2_weight = tl.zeros([XBLOCK, RBLOCK], tl.float32)
for roffset in range(0, rnumel, RBLOCK):
rindex = roffset + rbase
rmask = rindex < rnumel
r1 = rindex
tmp0 = tl.load(in_ptr0 + (x0 + (ks0*r1)), rmask & xmask, eviction_policy='evict_last', other=0.0)
tmp1 = tl.broadcast_to(tmp0, [XBLOCK, RBLOCK])
tmp2_mean_next, tmp2_m2_next, tmp2_weight_next = triton_helpers.welford_reduce(
tmp1, tmp2_mean, tmp2_m2, tmp2_weight, roffset == 0
)
tmp2_mean = tl.where(rmask & xmask, tmp2_mean_next, tmp2_mean)
tmp2_m2 = tl.where(rmask & xmask, tmp2_m2_next, tmp2_m2)
tmp2_weight = tl.where(rmask & xmask, tmp2_weight_next, tmp2_weight)
tmp2_tmp, tmp3_tmp, tmp4_tmp = triton_helpers.welford(
tmp2_mean, tmp2_m2, tmp2_weight, 1
)
tmp2 = tmp2_tmp[:, None]
tmp3 = tmp3_tmp[:, None]
tmp4 = tmp4_tmp[:, None]
for roffset in range(0, rnumel, RBLOCK):
rindex = roffset + rbase
rmask = rindex < rnumel
r1 = rindex
tmp5 = tl.load(in_ptr0 + (x0 + (ks0*r1)), rmask & xmask, eviction_policy='evict_first', other=0.0)
tmp13 = tl.load(in_ptr1 + (r1), rmask, eviction_policy='evict_last', other=0.0)
tmp15 = tl.load(in_ptr2 + (r1), rmask, eviction_policy='evict_last', other=0.0)
tmp6 = tmp5 - tmp2
tmp7 = 256.0
tmp8 = tmp3 / tmp7
tmp9 = 1e-05
tmp10 = tmp8 + tmp9
tmp11 = libdevice.rsqrt(tmp10)
tmp12 = tmp6 * tmp11
tmp14 = tmp12 * tmp13
tmp16 = tmp14 + tmp15
tmp17 = tmp16.to(tl.float32)
tl.store(out_ptr2 + (r1 + (256*x0)), tmp16, rmask & xmask)
tl.store(out_ptr3 + (r1 + (256*x0)), tmp17, rmask & xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/ql/cqlvi4z6emmolmje6siqevz2szjglsleknd64lz6zqfbcblgek66.py
# Source Nodes: [curr_QV], Original ATen: [aten._to_copy]
# curr_QV => convert_element_type_30
triton_poi_fused__to_copy_11 = async_compile.triton('triton_', '''
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=[131072],
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp16', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_11', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
xnumel = 131072
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x0 = xindex
tmp0 = tl.load(in_ptr0 + (x0), None)
tmp1 = tmp0.to(tl.float32)
tl.store(out_ptr0 + (x0), tmp1, None)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/4g/c4gcelqhsvobirpokprgfx35gdsqo2pfz6o3ls6fmwhjfrodnnf4.py
# Source Nodes: [curr_QV], Original ATen: [aten._to_copy]
# curr_QV => convert_element_type_29
triton_poi_fused__to_copy_12 = async_compile.triton('triton_', '''
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=[512],
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp16', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_12', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
xnumel = 512
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x0 = xindex
tmp0 = tl.load(in_ptr0 + (x0), xmask)
tmp1 = tmp0.to(tl.float32)
tl.store(out_ptr0 + (x0), tmp1, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/dg/cdg2donqs5d27apgvv2pnsidu6d7tuhhmdmflfnugud6xxrszsso.py
# Source Nodes: [ID_KV], Original ATen: [aten._to_copy]
# ID_KV => convert_element_type_37
triton_poi_fused__to_copy_13 = async_compile.triton('triton_', '''
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=[8388608],
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp16', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__to_copy_13', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x0 = xindex
tmp0 = tl.load(in_ptr0 + (x0), xmask)
tmp1 = tmp0.to(tl.float32)
tl.store(out_ptr0 + (x0), tmp1, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/yc/cyc6e4rpbote3u4cjxxudvlrotbvsl2ysjchpo6qnra74glhespz.py
# Source Nodes: [], Original ATen: []
triton_poi_fused_14 = async_compile.triton('triton_', '''
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=[131072],
filename=__file__,
triton_meta={'signature': {0: '*fp32', 1: '*fp16', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_14', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
xnumel = 67584
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x1 = (xindex // 256)
x2 = xindex
tmp0 = x1
tmp1 = tl.full([1], 257, tl.int64)
tmp2 = tmp0 < tmp1
tmp3 = tl.load(in_ptr0 + (x2), tmp2, other=0.0)
tmp4 = tmp3.to(tl.float32)
tmp5 = tl.full(tmp4.shape, 0.0, tmp4.dtype)
tmp6 = tl.where(tmp2, tmp4, tmp5)
tl.store(out_ptr0 + (x2), tmp6, None)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/m3/cm36vzch7nuglv4iluddqw3xhokemjpzvqhzil3qfmfncetfvttb.py
# Source Nodes: [tensor, tensor_1], Original ATen: [aten.clone]
# tensor => clone_4
# tensor_1 => clone_5
triton_poi_fused_clone_15 = async_compile.triton('triton_', '''
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, 32768], tile_hint=TileHint.DEFAULT,
filename=__file__,
triton_meta={'signature': {0: '*fp16', 1: '*fp16', 2: '*fp32', 3: '*fp16', 4: '*fp16', 5: 'i32', 6: 'i32', 7: 'i32', 8: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 4, 7), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clone_15', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, in_ptr1, in_ptr2, out_ptr0, out_ptr1, ks0, ks1, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
ynumel = 256
yoffset = (tl.program_id(1) + tl.program_id(2) * tl.num_programs(1)) * YBLOCK
yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
ymask = yindex < ynumel
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
x1 = xindex
y0 = yindex
tmp0 = tl.load(in_ptr0 + (y0 + (512*x1)), xmask & ymask, eviction_policy='evict_last').to(tl.float32)
tmp1 = tl.load(in_ptr1 + (264*x1), xmask, eviction_policy='evict_last').to(tl.float32)
tmp6 = tl.load(in_ptr2 + (0))
tmp7 = tl.broadcast_to(tmp6, [XBLOCK, YBLOCK])
tmp2 = tl.full([1, 1], 0, tl.int64)
tmp3 = tmp2 >= tmp2
tmp4 = tl.full([1, 1], 257, tl.int64)
tmp5 = tmp2 < tmp4
tmp8 = tmp7.to(tl.float32)
tmp9 = tl.full(tmp8.shape, 0.0, tmp8.dtype)
tmp10 = tl.where(tmp5, tmp8, tmp9)
tmp11 = tmp2 >= tmp4
tmp12 = tl.full([1, 1], 264, tl.int64)
tmp13 = tmp2 < tmp12
tmp14 = 0.0
tmp15 = tl.full(tmp14.shape, 0.0, tmp14.dtype)
tmp16 = tl.where(tmp11, tmp14, tmp15)
tmp17 = tl.where(tmp5, tmp10, tmp16)
tmp18 = tmp1 + tmp17
tmp19 = libdevice.tanh(tmp18)
tmp20 = 1.0
tmp21 = tmp19 + tmp20
tmp22 = tmp0 * tmp21
tl.store(out_ptr0 + (x1 + (ks0*ks1*y0)), tmp0, xmask & ymask)
tl.store(out_ptr1 + (x1 + (ks0*ks1*y0)), tmp22, xmask & ymask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/ht/chtc7mqqpqffcgztk7myk3ljdyif5qgytm7vbkq2lcjsechsxetf.py
# Source Nodes: [tensor_2], Original ATen: [aten.clone]
# tensor_2 => clone_6
triton_poi_fused_clone_16 = async_compile.triton('triton_', '''
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=[32768, 256], tile_hint=TileHint.DEFAULT,
filename=__file__,
triton_meta={'signature': {0: '*fp16', 1: '*fp16', 2: '*fp32', 3: '*fp16', 4: 'i32', 5: 'i32', 6: 'i32', 7: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 7), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clone_16', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, in_ptr1, in_ptr2, out_ptr0, ks0, ks1, ynumel, xnumel, YBLOCK : tl.constexpr, XBLOCK : tl.constexpr):
xnumel = 256
yoffset = (tl.program_id(1) + tl.program_id(2) * tl.num_programs(1)) * YBLOCK
yindex = yoffset + tl.arange(0, YBLOCK)[None, :]
ymask = yindex < ynumel
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
x1 = xindex
y0 = yindex
tmp0 = tl.load(in_ptr0 + (256 + x1 + (512*y0)), xmask & ymask, eviction_policy='evict_last').to(tl.float32)
tmp1 = tl.load(in_ptr1 + (1 + x1 + (264*y0)), xmask & ymask, eviction_policy='evict_last').to(tl.float32)
tmp2 = 1 + x1
tmp3 = tl.full([1, 1], 0, tl.int64)
tmp4 = tmp2 >= tmp3
tmp5 = tl.full([1, 1], 257, tl.int64)
tmp6 = tmp2 < tmp5
tmp7 = tl.load(in_ptr2 + (tl.broadcast_to(1 + x1, [XBLOCK, YBLOCK])), tmp6 & xmask & ymask, eviction_policy='evict_last', other=0.0)
tmp8 = tmp7.to(tl.float32)
tmp9 = tl.full(tmp8.shape, 0.0, tmp8.dtype)
tmp10 = tl.where(tmp6, tmp8, tmp9)
tmp11 = tmp2 >= tmp5
tmp12 = tl.full([1, 1], 264, tl.int64)
tmp13 = tmp2 < tmp12
tmp14 = 0.0
tmp15 = tl.full(tmp14.shape, 0.0, tmp14.dtype)
tmp16 = tl.where(tmp11, tmp14, tmp15)
tmp17 = tl.where(tmp6, tmp10, tmp16)
tmp18 = tmp1 + tmp17
tmp19 = tmp0 + tmp18
tl.store(out_ptr0 + (y0 + (ks0*ks1*x1)), tmp19, xmask & ymask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/63/c634evpcrld3hegpdjpu7dr53jbl4imrp5igdqpiwapcnqvvvm6y.py
# Source Nodes: [global_K], Original ATen: [aten.clone]
# global_K => clone_7
triton_poi_fused_clone_17 = async_compile.triton('triton_', '''
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=[2097152],
filename=__file__,
triton_meta={'signature': {0: '*fp16', 1: '*fp16', 2: '*fp32', 3: '*fp16', 4: 'i32', 5: 'i32', 6: 'i32', 7: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 5, 7), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clone_17', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, in_ptr1, in_ptr2, out_ptr0, ks0, ks1, ks2, xnumel, XBLOCK : tl.constexpr):
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x0 = xindex % 256
x1 = (xindex // 256) % ks0
x2 = (xindex // ks1)
x3 = xindex
tmp0 = tl.load(in_ptr0 + (x0 + (1024*x1) + (1024*ks2*x2)), xmask, eviction_policy='evict_last').to(tl.float32)
tmp1 = tl.load(in_ptr1 + ((528*x1) + (528*ks2*x2)), xmask, eviction_policy='evict_last').to(tl.float32)
tmp6 = tl.load(in_ptr2 + (0))
tmp7 = tl.broadcast_to(tmp6, [XBLOCK])
tmp2 = tl.full([1], 0, tl.int64)
tmp3 = tmp2 >= tmp2
tmp4 = tl.full([1], 257, tl.int64)
tmp5 = tmp2 < tmp4
tmp8 = tmp7.to(tl.float32)
tmp9 = tl.full(tmp8.shape, 0.0, tmp8.dtype)
tmp10 = tl.where(tmp5, tmp8, tmp9)
tmp11 = tmp2 >= tmp4
tmp12 = tl.full([1], 264, tl.int64)
tmp13 = tmp2 < tmp12
tmp14 = 0.0
tmp15 = tl.full(tmp14.shape, 0.0, tmp14.dtype)
tmp16 = tl.where(tmp11, tmp14, tmp15)
tmp17 = tl.where(tmp5, tmp10, tmp16)
tmp18 = tmp1 + tmp17
tmp19 = libdevice.tanh(tmp18)
tmp20 = 1.0
tmp21 = tmp19 + tmp20
tmp22 = tmp0 * tmp21
tl.store(out_ptr0 + (x3), tmp22, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/3g/c3gj4nlibr3pngihadjivozssv7rvrjw7ymmcqh23o353l4k4f2k.py
# Source Nodes: [global_K], Original ATen: [aten._unsafe_view, aten.clone]
# global_K => clone_7, view_29
triton_poi_fused__unsafe_view_clone_18 = async_compile.triton('triton_', '''
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=[2097152],
filename=__file__,
triton_meta={'signature': {0: '*fp16', 1: '*fp16', 2: 'i32', 3: 'i32', 4: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 4), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused__unsafe_view_clone_18', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, out_ptr0, ks0, ks1, xnumel, XBLOCK : tl.constexpr):
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x0 = xindex % 256
x1 = (xindex // 256)
x2 = xindex
tmp0 = tl.load(in_ptr0 + (x0 + (256*(x1 % (ks0*((1 + ks1) // 2))))), xmask, eviction_policy='evict_last').to(tl.float32)
tl.store(out_ptr0 + (x2), tmp0, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/zn/cznhsgkdosya2d65gqo2n2vw5fyhouophbei74x726qoak4xfggb.py
# Source Nodes: [Q_3], Original ATen: [aten.div]
# Q_3 => div_2
triton_poi_fused_div_19 = async_compile.triton('triton_', '''
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=[8388608],
filename=__file__,
triton_meta={'signature': {0: '*fp16', 1: '*fp16', 2: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_div_19', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 1, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, out_ptr0, xnumel, XBLOCK : tl.constexpr):
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x0 = xindex % 256
x1 = (xindex // 256)
x2 = xindex
tmp0 = tl.load(in_ptr0 + (x0 + (512*x1)), xmask).to(tl.float32)
tmp1 = 0.0625
tmp2 = tmp0 * tmp1
tl.store(out_ptr0 + (x2), tmp2, xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/ye/cyef7lse67plee6zov4nzz7rhh5cuq5fmk6uvz24rc3lo3kjue5b.py
# Source Nodes: [attn_2, matmul_3], Original ATen: [aten._softmax, aten._to_copy]
# attn_2 => amax_1, convert_element_type_43, div_3, exp_1, sub_3, sum_2
# matmul_3 => convert_element_type_44
triton_red_fused__softmax__to_copy_20 = async_compile.triton('triton_', '''
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.reduction(
size_hints=[32768, 8192],
reduction_hint=ReductionHint.INNER,
filename=__file__,
triton_meta={'signature': {0: '*fp16', 1: '*fp16', 2: 'i32', 3: 'i32', 4: 'i32', 5: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_red_fused__softmax__to_copy_20', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 2, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, out_ptr2, ks0, ks1, xnumel, rnumel, XBLOCK : tl.constexpr, RBLOCK : tl.constexpr):
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:, None]
xmask = xindex < xnumel
rbase = tl.arange(0, RBLOCK)[None, :]
x0 = xindex
_tmp3 = tl.full([XBLOCK, RBLOCK], float("-inf"), tl.float32)
for roffset in range(0, rnumel, RBLOCK):
rindex = roffset + rbase
rmask = rindex < rnumel
r1 = rindex
tmp0 = tl.load(in_ptr0 + (r1 + (x0*((1 + ks1) // 2)*((1 + (ks0 // ks1)) // 2))), rmask & xmask, eviction_policy='evict_last', other=0.0).to(tl.float32)
tmp1 = tmp0.to(tl.float32)
tmp2 = tl.broadcast_to(tmp1, [XBLOCK, RBLOCK])
tmp4 = triton_helpers.maximum(_tmp3, tmp2)
_tmp3 = tl.where(rmask & xmask, tmp4, _tmp3)
tmp3 = triton_helpers.max2(_tmp3, 1)[:, None]
_tmp10 = tl.full([XBLOCK, RBLOCK], 0, tl.float32)
for roffset in range(0, rnumel, RBLOCK):
rindex = roffset + rbase
rmask = rindex < rnumel
r1 = rindex
tmp5 = tl.load(in_ptr0 + (r1 + (x0*((1 + ks1) // 2)*((1 + (ks0 // ks1)) // 2))), rmask & xmask, eviction_policy='evict_last', other=0.0).to(tl.float32)
tmp6 = tmp5.to(tl.float32)
tmp7 = tmp6 - tmp3
tmp8 = tl_math.exp(tmp7)
tmp9 = tl.broadcast_to(tmp8, [XBLOCK, RBLOCK])
tmp11 = _tmp10 + tmp9
_tmp10 = tl.where(rmask & xmask, tmp11, _tmp10)
tmp10 = tl.sum(_tmp10, 1)[:, None]
for roffset in range(0, rnumel, RBLOCK):
rindex = roffset + rbase
rmask = rindex < rnumel
r1 = rindex
tmp12 = tl.load(in_ptr0 + (r1 + (x0*((1 + ks1) // 2)*((1 + (ks0 // ks1)) // 2))), rmask & xmask, eviction_policy='evict_first', other=0.0).to(tl.float32)
tmp13 = tmp12.to(tl.float32)
tmp14 = tmp13 - tmp3
tmp15 = tl_math.exp(tmp14)
tmp16 = tmp15 / tmp10
tmp17 = tmp16.to(tl.float32)
tl.store(out_ptr2 + (r1 + (x0*((1 + ks1) // 2)*((1 + (ks0 // ks1)) // 2))), tmp17, rmask & xmask)
''', device_str='cuda')
# kernel path: /tmp/torchinductor_root/oz/cozu4wsjkasokigmqxsosjnq5hpmy3hwxgida4fp6oryhfz5mwjt.py
# Source Nodes: [global_V], Original ATen: [aten.clone]
# global_V => clone_8
triton_poi_fused_clone_21 = async_compile.triton('triton_', '''
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=[2097152],
filename=__file__,
triton_meta={'signature': {0: '*fp16', 1: '*fp16', 2: '*fp32', 3: '*fp16', 4: 'i32', 5: 'i32', 6: 'i32', 7: 'i32'}, 'device': DeviceProperties(type='cuda', index=0, cc=89, major=8, regs_per_multiprocessor=65536, max_threads_per_multi_processor=1536, multi_processor_count=58), 'constants': {}, 'configs': [AttrsDescriptor(divisible_by_16=(0, 1, 2, 3, 5, 7), equal_to_1=())]},
inductor_meta={'autotune_hints': set(), 'kernel_name': 'triton_poi_fused_clone_21', 'mutated_arg_names': [], 'no_x_dim': False, 'num_load': 3, 'num_reduction': 0, 'backend_hash': '72c34bdb145549777ca2f0838f26abe42bb446cf528c78d229508b5a55e67a78', 'are_deterministic_algorithms_enabled': False, 'assert_indirect_indexing': True, 'autotune_local_cache': True, 'autotune_pointwise': True, 'autotune_remote_cache': False, '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_(in_ptr0, in_ptr1, in_ptr2, out_ptr0, ks0, ks1, ks2, xnumel, XBLOCK : tl.constexpr):
xoffset = tl.program_id(0) * XBLOCK
xindex = xoffset + tl.arange(0, XBLOCK)[:]
xmask = xindex < xnumel
x0 = xindex % 256
x1 = (xindex // 256) % ks0
x2 = (xindex // ks1)
x4 = xindex
tmp0 = tl.load(in_ptr0 + (256 + x0 + (1024*x1) + (1024*ks2*x2)), xmask, eviction_policy='evict_last').to(tl.float32)
tmp1 = tl.load(in_ptr1 + (1 + x0 + (528*x1) + (528*ks2*x2)), xmask, eviction_policy='evict_last').to(tl.float32)
tmp2 = 1 + x0
tmp3 = tl.full([1], 0, tl.int64)
tmp4 = tmp2 >= tmp3
tmp5 = tl.full([1], 257, tl.int64)
tmp6 = tmp2 < tmp5
tmp7 = tl.load(in_ptr2 + (1 + x0), tmp6 & xmask, eviction_policy='evict_last', other=0.0)
tmp8 = tmp7.to(tl.float32)
tmp9 = tl.full(tmp8.shape, 0.0, tmp8.dtype)
tmp10 = tl.where(tmp6, tmp8, tmp9)
tmp11 = tmp2 >= tmp5
tmp12 = tl.full([1], 264, tl.int64)
tmp13 = tmp2 < tmp12
tmp14 = 0.0
tmp15 = tl.full(tmp14.shape, 0.0, tmp14.dtype)
tmp16 = tl.where(tmp11, tmp14, tmp15)
tmp17 = tl.where(tmp6, tmp10, tmp16)
tmp18 = tmp1 + tmp17
tmp19 = tmp0 + tmp18
tl.store(out_ptr0 + (x4), tmp19, xmask)
''', device_str='cuda')
async_compile.wait(globals())
del async_compile
def call(args):
arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1, arg9_1, arg10_1, arg11_1, arg12_1, arg13_1, arg14_1, arg15_1, arg16_1, arg17_1, arg18_1, arg19_1, arg20_1, arg21_1, arg22_1, arg23_1, arg24_1, arg25_1, arg26_1 = args
args.clear()
s13 = arg2_1
s6 = arg5_1
s7 = arg6_1
s8 = arg13_1
s9 = arg20_1
s10 = arg21_1
assert_size_stride(arg0_1, (256, ), (1, ))
assert_size_stride(arg1_1, (256, ), (1, ))
assert_size_stride(arg3_1, (s13, 1, 256), (1, 256*s13, s13))
assert_size_stride(arg4_1, (s13, 1, 256), (256, 256, 1))
assert_size_stride(arg7_1, (256, 256), (256, 1))
assert_size_stride(arg8_1, (256, ), (1, ))
assert_size_stride(arg9_1, (256, 256), (256, 1))
assert_size_stride(arg10_1, (256, ), (1, ))
assert_size_stride(arg11_1, (256, 256), (256, 1))
assert_size_stride(arg12_1, (256, ), (1, ))
assert_size_stride(arg14_1, (256, 256), (256, 1))
assert_size_stride(arg15_1, (256, ), (1, ))
assert_size_stride(arg16_1, (256, ), (1, ))
assert_size_stride(arg17_1, (256, ), (1, ))
assert_size_stride(arg18_1, (512, 256), (256, 1))
assert_size_stride(arg19_1, (512, ), (1, ))
assert_size_stride(arg22_1, (s13, 1, 256), (256, 256, 1))
assert_size_stride(arg23_1, (257, 256), (256, 1))
assert_size_stride(arg24_1, (257, ), (1, ))
assert_size_stride(arg25_1, (256, 256), (256, 1))
assert_size_stride(arg26_1, (256, ), (1, ))
with torch.cuda._DeviceGuard(0):
torch.cuda.set_device(0)
buf0 = empty_strided_cuda((s13, 1, 1), (1, s13, s13), torch.float32)
buf1 = empty_strided_cuda((s13, 1, 1), (1, s13, s13), torch.float32)
# Source Nodes: [_tgt], Original ATen: [aten.native_layer_norm]
stream0 = get_raw_stream(0)
triton_red_fused_native_layer_norm_0.run(arg3_1, buf0, buf1, s13, s13, 256, grid=grid(s13), stream=stream0)
buf3 = empty_strided_cuda((s13, 1, 256), (1, 256*s13, s13), torch.float32)
# Source Nodes: [_tgt], Original ATen: [aten.native_layer_norm]
triton_poi_fused_native_layer_norm_1_xnumel = 256*s13
triton_poi_fused_native_layer_norm_1.run(arg3_1, buf0, buf1, arg0_1, arg1_1, buf3, s13, triton_poi_fused_native_layer_norm_1_xnumel, grid=grid(triton_poi_fused_native_layer_norm_1_xnumel), stream=stream0)
del arg0_1
del arg1_1
del buf0
del buf1
buf4 = empty_strided_cuda((s13, 1, 256), (256, 256, 1), torch.float16)
# Source Nodes: [Q, q], Original ATen: [aten._to_copy, aten.add]
triton_poi_fused__to_copy_add_2.run(buf3, arg4_1, buf4, s13, s13, 256, grid=grid(s13, 256), stream=stream0)
buf5 = empty_strided_cuda((256, 256), (256, 1), torch.float16)
# Source Nodes: [Q], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_3.run(arg7_1, buf5, 65536, grid=grid(65536), stream=stream0)
del arg7_1
buf6 = empty_strided_cuda((s13, 256), (256, 1), torch.float16)
# Source Nodes: [], Original ATen: []
extern_kernels.mm(reinterpret_tensor(buf4, (s13, 256), (256, 1), 0), reinterpret_tensor(buf5, (256, 256), (1, 256), 0), out=buf6)
buf7 = empty_strided_cuda((((1 + s13) // 2), 1, 256), (256, 256, 1), torch.float16)
buf15 = empty_strided_cuda((((1 + s13) // 2), 1, 256), (256, 256, 1), torch.float16)
# Source Nodes: [K, V], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_4_xnumel = 256*((1 + s13) // 2)
triton_poi_fused__to_copy_4.run(buf3, arg4_1, buf7, buf15, s13, triton_poi_fused__to_copy_4_xnumel, grid=grid(triton_poi_fused__to_copy_4_xnumel), stream=stream0)
del arg4_1
buf8 = buf5; del buf5 # reuse
# Source Nodes: [K], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_3.run(arg9_1, buf8, 65536, grid=grid(65536), stream=stream0)
del arg9_1
buf9 = empty_strided_cuda((256, ), (1, ), torch.float16)
# Source Nodes: [K], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_5.run(arg10_1, buf9, 256, grid=grid(256), stream=stream0)
del arg10_1
buf10 = empty_strided_cuda((((1 + s13) // 2), 256), (256, 1), torch.float16)
# Source Nodes: [K], Original ATen: [aten._to_copy, aten.addmm]
extern_kernels.addmm(buf9, reinterpret_tensor(buf7, (((1 + s13) // 2), 256), (256, 1), 0), reinterpret_tensor(buf8, (256, 256), (1, 256), 0), alpha=1, beta=1, out=buf10)
del buf7
buf11 = reinterpret_tensor(buf6, (s13, 1, 256), (256, 256, 1), 0); del buf6 # reuse
# Source Nodes: [Q_1], Original ATen: [aten.div]
triton_poi_fused_div_6_xnumel = 256*s13
triton_poi_fused_div_6.run(buf11, arg8_1, triton_poi_fused_div_6_xnumel, grid=grid(triton_poi_fused_div_6_xnumel), stream=stream0)
del arg8_1
buf12 = empty_strided_cuda((s6, s13, ((1 + s13) // 2)), (s13*((1 + s13) // 2), ((1 + s13) // 2), 1), torch.float16)
# Source Nodes: [QK], Original ATen: [aten.bmm]
extern_kernels.bmm(reinterpret_tensor(buf11, (s6, s13, (256 // s6)), (s8, 256, 1), 0), reinterpret_tensor(buf10, (s6, (256 // s6), ((1 + s13) // 2)), (s8, 1, s6*s8), 0), out=buf12)
buf19 = empty_strided_cuda((1, s6, s13, ((1 + s13) // 2)), (s6*s13*((1 + s13) // 2), s13*((1 + s13) // 2), ((1 + s13) // 2), 1), torch.float16)
# Source Nodes: [attn, matmul_1], Original ATen: [aten._softmax, aten._to_copy]
triton_red_fused__softmax__to_copy_7_xnumel = s6*s13
triton_red_fused__softmax__to_copy_7_rnumel = ((1 + s13) // 2)
triton_red_fused__softmax__to_copy_7.run(buf12, buf19, s13, triton_red_fused__softmax__to_copy_7_xnumel, triton_red_fused__softmax__to_copy_7_rnumel, grid=grid(triton_red_fused__softmax__to_copy_7_xnumel), stream=stream0)
del buf12
buf16 = buf8; del buf8 # reuse
# Source Nodes: [V], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_3.run(arg11_1, buf16, 65536, grid=grid(65536), stream=stream0)
del arg11_1
buf17 = buf9; del buf9 # reuse
# Source Nodes: [V], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_5.run(arg12_1, buf17, 256, grid=grid(256), stream=stream0)
del arg12_1
buf18 = buf10; del buf10 # reuse
# Source Nodes: [V], Original ATen: [aten._to_copy, aten.addmm]
extern_kernels.addmm(buf17, reinterpret_tensor(buf15, (((1 + s13) // 2), 256), (256, 1), 0), reinterpret_tensor(buf16, (256, 256), (1, 256), 0), alpha=1, beta=1, out=buf18)
del buf15
buf20 = empty_strided_cuda((s6, s13, (256 // s6)), (s13*(256 // s6), (256 // s6), 1), torch.float16)
# Source Nodes: [matmul_1], Original ATen: [aten.bmm]
extern_kernels.bmm(reinterpret_tensor(buf19, (s6, s13, ((1 + s13) // 2)), (s13*((1 + s13) // 2), ((1 + s13) // 2), 1), 0), reinterpret_tensor(buf18, (s6, ((1 + s13) // 2), (256 // s6)), (s7, s6*s7, 1), 0), out=buf20)
del buf18
del buf19
ps0 = (256 // s6)
ps1 = s6*(256 // s6)
buf21 = empty_strided_cuda((s13, 1, s6, (256 // s6)), (s6*(256 // s6), 1, (256 // s6), 1), torch.float16)
# Source Nodes: [outputs_1], Original ATen: [aten.clone]
triton_poi_fused_clone_8_xnumel = s6*s13*(256 // s6)
triton_poi_fused_clone_8.run(buf20, buf21, ps0, s6, ps1, s13, triton_poi_fused_clone_8_xnumel, grid=grid(triton_poi_fused_clone_8_xnumel), stream=stream0)
del buf20
buf22 = buf16; del buf16 # reuse
# Source Nodes: [outputs_2], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_3.run(arg14_1, buf22, 65536, grid=grid(65536), stream=stream0)
del arg14_1
buf23 = reinterpret_tensor(buf11, (s13, 256), (256, 1), 0); del buf11 # reuse
# Source Nodes: [], Original ATen: []
extern_kernels.mm(reinterpret_tensor(buf21, (s13, s6*(256 // s6)), (s6*(256 // s6), 1), 0), reinterpret_tensor(buf22, (256, 256), (1, 256), 0), out=buf23)
del buf21
buf24 = buf3; del buf3 # reuse
# Source Nodes: [tgt], Original ATen: [aten.add]
triton_poi_fused_add_9.run(arg3_1, buf23, arg15_1, buf24, s13, 256, s13, grid=grid(256, s13), stream=stream0)
del arg15_1
del arg3_1
buf28 = empty_strided_cuda((s13, 1, 256), (256, 256, 1), torch.float32)
buf29 = reinterpret_tensor(buf23, (s13, 1, 256), (256, 256, 1), 0); del buf23 # reuse
# Source Nodes: [_tgt_1, curr_QV], Original ATen: [aten._to_copy, aten.native_layer_norm]
triton_red_fused__to_copy_native_layer_norm_10.run(buf24, arg16_1, arg17_1, buf28, buf29, s13, s13, 256, grid=grid(s13), stream=stream0)
del arg16_1
del arg17_1
buf30 = empty_strided_cuda((512, 256), (256, 1), torch.float16)
# Source Nodes: [curr_QV], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_11.run(arg18_1, buf30, 131072, grid=grid(131072), stream=stream0)
del arg18_1
buf31 = empty_strided_cuda((512, ), (1, ), torch.float16)
# Source Nodes: [curr_QV], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_12.run(arg19_1, buf31, 512, grid=grid(512), stream=stream0)
del arg19_1
buf32 = empty_strided_cuda((s13, 512), (512, 1), torch.float16)
# Source Nodes: [curr_QV], Original ATen: [aten._to_copy, aten.addmm]
extern_kernels.addmm(buf31, reinterpret_tensor(buf29, (s13, 256), (256, 1), 0), reinterpret_tensor(buf30, (256, 512), (1, 256), 0), alpha=1, beta=1, out=buf32)
del buf30
del buf31
buf33 = buf29; del buf29 # reuse
# Source Nodes: [ID_KV], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_13_xnumel = 256*s13
triton_poi_fused__to_copy_13.run(arg22_1, buf33, triton_poi_fused__to_copy_13_xnumel, grid=grid(triton_poi_fused__to_copy_13_xnumel), stream=stream0)
del arg22_1
buf34 = empty_strided_cuda((256, 264), (1, 256), torch.float16)
# Source Nodes: [], Original ATen: []
triton_poi_fused_14.run(arg23_1, buf34, 67584, grid=grid(67584), stream=stream0)
del arg23_1
buf35 = empty_strided_cuda((s13, 264), (264, 1), torch.float16)
# Source Nodes: [], Original ATen: []
extern_kernels.mm(reinterpret_tensor(buf33, (s13, 256), (256, 1), 0), buf34, out=buf35)
del buf34
buf36 = empty_strided_cuda((1, 256, s9, s10), (256*s10*s9, s10*s9, s10, 1), torch.float16)
buf37 = empty_strided_cuda((1, 256, s9, s10), (256*s10*s9, s10*s9, s10, 1), torch.float16)
# Source Nodes: [tensor, tensor_1], Original ATen: [aten.clone]
triton_poi_fused_clone_15_xnumel = s10*s9
triton_poi_fused_clone_15.run(buf32, buf35, arg24_1, buf36, buf37, s10, s9, 256, triton_poi_fused_clone_15_xnumel, grid=grid(256, triton_poi_fused_clone_15_xnumel), stream=stream0)
buf38 = empty_strided_cuda((1, 256, s9, s10), (256*s10*s9, s10*s9, s10, 1), torch.float16)
# Source Nodes: [tensor_2], Original ATen: [aten.clone]
triton_poi_fused_clone_16_ynumel = s10*s9
triton_poi_fused_clone_16.run(buf32, buf35, arg24_1, buf38, s10, s9, triton_poi_fused_clone_16_ynumel, 256, grid=grid(triton_poi_fused_clone_16_ynumel, 256), stream=stream0)
ps2 = ((1 + s10) // 2)
ps3 = 256*((1 + s10) // 2)
buf39 = empty_strided_cuda((((1 + s9) // 2), ((1 + s10) // 2), 1, 256), (256*((1 + s10) // 2), 256, 256, 1), torch.float16)
# Source Nodes: [global_K], Original ATen: [aten.clone]
triton_poi_fused_clone_17_xnumel = 256*((1 + s10) // 2)*((1 + s9) // 2)
triton_poi_fused_clone_17.run(buf32, buf35, arg24_1, buf39, ps2, ps3, s10, triton_poi_fused_clone_17_xnumel, grid=grid(triton_poi_fused_clone_17_xnumel), stream=stream0)
buf40 = empty_strided_cuda((((1 + s9) // 2)*((1 + (s13 // s9)) // 2), 1, 256), (256, 256, 1), torch.float16)
# Source Nodes: [global_K], Original ATen: [aten._unsafe_view, aten.clone]
triton_poi_fused__unsafe_view_clone_18_xnumel = 256*((1 + s9) // 2)*((1 + (s13 // s9)) // 2)
triton_poi_fused__unsafe_view_clone_18.run(buf39, buf40, ps2, s9, triton_poi_fused__unsafe_view_clone_18_xnumel, grid=grid(triton_poi_fused__unsafe_view_clone_18_xnumel), stream=stream0)
buf41 = buf33; del buf33 # reuse
# Source Nodes: [Q_3], Original ATen: [aten.div]
triton_poi_fused_div_19_xnumel = 256*s13
triton_poi_fused_div_19.run(buf32, buf41, triton_poi_fused_div_19_xnumel, grid=grid(triton_poi_fused_div_19_xnumel), stream=stream0)
buf42 = empty_strided_cuda((1, s13, ((1 + s9) // 2)*((1 + (s13 // s9)) // 2)), (s13*((1 + s9) // 2)*((1 + (s13 // s9)) // 2), ((1 + s9) // 2)*((1 + (s13 // s9)) // 2), 1), torch.float16)
# Source Nodes: [QK_1], Original ATen: [aten.bmm]
extern_kernels.bmm(reinterpret_tensor(buf41, (1, s13, 256), (0, 256, 1), 0), reinterpret_tensor(buf40, (1, 256, ((1 + s9) // 2)*((1 + (s13 // s9)) // 2)), (0, 1, 256), 0), out=buf42)
buf47 = empty_strided_cuda((1, 1, s13, ((1 + s9) // 2)*((1 + (s13 // s9)) // 2)), (s13*((1 + s9) // 2)*((1 + (s13 // s9)) // 2), 1, ((1 + s9) // 2)*((1 + (s13 // s9)) // 2), 1), torch.float16)
# Source Nodes: [attn_2, matmul_3], Original ATen: [aten._softmax, aten._to_copy]
triton_red_fused__softmax__to_copy_20_rnumel = ((1 + s9) // 2)*((1 + (s13 // s9)) // 2)
triton_red_fused__softmax__to_copy_20.run(buf42, buf47, s13, s9, s13, triton_red_fused__softmax__to_copy_20_rnumel, grid=grid(s13), stream=stream0)
del buf42
buf45 = buf39; del buf39 # reuse
# Source Nodes: [global_V], Original ATen: [aten.clone]
triton_poi_fused_clone_21_xnumel = 256*((1 + s10) // 2)*((1 + s9) // 2)
triton_poi_fused_clone_21.run(buf32, buf35, arg24_1, buf45, ps2, ps3, s10, triton_poi_fused_clone_21_xnumel, grid=grid(triton_poi_fused_clone_21_xnumel), stream=stream0)
del arg24_1
del buf35
buf46 = empty_strided_cuda((((1 + s9) // 2)*((1 + (s13 // s9)) // 2), 1, 256), (256, 256, 1), torch.float16)
# Source Nodes: [global_V], Original ATen: [aten._unsafe_view, aten.clone]
triton_poi_fused__unsafe_view_clone_18_xnumel = 256*((1 + s9) // 2)*((1 + (s13 // s9)) // 2)
triton_poi_fused__unsafe_view_clone_18.run(buf45, buf46, ps2, s9, triton_poi_fused__unsafe_view_clone_18_xnumel, grid=grid(triton_poi_fused__unsafe_view_clone_18_xnumel), stream=stream0)
del buf45
buf48 = reinterpret_tensor(buf41, (1, s13, 256), (256*s13, 256, 1), 0); del buf41 # reuse
# Source Nodes: [matmul_3], Original ATen: [aten.bmm]
extern_kernels.bmm(reinterpret_tensor(buf47, (1, s13, ((1 + s9) // 2)*((1 + (s13 // s9)) // 2)), (0, ((1 + s9) // 2)*((1 + (s13 // s9)) // 2), 1), 0), reinterpret_tensor(buf46, (1, ((1 + s9) // 2)*((1 + (s13 // s9)) // 2), 256), (256*((1 + s9) // 2)*((1 + (s13 // s9)) // 2), 256, 1), 0), out=buf48)
del buf47
buf49 = buf22; del buf22 # reuse
# Source Nodes: [outputs_5], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_3.run(arg25_1, buf49, 65536, grid=grid(65536), stream=stream0)
del arg25_1
buf50 = buf17; del buf17 # reuse
# Source Nodes: [outputs_5], Original ATen: [aten._to_copy]
triton_poi_fused__to_copy_5.run(arg26_1, buf50, 256, grid=grid(256), stream=stream0)
del arg26_1
buf51 = reinterpret_tensor(buf4, (s13, 256), (256, 1), 0); del buf4 # reuse
# Source Nodes: [outputs_5], Original ATen: [aten._to_copy, aten.addmm]
extern_kernels.addmm(buf50, reinterpret_tensor(buf48, (s13, 256), (256, 1), 0), reinterpret_tensor(buf49, (256, 256), (1, 256), 0), alpha=1, beta=1, out=buf51)
del buf48
del buf49
del buf50
return (buf36, buf37, buf38, buf24, buf28, reinterpret_tensor(buf51, (s13, 1, 256), (256, 256, 1), 0), reinterpret_tensor(buf32, (s13, 1, 256), (512, 512, 1), 0), reinterpret_tensor(buf32, (s13, 1, 256), (512, 512, 1), 256), buf40, buf46, )
def benchmark_compiled_module(times=10, repeat=10):
from torch._dynamo.testing import rand_strided
from torch._inductor.utils import print_performance
arg0_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg1_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg2_1 = 18496
arg3_1 = rand_strided((18496, 1, 256), (1, 4734976, 18496), device='cuda:0', dtype=torch.float32)
arg4_1 = rand_strided((18496, 1, 256), (256, 256, 1), device='cuda:0', dtype=torch.float32)
arg5_1 = 4
arg6_1 = 64
arg7_1 = rand_strided((256, 256), (256, 1), device='cuda:0', dtype=torch.float32)
arg8_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg9_1 = rand_strided((256, 256), (256, 1), device='cuda:0', dtype=torch.float32)
arg10_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg11_1 = rand_strided((256, 256), (256, 1), device='cuda:0', dtype=torch.float32)
arg12_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg13_1 = 64
arg14_1 = rand_strided((256, 256), (256, 1), device='cuda:0', dtype=torch.float32)
arg15_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg16_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg17_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
arg18_1 = rand_strided((512, 256), (256, 1), device='cuda:0', dtype=torch.float32)
arg19_1 = rand_strided((512, ), (1, ), device='cuda:0', dtype=torch.float32)
arg20_1 = 136
arg21_1 = 136
arg22_1 = rand_strided((18496, 1, 256), (256, 256, 1), device='cuda:0', dtype=torch.float32)
arg23_1 = rand_strided((257, 256), (256, 1), device='cuda:0', dtype=torch.float32)
arg24_1 = rand_strided((257, ), (1, ), device='cuda:0', dtype=torch.float32)
arg25_1 = rand_strided((256, 256), (256, 1), device='cuda:0', dtype=torch.float32)
arg26_1 = rand_strided((256, ), (1, ), device='cuda:0', dtype=torch.float32)
fn = lambda: call([arg0_1, arg1_1, arg2_1, arg3_1, arg4_1, arg5_1, arg6_1, arg7_1, arg8_1, arg9_1, arg10_1, arg11_1, arg12_1, arg13_1, arg14_1, arg15_1, arg16_1, arg17_1, arg18_1, arg19_1, arg20_1, arg21_1, arg22_1, arg23_1, arg24_1, arg25_1, arg26_1])
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)