Tutorials

Common Usage Examples

Interactive Usage with Python

You can directly import MASE as a package using import mase after installation

The MASE Command Line System

MASE supported a range of actions (eg. train, test, transform …), these are designed to help you to quickly spin things in your command line without touching the source code.

For simplicity, we summarized the following commands for you to quickly start with MASE Command Line System:

# Basic training and testing
## training
./ch train jsc-tiny jsc --max-epochs 3 --batch-size 256 --accelerator cpu --project tmp --debug
## test
./ch test jsc-tiny jsc --accelerator cpu --debug --load ../mase_output/tmp/software/training_ckpts/best.ckpt --load-type pl

# Graph-level
## transfrom on graph level
./ch transform --config $MASE/configs/examples/jsc_toy_by_type.toml --task cls --accelerator=cpu --load ../mase_output/tmp/software/training_ckpts/best.ckpt --load-type pl
## search command
./ch search --config $MASE/configs/examples/jsc_toy_by_type.toml --task cls --accelerator=cpu --load ../mase_output/tmp/software/training_ckpts/best.ckpt --load-type pl
## train searched network
./ch train jsc-tiny jsc --max-epochs 3 --batch-size 256 --accelerator cpu --project tmp --debug --load ../mase_output/jsc-tiny/software/transform/transformed_ckpt/graph_module.mz --load-type mz

# Module-level
## transfrom on module level
./ch transform --config $MASE/configs/examples/jsc_toy_by_type_module.toml --task cls --accelerator=cpu --load ../mase_output/tmp/software/training_ckpts/best.ckpt --load-type pl
## train the transformed network
./ch train jsc-tiny jsc --max-epochs 3 --batch-size 256 --accelerator cpu --project tmp --debug --load ../mase_output/jsc-tiny/software/transform/transformed_ckpt/state_dict.pt --load-type pt

The MASE Pass System

One specific feature of MASE is its capability to transform DL models to a computation graph and apply analysis or transformation passes on the graph.

In MASE, we support two granularities on these passes, namely module level and graph level:

  • module level passes: this only provides coarse-grained control over any torch.nn.Module in the model. We refer this as Module Passes.

  • graph level passes: this provides fine-grained control over the computation graph of the model using the torch.fx framework. This also nessitates the use of torch.fx to represent the computation graph. We provide a set of APIs to convert a model to a MASEGraph, starting from the Notebook.

These tutorials will guide you through the process of creating and applying passes.

Advanced Topics