.. _quickstart-kpi: Quickstart with KPI Prediction =================================== To get started, first make sure that: * MLSimKit is :ref:`installed ` We'll use a sample dataset to quickly show you an end-to-end workflow. KPI Prediction (KPI) is accessed via the ``mlsimkit-learn kpi`` command: .. code-block:: shell Usage: mlsimkit-learn kpi [OPTIONS] COMMAND1 [ARGS]... [COMMAND2 [ARGS]...]... Use Case: KPI prediction using a variant of Mesh Graph Networks (MGN) Options: --manifest-uri PATH Manifest file to drive all subcommands. Searches mlsimkit/datasets as a fallback --help Show this message and exit. Commands: predict preprocess train To run KPI commands, you may provide a config only or override the config with command-line arguments by running: .. code-block:: shell mlsimkit-learn --config kpi You can use the ``help`` command to see the definitions of all the hyperparameters associated with any command. For example, the following command will display all hyperparameters for training: .. code-block:: shell mlsimkit-learn kpi train --help Sample Dataset ------------------------ There is a sample config and a very small sample dataset called "drivaer-sample" so you can run end-to-end quickly: .. code-block:: shell src/mlsimkit/conf └── kpi └── sample.yaml src/mlsimkit/datasets ├── ... └── drivaer-sample ├── downsampled_stls └── kpi.manifest External Datasets ------------------------ In addition to the sample dataset, there are tutorials to get started with publicly available datasets:: tutorials/ └── kpi ├── ahmed/ ├── drivaer/ (coming soon) ├── sample/ └── windsor/ Run the Sample -------------- First, make a folder for all the outputs. Replace ``--output-dir quickstart/kpi`` in the command below with your own folder location. Second, run the entire train-predict pipeline to make predictions on the sample data using CPU-only: .. code-block:: shell mlsimkit-learn --output-dir quickstart/kpi \ --config src/mlsimkit/conf/kpi/sample.yaml \ kpi preprocess train --device cpu predict Also, note that commands can be chained together. For example, the above runs `preprocess`, `train`, and then `predict`. Running on GPU ~~~~~~~~~~~~~~ MLSimKit automatically uses a GPU by default. To use your GPU, remove ``--device cpu`` from the previous command and run again: .. code-block:: shell mlsimkit-learn --output-dir quickstart/kpi \ --config src/mlsimkit/conf/kpi/sample.yaml \ kpi preprocess train predict .. note:: On older MacOS hardware, you may see the error ``Cannot convert a MPS Tensor to float64 dtype``. If so, force CPU by specifying ``--device cpu`` for train commands. In general, please see the :ref:`Troubleshooting ` guide for possible errors if commands do not work. All artifacts are written into the output directory ``--output-dir``. You may also set the output directory in the config file. Commands automatically share paths to the output artifacts such as the train model path. The sample configuration below sets some input options but most options use defaults. There are many options, which we go into detail after the quickstart. The sample configuration ``conf/kpi/sample.yaml`` looks like this: .. code-block:: yaml kpi: manifest_uri: drivaer-sample/kpi.manifest train: epochs: 10 batch_size: 1 .. note:: A manifest (``manifest_uri``) describes the paths to a dataset and is used to share data between tasks. For now, know that ``kpi.manifest`` references a small dataset packaged with MLSimKit. You will see console logs for all three commands, something like below. File artifacts are written to the ``--output-dir``. .. code-block:: shell [INFO] [MLSimKit] Learning Tools [INFO] Package Version: 0.2.3.dev3+gaf49957.d20240808 [INFO] Use Case: KPI prediction via a variant of MeshGraphNets [INFO] Running command 'preprocess' [INFO] Preprocessing configuration: manifest_path='/home/ubuntu/mlsimkit/src/mlsimkit/datasets/drivaer-sample/kpi.manifest' output_dir='/home/ubuntu/mlsimkit/quickstart/kpi/preprocessed_data' downsample_remaining_perc=None num_processes=None manifest_base_relative_path= [INFO] Preprocessing mesh files (num_processes=95) [INFO] Pre-processing file 1 out of 7 files [INFO] Pre-processing file 2 out of 7 files [INFO] Pre-processing file 3 out of 7 files [INFO] Pre-processing file 4 out of 7 files [INFO] Pre-processing file 5 out of 7 files [INFO] Pre-processing file 6 out of 7 files [INFO] Pre-processing file 7 out of 7 files [INFO] Saved output files in /home/ubuntu/mlsimkit/quickstart/kpi/preprocessed_data [INFO] Manifest '/home/ubuntu/mlsimkit/quickstart/kpi/kpi-copy.manifest' written (7 records) [INFO] Total preprocessing time: 2.036 seconds [INFO] Splitting manifest into train-size=0.6 valid-size=0.2 test-size=0.2 [INFO] Manifest '/home/ubuntu/mlsimkit/quickstart/kpi/train.manifest' written (4 records) [INFO] Manifest '/home/ubuntu/mlsimkit/quickstart/kpi/validate.manifest' written (1 records) [INFO] Manifest '/home/ubuntu/mlsimkit/quickstart/kpi/test.manifest' written (2 records) [INFO] Running command 'train' ... [INFO] Training state configuration: {"Distributed": "no", "Num processes": 1, "Process index": 0, "Local process index": 0, "Device": "cuda", "Mixed precision": "no"} [INFO] Training started for 'model' [INFO] Train dataset size: 4 [INFO] Validation dataset size: 1 [INFO] Training: 0%| | 0/10 [00:00