|
| 1 | +## RGG Random Graph Generator |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +### Execution |
| 6 | + |
| 7 | +For each random model RGG passes through steps: |
| 8 | + |
| 9 | + - Generate random model for specific random_seed |
| 10 | + - Verify model via verify_module |
| 11 | + |
| 12 | +Source code of each randomly generated model with a pytest function can be automatically stored in a folder, ex `test/random_tests/` if configured. |
| 13 | + |
| 14 | +## Run |
| 15 | + |
| 16 | +Entrypoint for RGG pytests is in `test_graphs.py` module |
| 17 | + |
| 18 | +Example command for running Forge RGG tests generated via random graph algorithm |
| 19 | + |
| 20 | +```shell |
| 21 | +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 |
| 22 | +``` |
| 23 | + |
| 24 | +Example command for running PyTorch RGG tests generated via random graph algorithm |
| 25 | + |
| 26 | +```shell |
| 27 | +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 |
| 28 | +``` |
| 29 | + |
| 30 | + |
| 31 | +## Helper scripts |
| 32 | + |
| 33 | +To start interacting with RGG tests load helper commands via |
| 34 | + |
| 35 | +```sh |
| 36 | +source forge/test/random/test_commands.sh |
| 37 | +``` |
| 38 | + |
| 39 | +Available commands |
| 40 | + |
| 41 | +| Command | Description | |
| 42 | +| --------------------- | --------------------------------------------------------------------- | |
| 43 | +| `print_help` | Print commands and current query parameters. | |
| 44 | +| `print_query_docs` | Print docs for all available query parameters. | |
| 45 | +| `print_params` | Print current query parameters values. | |
| 46 | +| `select_test_graphs` | Select test_graps pytest function. | |
| 47 | +| `pytest` | Run all tests specfied via a query parameters. | |
| 48 | +| `with-params pytest` | Print params before and after test run. | |
| 49 | + |
| 50 | +Usage examples |
| 51 | + |
| 52 | +Run 5 tests for PYTHORCH framework |
| 53 | + |
| 54 | +```sh |
| 55 | +RANDOM_TEST_COUNT=5 FRAMEWORKS=PYTORCH with-params pytest |
| 56 | +``` |
| 57 | + |
| 58 | + |
| 59 | +## Configuration |
| 60 | + |
| 61 | +Configuration of RGG is supported via `RandomizerConfig` |
| 62 | + |
| 63 | +Parameters includes configuration of: |
| 64 | + |
| 65 | + - framework |
| 66 | + - number of tests |
| 67 | + - number of nodes |
| 68 | + - min and max size of an operand dimension |
| 69 | + - ... |
| 70 | + |
| 71 | +For more details about configuration please take a look at `forge/test/random/rgg/config.py`. |
| 72 | + |
| 73 | +Please refer to full list of supported enviroment variables in [README.debug.md](../README.debug.md) |
| 74 | + |
| 75 | +*Test specific environment variables that can be used to fine tune default behavior of Forge RGG tests.* |
| 76 | + |
| 77 | +## Parameters |
| 78 | + |
| 79 | +Full list of supported query parameters |
| 80 | + |
| 81 | +| Parameter | Description | Supported values | Default | |
| 82 | +| ----------------------------- | ----------------------------------------------------------------- | ----------------------------- | --------------------- | |
| 83 | +| FRAMEWORKS | List of frameworks. | PYTORCH, FORGE | | |
| 84 | +| ALGORITHMS | List of algorithms. | RANDOM | RANDOM | |
| 85 | +| CONFIGS | List of config names. | DEFAULT, UNSTABLE, ... | DEFAULT | |
| 86 | +| RANDOM\_TEST\_SEED | Initial seed for RGG. | | 0 | |
| 87 | +| 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 | |
| 88 | +| 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. | |
| 89 | +| VERIFICATION\_TIMEOUT | Limit time for inference verification in seconds. | | 60 | |
| 90 | +| MIN\_DIM | Minimal number of dimensions of input tensors. | | 3 | |
| 91 | +| MAX\_DIM | Maximum number of dimensions of input tensors. | | 4 | |
| 92 | +| MIN\_OP\_SIZE\_PER\_DIM | Minimal size of an operand dimension. | | 16 | |
| 93 | +| MAX\_OP\_SIZE\_PER\_DIM | Maximum size of an operand dimension. Smaller operand size results in fewer failed tests. | | 512 | |
| 94 | +| OP\_SIZE\_QUANTIZATION | Quantization factor for operand size. | | 1 | |
| 95 | +| MIN_MICROBATCH_SIZE | Minimal size of microbatch of an input tensor. | | 1 | |
| 96 | +| MAX_MICROBATCH_SIZE | Maximum size of microbatch of an input tensor. | | 8 | |
| 97 | +| NUM\_OF\_NODES\_MIN | Minimal number of nodes to be generated by RGG. | | 5 | |
| 98 | +| NUM\_OF\_NODES\_MAX | Maximum number of nodes to be generated by RGG. | | 10 | |
| 99 | +| NUM\_OF\_FORK\_JOINS\_MAX | Maximum number of fork joins to be generated by random graph algorithm in RGG. | | 50 | |
| 100 | +| CONSTANT\_INPUT\_RATE | Rate of constant inputs in RGG in percents. | | 50 | |
| 101 | +| SAME\_INPUTS\_PERCENT\_LIMIT | Percent limit of nodes which have same value on multiple inputes. | | 10 | |
| 102 | + |
| 103 | + |
| 104 | +Test configuration parameters |
| 105 | + |
| 106 | +| Parameter | Description | |
| 107 | +| ------------------------- | --------------------------------------------------------------------------------------------- | |
| 108 | +| SKIP_FORGE_VERIFICATION | Skip Forge model verification including model compiling and inference | |
| 109 | + |
| 110 | + |
| 111 | +## Development |
| 112 | + |
| 113 | +Entrypoint for RGG impplementation is `process_test` module |
| 114 | + |
| 115 | +Parameters of process_test pytest: |
| 116 | + |
| 117 | + - test_index - index of a test |
| 118 | + - random_seed - random seed of a test |
| 119 | + - test_device - target test device |
| 120 | + - randomizer_config - test configation parameters |
| 121 | + - graph_builder_type - algorithm |
| 122 | + - framework - target framework |
0 commit comments