-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RGG implementation RGG documentation Reformat RGG code Removed global compiler config DepricatedVerifyConfig Use common forge verification Move random seed logic to test_graphs Rename PyBuda to Forge Single RGG pytest test_commands for rgg
- Loading branch information
Showing
19 changed files
with
2,732 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC | ||
|
||
# SPDX-License-Identifier: Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
## RGG Random Graph Generator | ||
|
||
Random Graph Generator supports testing of randomly generated graphs. Tests based on RGG can be triggered as regular pytests and executed in a single run of pytest. Tests are performed as a bulk operation for the specified number of tests. | ||
|
||
### Execution | ||
|
||
For each random model RGG passes through steps: | ||
|
||
- Generate random model for specific random_seed | ||
- Verify model via verify_module | ||
|
||
Source code of each randomly generated model with a pytest function can be automatically stored in a folder, ex `test/random_tests/` if configured. | ||
|
||
## Run | ||
|
||
Entrypoint for RGG pytests is in `test_graphs.py` module | ||
|
||
Example command for running Forge RGG tests generated via random graph algorithm | ||
|
||
```shell | ||
LOGURU_LEVEL=DEBUG FRAMEWORKS=FORGE RANDOM_TEST_SEED=0 RANDOM_TEST_COUNT=5 VERIFICATION_TIMEOUT=60 MIN_DIM=3 MAX_DIM=4 MIN_OP_SIZE_PER_DIM=16 MAX_OP_SIZE_PER_DIM=64 OP_SIZE_QUANTIZATION=1 MIN_MICROBATCH_SIZE=1 MAX_MICROBATCH_SIZE=8 NUM_OF_NODES_MIN=5 NUM_OF_NODES_MAX=10 NUM_OF_FORK_JOINS_MAX=5 CONSTANT_INPUT_RATE=20 SAME_INPUTS_PERCENT_LIMIT=10 pytest -svv forge/test/random/test_graphs.py::test_random_graph_algorithm | ||
``` | ||
|
||
Example command for running PyTorch RGG tests generated via random graph algorithm | ||
|
||
```shell | ||
LOGURU_LEVEL=DEBUG FRAMEWORKS=PYTORCH RANDOM_TEST_SEED=0 RANDOM_TEST_COUNT=5 VERIFICATION_TIMEOUT=60 MIN_DIM=4 MAX_DIM=4 MIN_OP_SIZE_PER_DIM=4 MAX_OP_SIZE_PER_DIM=8 OP_SIZE_QUANTIZATION=1 MIN_MICROBATCH_SIZE=1 MAX_MICROBATCH_SIZE=1 NUM_OF_NODES_MIN=3 NUM_OF_NODES_MAX=5 NUM_OF_FORK_JOINS_MAX=5 CONSTANT_INPUT_RATE=20 SAME_INPUTS_PERCENT_LIMIT=10 pytest -svv forge/test/random/test_graphs.py::test_random_graph_algorithm | ||
``` | ||
|
||
## Configuration | ||
|
||
Configuration of RGG is supported via `RandomizerConfig` | ||
|
||
Parameters includes configuration of: | ||
|
||
- framework | ||
- number of tests | ||
- number of nodes | ||
- min and max size of an operand dimension | ||
- ... | ||
|
||
For more details about configuration please take a look at `forge/test/random/rgg/config.py`. | ||
|
||
Please refer to full list of supported enviroment variables in [README.debug.md](../README.debug.md) | ||
|
||
*Test specific environment variables that can be used to fine tune default behavior of Forge RGG tests.* | ||
|
||
## Parameters | ||
|
||
|
||
| Parameter | Description | Supported values | Default | | ||
| ----------------------------- | ----------------------------------------------------------------- | ----------------------------- | --------------------- | | ||
| FRAMEWORKS | List of frameworks. | PYTORCH, FORGE | | | ||
| TEST_NAMES | List of test names. | NARY, FORK JOINS, DEFAULT | DEFAULT | | ||
| RANDOM\_TEST\_SEED | Initial seed for RGG. | | 0 | | ||
| RANDOM\_TEST\_COUNT | Number of random tests to be generated and executed. The parameter generate test_index in range from 0 to RANDOM\_TEST\_COUNT-1. | | 5 | | ||
| RANDOM\_TESTS\_SELECTED | Limiting random tests to only selected subset defined as comma separated list of test indexes. E.x. "3,4,6" | | Default is no limitation if not specified or empty. | | ||
| VERIFICATION\_TIMEOUT | Limit time for inference verification in seconds. | | 60 | | ||
| MIN\_DIM | Minimal number of dimensions of input tensors. | | 3 | | ||
| MAX\_DIM | Maximum number of dimensions of input tensors. | | 4 | | ||
| MIN\_OP\_SIZE\_PER\_DIM | Minimal size of an operand dimension. | | 16 | | ||
| MAX\_OP\_SIZE\_PER\_DIM | Maximum size of an operand dimension. Smaller operand size results in fewer failed tests. | | 512 | | ||
| OP\_SIZE\_QUANTIZATION | Quantization factor for operand size. | | 1 | | ||
| MIN_MICROBATCH_SIZE | Minimal size of microbatch of an input tensor. | | 1 | | ||
| MAX_MICROBATCH_SIZE | Maximum size of microbatch of an input tensor. | | 8 | | ||
| NUM\_OF\_NODES\_MIN | Minimal number of nodes to be generated by RGG. | | 5 | | ||
| NUM\_OF\_NODES\_MAX | Maximum number of nodes to be generated by RGG. | | 10 | | ||
| NUM\_OF\_FORK\_JOINS\_MAX | Maximum number of fork joins to be generated by random graph algorithm in RGG. | | 50 | | ||
| CONSTANT\_INPUT\_RATE | Rate of constant inputs in RGG in percents. | | 50 | | ||
| SAME\_INPUTS\_PERCENT\_LIMIT | Percent limit of nodes which have same value on multiple inputes. | | 10 | | ||
|
||
|
||
## Development | ||
|
||
Entrypoint for RGG impplementation is `process_test` module | ||
|
||
Parameters of process_test pytest: | ||
|
||
- test_index - index of a test | ||
- random_seed - random seed of a test | ||
- test_device - target test device | ||
- randomizer_config - test configation parameters | ||
- graph_builder_type - algorithm | ||
- framework - target framework |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# SPDX-FileCopyrightText: © 2024 Tenstorrent AI ULC | ||
|
||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
from .datatypes import TensorShape | ||
from .datatypes import RandomizerConstantNode | ||
from .datatypes import ( | ||
RandomizerInputNode, | ||
RandomizerNode, | ||
ExecutionContext, | ||
RandomizerParameters, | ||
RandomizerGraph, | ||
RandomizerConfig, | ||
) | ||
from .datatypes import NodeShapeCalculationContext | ||
from .datatypes import RandomizerTestContext | ||
from .datatypes import ModelBuilder, Framework | ||
from .config import get_randomizer_config_default | ||
from .utils import StrUtils, GraphUtils | ||
from .utils import DebugUtils | ||
from .base import GraphBuilder | ||
from .base import RandomizerRunner, RandomizerCodeGenerator, process_test | ||
from .frameworks import Frameworks | ||
from .frameworks import FrameworkTestUtils | ||
from .algorithms import GraphNodeSetup | ||
from .algorithms import RandomGraphAlgorithm | ||
|
||
__all__ = [ | ||
"TensorShape", | ||
"RandomizerConstantNode", | ||
"RandomizerInputNode", | ||
"RandomizerNode", | ||
"ExecutionContext", | ||
"RandomizerParameters", | ||
"RandomizerGraph", | ||
"RandomizerConfig", | ||
"NodeShapeCalculationContext", | ||
"RandomizerTestContext", | ||
"ModelBuilder", | ||
"Framework", | ||
"get_randomizer_config_default", | ||
"StrUtils", | ||
"GraphUtils", | ||
"DebugUtils", | ||
"Framework", | ||
"GraphBuilder", | ||
"RandomizerRunner", | ||
"RandomizerCodeGenerator", | ||
"process_test", | ||
"Frameworks", | ||
"FrameworkTestUtils", | ||
"GraphNodeSetup", | ||
"RandomGraphAlgorithm", | ||
] |
Oops, something went wrong.