Skip to content

Commit

Permalink
Add new ttnn sweeps (#13239)
Browse files Browse the repository at this point in the history
* #11512: Add log_sigmoid and logical_not_sweeps

* #11512: Add sweeps to workflow

* #11512: Add new sweeps logaddexp and lgamma

* #11512: Add new sweeps logaddexp and lgamma

* #11512: Add new sweeps ldexp

* #11512: Add erf sweep tests

* #11512: Add erfinv sweeps

* #11512: Update run nightly pipline

* #11512: Add hypot and i0 sweeps

* #11512: Add run config for sweeps

* #11512: Add sigmoid and sigmoid_accurate tests

* #11512: Add glu and silu

* #11512: Fix run config

* #11512: Fix suites

---------

Co-authored-by: “Nenad <“[email protected]”>
  • Loading branch information
npetrovic-tenstorrent and “Nenad authored Oct 3, 2024
1 parent a4a9a4c commit 844ca1c
Show file tree
Hide file tree
Showing 14 changed files with 1,002 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ttnn-run-sweeps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ on:
- eltwise.unary.bitwise.bitwise_or
- eltwise.unary.bitwise.bitwise_right_shift
- eltwise.unary.bitwise.bitwise_xor
- eltwise.unary.log_sigmoid.log_sigmoid
- eltwise.unary.logical_not_.logical_not_
- eltwise.unary.erf.erf
- eltwise.unary.erfinv.erfinv
- eltwise.unary.i0.i0
- eltwise.unary.silu.silu
- eltwise.unary.glu.glu
- eltwise.unary.lgamma.lgamma
- eltwise.unary.sigmoid.sigmoid
- eltwise.unary.sigmoid_accurate.sigmoid_accurate
- eltwise.binary.subtract.subtract
- eltwise.binary.multiply.multiply
- eltwise.binary.div.div
Expand All @@ -56,6 +66,9 @@ on:
- eltwise.binary.bcast.bcast_h_sharded
- eltwise.binary.bcast.bcast
- eltwise.binary.fmod.fmod
- eltwise.binary.logaddexp.logaddexp
- eltwise.binary.ldexp.ldexp
- eltwise.binary.hypot.hypot
- eltwise.composite.binary.addalpha.addalpha
- eltwise.composite.binary.subalpha.subalpha
- eltwise.composite.binary.minimum.minimum
Expand Down
86 changes: 86 additions & 0 deletions tests/sweep_framework/sweeps/eltwise/binary/hypot/hypot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

from typing import Optional, Tuple
from functools import partial

import torch
import random
import ttnn
from tests.sweep_framework.utils import gen_shapes
from tests.tt_eager.python_api_testing.sweep_tests.generation_funcs import gen_func_with_cast_tt

from tests.ttnn.utils_for_testing import check_with_pcc, start_measuring_time, stop_measuring_time
from models.utility_functions import torch_random

# Override the default timeout in seconds for hang detection.
TIMEOUT = 30

random.seed(0)

# Parameters provided to the test vector generator are defined here.
# They are defined as dict-type suites that contain the arguments to the run function as keys, and lists of possible inputs as values.
# Each suite has a key name (in this case "suite_1") which will associate the test vectors to this specific suite of inputs.
# Developers can create their own generator functions and pass them to the parameters as inputs.
parameters = {
"xfail": {
"input_shape": gen_shapes([1, 1, 32, 32], [6, 12, 256, 256], [1, 1, 32, 32], 16)
+ gen_shapes([1, 32, 32], [12, 256, 256], [1, 32, 32], 16)
+ gen_shapes([32, 32], [256, 256], [32, 32], 16),
"input_a_dtype": [ttnn.bfloat16, ttnn.bfloat8_b],
"input_b_dtype": [ttnn.bfloat16, ttnn.bfloat8_b],
"input_a_layout": [ttnn.TILE_LAYOUT],
"input_b_layout": [ttnn.TILE_LAYOUT],
"input_a_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
"input_b_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
},
}


# This is the run instructions for the test, defined by the developer.
# The run function must take the above-defined parameters as inputs.
# The runner will call this run function with each test vector, and the returned results from this function will be stored.
# If you defined a device_mesh_fixture above, the object you yielded will be passed into this function as 'device'. Otherwise, it will be the default ttnn device opened by the infra.
def run(
input_shape,
input_a_dtype,
input_b_dtype,
input_a_layout,
input_b_layout,
input_a_memory_config,
input_b_memory_config,
*,
device,
) -> list:
data_seed = random.randint(0, 20000000)
torch.manual_seed(data_seed)

torch_input_tensor_a = gen_func_with_cast_tt(
partial(torch_random, low=-100, high=100, dtype=torch.float32), input_a_dtype
)(input_shape)
torch_input_tensor_b = gen_func_with_cast_tt(
partial(torch_random, low=-100, high=100, dtype=torch.float32), input_b_dtype
)(input_shape)
torch_output_tensor = torch.hypot(torch_input_tensor_a, torch_input_tensor_b)

input_tensor_a = ttnn.from_torch(
torch_input_tensor_a,
dtype=input_a_dtype,
layout=input_a_layout,
device=device,
memory_config=input_a_memory_config,
)
input_tensor_b = ttnn.from_torch(
torch_input_tensor_b,
dtype=input_b_dtype,
layout=input_b_layout,
device=device,
memory_config=input_b_memory_config,
)
start_time = start_measuring_time()
result = ttnn.hypot(input_tensor_a, input_tensor_b)
output_tensor = ttnn.to_torch(result)
e2e_perf = stop_measuring_time(start_time)

return [check_with_pcc(torch_output_tensor, output_tensor, 0.999), e2e_perf]
86 changes: 86 additions & 0 deletions tests/sweep_framework/sweeps/eltwise/binary/ldexp/ldexp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

from typing import Optional, Tuple
from functools import partial

import torch
import random
import ttnn
from tests.sweep_framework.utils import gen_shapes
from tests.tt_eager.python_api_testing.sweep_tests.generation_funcs import gen_func_with_cast_tt

from tests.ttnn.utils_for_testing import check_with_pcc, start_measuring_time, stop_measuring_time
from models.utility_functions import torch_random

# Override the default timeout in seconds for hang detection.
TIMEOUT = 30

random.seed(0)

# Parameters provided to the test vector generator are defined here.
# They are defined as dict-type suites that contain the arguments to the run function as keys, and lists of possible inputs as values.
# Each suite has a key name (in this case "suite_1") which will associate the test vectors to this specific suite of inputs.
# Developers can create their own generator functions and pass them to the parameters as inputs.
parameters = {
"nightly": {
"input_shape": gen_shapes([1, 1, 32, 32], [6, 12, 256, 256], [1, 1, 32, 32], 16)
+ gen_shapes([1, 32, 32], [12, 256, 256], [1, 32, 32], 16)
+ gen_shapes([32, 32], [256, 256], [32, 32], 16),
"input_a_dtype": [ttnn.bfloat16, ttnn.bfloat8_b],
"input_b_dtype": [ttnn.bfloat16, ttnn.bfloat8_b],
"input_a_layout": [ttnn.TILE_LAYOUT],
"input_b_layout": [ttnn.TILE_LAYOUT],
"input_a_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
"input_b_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
},
}


# This is the run instructions for the test, defined by the developer.
# The run function must take the above-defined parameters as inputs.
# The runner will call this run function with each test vector, and the returned results from this function will be stored.
# If you defined a device_mesh_fixture above, the object you yielded will be passed into this function as 'device'. Otherwise, it will be the default ttnn device opened by the infra.
def run(
input_shape,
input_a_dtype,
input_b_dtype,
input_a_layout,
input_b_layout,
input_a_memory_config,
input_b_memory_config,
*,
device,
) -> list:
data_seed = random.randint(0, 20000000)
torch.manual_seed(data_seed)

torch_input_tensor_a = gen_func_with_cast_tt(
partial(torch_random, low=-10, high=10, dtype=torch.float32), input_a_dtype
)(input_shape)
torch_input_tensor_b = gen_func_with_cast_tt(
partial(torch_random, low=-10, high=10, dtype=torch.float32), input_b_dtype
)(input_shape)
torch_output_tensor = torch.ldexp(torch_input_tensor_a, torch_input_tensor_b)

input_tensor_a = ttnn.from_torch(
torch_input_tensor_a,
dtype=input_a_dtype,
layout=input_a_layout,
device=device,
memory_config=input_a_memory_config,
)
input_tensor_b = ttnn.from_torch(
torch_input_tensor_b,
dtype=input_b_dtype,
layout=input_b_layout,
device=device,
memory_config=input_b_memory_config,
)
start_time = start_measuring_time()
result = ttnn.ldexp(input_tensor_a, input_tensor_b)
output_tensor = ttnn.to_torch(result)
e2e_perf = stop_measuring_time(start_time)

return [check_with_pcc(torch_output_tensor, output_tensor, 0.999), e2e_perf]
86 changes: 86 additions & 0 deletions tests/sweep_framework/sweeps/eltwise/binary/logaddexp/logaddexp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

from typing import Optional, Tuple
from functools import partial

import torch
import random
import ttnn
from tests.sweep_framework.utils import gen_shapes
from tests.tt_eager.python_api_testing.sweep_tests.generation_funcs import gen_func_with_cast_tt

from tests.ttnn.utils_for_testing import check_with_pcc, start_measuring_time, stop_measuring_time
from models.utility_functions import torch_random

# Override the default timeout in seconds for hang detection.
TIMEOUT = 30

random.seed(0)

# Parameters provided to the test vector generator are defined here.
# They are defined as dict-type suites that contain the arguments to the run function as keys, and lists of possible inputs as values.
# Each suite has a key name (in this case "suite_1") which will associate the test vectors to this specific suite of inputs.
# Developers can create their own generator functions and pass them to the parameters as inputs.
parameters = {
"nightly": {
"input_shape": gen_shapes([1, 1, 32, 32], [6, 12, 256, 256], [1, 1, 32, 32], 16)
+ gen_shapes([1, 32, 32], [12, 256, 256], [1, 32, 32], 16)
+ gen_shapes([32, 32], [256, 256], [32, 32], 16),
"input_a_dtype": [ttnn.bfloat16, ttnn.bfloat8_b],
"input_b_dtype": [ttnn.bfloat16, ttnn.bfloat8_b],
"input_a_layout": [ttnn.TILE_LAYOUT],
"input_b_layout": [ttnn.TILE_LAYOUT],
"input_a_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
"input_b_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
},
}


# This is the run instructions for the test, defined by the developer.
# The run function must take the above-defined parameters as inputs.
# The runner will call this run function with each test vector, and the returned results from this function will be stored.
# If you defined a device_mesh_fixture above, the object you yielded will be passed into this function as 'device'. Otherwise, it will be the default ttnn device opened by the infra.
def run(
input_shape,
input_a_dtype,
input_b_dtype,
input_a_layout,
input_b_layout,
input_a_memory_config,
input_b_memory_config,
*,
device,
) -> list:
data_seed = random.randint(0, 20000000)
torch.manual_seed(data_seed)

torch_input_tensor_a = gen_func_with_cast_tt(
partial(torch_random, low=-64, high=64, dtype=torch.float32), input_a_dtype
)(input_shape)
torch_input_tensor_b = gen_func_with_cast_tt(
partial(torch_random, low=-64, high=64, dtype=torch.float32), input_b_dtype
)(input_shape)
torch_output_tensor = torch.logaddexp(torch_input_tensor_a, torch_input_tensor_b)

input_tensor_a = ttnn.from_torch(
torch_input_tensor_a,
dtype=input_a_dtype,
layout=input_a_layout,
device=device,
memory_config=input_a_memory_config,
)
input_tensor_b = ttnn.from_torch(
torch_input_tensor_b,
dtype=input_b_dtype,
layout=input_b_layout,
device=device,
memory_config=input_b_memory_config,
)
start_time = start_measuring_time()
result = ttnn.logaddexp(input_tensor_a, input_tensor_b)
output_tensor = ttnn.to_torch(result)
e2e_perf = stop_measuring_time(start_time)

return [check_with_pcc(torch_output_tensor, output_tensor, 0.999), e2e_perf]
73 changes: 73 additions & 0 deletions tests/sweep_framework/sweeps/eltwise/unary/erf/erf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# SPDX-FileCopyrightText: © 2024 Tenstorrent Inc.

# SPDX-License-Identifier: Apache-2.0

from typing import Optional, Tuple
from functools import partial

import torch
import random
import ttnn
from tests.sweep_framework.utils import gen_shapes
from tests.tt_eager.python_api_testing.sweep_tests.generation_funcs import gen_func_with_cast_tt

from tests.ttnn.utils_for_testing import check_with_pcc, start_measuring_time, stop_measuring_time
from models.utility_functions import torch_random

# Override the default timeout in seconds for hang detection.
TIMEOUT = 30

random.seed(0)

# Parameters provided to the test vector generator are defined here.
# They are defined as dict-type suites that contain the arguments to the run function as keys, and lists of possible inputs as values.
# Each suite has a key name (in this case "suite_1") which will associate the test vectors to this specific suite of inputs.
# Developers can create their own generator functions and pass them to the parameters as inputs.
parameters = {
"nightly": {
"input_shape": gen_shapes([1, 1, 32, 32], [6, 12, 256, 256], [1, 1, 32, 32], 16)
+ gen_shapes([1, 32, 32], [12, 256, 256], [1, 32, 32], 16)
+ gen_shapes([32, 32], [256, 256], [32, 32], 32),
"input_a_dtype": [ttnn.bfloat16, ttnn.bfloat8_b],
"input_a_layout": [ttnn.TILE_LAYOUT],
"input_a_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
"output_memory_config": [ttnn.DRAM_MEMORY_CONFIG, ttnn.L1_MEMORY_CONFIG],
},
}


# This is the run instructions for the test, defined by the developer.
# The run function must take the above-defined parameters as inputs.
# The runner will call this run function with each test vector, and the returned results from this function will be stored.
# If you defined a device_mesh_fixture above, the object you yielded will be passed into this function as 'device'. Otherwise, it will be the default ttnn device opened by the infra.
def run(
input_shape,
input_a_dtype,
input_a_layout,
input_a_memory_config,
output_memory_config,
*,
device,
) -> list:
data_seed = random.randint(0, 20000000)
torch.manual_seed(data_seed)

torch_input_tensor_a = gen_func_with_cast_tt(
partial(torch_random, low=-100, high=100, dtype=torch.float16), input_a_dtype
)(input_shape)
torch_output_tensor = torch.erf(torch_input_tensor_a)

input_tensor_a = ttnn.from_torch(
torch_input_tensor_a,
dtype=input_a_dtype,
layout=input_a_layout,
device=device,
memory_config=input_a_memory_config,
)

start_time = start_measuring_time()
result = ttnn.erf(input_tensor_a, memory_config=output_memory_config)
output_tensor = ttnn.to_torch(result)
e2e_perf = stop_measuring_time(start_time)

return [check_with_pcc(torch_output_tensor, output_tensor, 0.999), e2e_perf]
Loading

0 comments on commit 844ca1c

Please sign in to comment.