一键导入
workflow
Full workflow: environment setup, running experiments, reusing and implementing new components (models, datasets, plmodules, callbacks), and testing
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Full workflow: environment setup, running experiments, reusing and implementing new components (models, datasets, plmodules, callbacks), and testing
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Git operations: branching, commit message format, pre-commit hook handling, and push policy
How to load a checkpoint and run evaluation (inference only, no training)
Reference code folder conventions — storing external code and documentation for AI-assisted development context
Coding style guidelines and common pitfalls for this project
Hydra configuration file structure and conventions for models, datasets, callbacks, and training
Data format conventions for datasets and plmodules
| name | workflow |
| description | Full workflow: environment setup, running experiments, reusing and implementing new components (models, datasets, plmodules, callbacks), and testing |
This document describes the full project workflow: environment setup, running experiments, reusing and implementing new components, and testing.
Important: Never commit or push directly to
main. All changes must go through a Pull Request. See thegitskill for details.
# consider adding "--index-url https://pypi.tuna.tsinghua.edu.cn/simple" if you have difficulty connecting to pypi.org
uv sync --extra cu118 # torch-cu118
uv sync --extra cu124 # torch-cu124
uv sync --extra cu126 # torch-cu126 (suggested)
uv sync --extra cu128 # torch-cu128
uv sync --extra cpu # torch-cpu
You can also put the above commands in your scripts so that the environment is activated and synced before each training. See examples in scripts_core.
conda create -n core python=3.11 -y && conda activate core # you can replace core with other names
We use pip for package installation:
pip install -r requirements/requirements-icon-core-cuda118.txt # for cuda 11.8
pip install -r requirements/requirements-icon-core-cuda124.txt # for cuda 12.4
Pre-commit hooks check code on every commit: enforcing formatting and avoiding mistakes like uploading private keys. If checks fail, hooks will try to auto-fix — amend the changes and commit again. If auto-fix doesn't work, manually adjust according to the error message.
Install once per local clone (strongly suggested before your first commit):
# uv
uv run pre-commit install # HTTPS
uv run pre-commit install --config requirements/.pre-commit-config-ssh.yaml # SSH
# conda (if not using uv)
conda activate your_env
pip install pre-commit # skip if already installed
pre-commit install # HTTPS
pre-commit install --config requirements/.pre-commit-config-ssh.yaml # SSH
Run on all files manually:
pre-commit run --all-files
Pre-commit hooks are also integrated in GitHub CI workflows (.github/workflows). To disable, delete that folder and run uv run pre-commit uninstall (or pre-commit uninstall).
sh scripts_core/cpu.sh
uv run python src/train.py --config-name=train_your_project
Machine-specific overrides can go in configs/train_custom.yaml (git-ignored):
defaults:
- train_your_project
- _self_
paths:
data_dir: ./project_data/
log_dir: ./project_logs/
If configs/train_custom.yaml exists, src/train.py reads it by default:
uv run python src/train.py # uses train_custom.yaml
uv run python src/train.py trainer.max_steps=10 # with overrides
configs/train_custom.yaml is git-ignored, so it is only effective on your machine. All configs will be logged (including those in configs/train_custom.yaml), so reproducibility is preserved. For better collaboration, only include insignificant machine-specific configs (e.g. paths) in this file.
This repository already contains a lot of components, including models, lightning modules, datasets, callbacks, etc. You should try to leverage them by reusing or inheriting from them in your project. Additionally, they serve as practical implementation references. Read them before implementing your own.
Do not modify files inherited from the core repository. These files start with a header in the beginning of the file:
#######################################################
# This file belongs to the core repository.
# If your project repository is a fork of core,
# you are suggested to keep this file untouched in your project.
# This helps avoid merge conflicts when syncing from core.
#######################################################
Other files are not part of the core repository and are free to modify. Do not add the header in your newly created files, so other developers can easily identify them.
When implementing new components, you generally need to implement both .py files and corresponding .yaml configuration files.
src/models/your_model_folder/your_model_file.py. Use subdirectories to organize models.configs/model/.src/plmodules/your_plmodule_file.py.configs/plmodule/.get_trainable_networks() (abstract method from BaseLitModule) to specify which network(s) should be optimized.src/datasets/your_dataset_folder/your_dataset_file.py.configs/data/your_dataset_folder/. In this folder, create train/, valid/, and test/ subfolders. For each training dataset, you should create a corresponding yaml file in train/ subfolder. You can have multiple yaml files for multiple training datasets. Similarly for validation and testing datasets. In the end, you should also create a main dataset yaml file configs/data/your_dataset_folder/your_dataset.yaml to list all training, validation, and testing datasets to be used in the project.src/datamodules/your_datamodule_file.py.configs/datamodule/.src/callbacks/your_callback_name.py.configs/callbacks/. See the configs skill for details on callback config conventions.Viz (src/callbacks/viz.py) and override get_image() rather than implementing from scratch.configs/train_project_name.yaml as the main configuration file for the project. This file will indicate what configurations to be used in the project, including models, datasets, callbacks, etc.scripts_project_name/ directory. Please see the scripts in scripts_core/ as references.Let's take the nop_rollout (neural operator with rollout) project as an example. This project demonstrates how to implement a complete neural operator training pipeline with rollout validation.
We use 1D FNO model, which is implemented in src/models/nop/fno.py. The corresponding configuration is in configs/model/fno1d.yaml.
The training and validation logic is implemented in src/plmodules/nop_rollout_lit_module.py, which inherits from BaseLitModule. The configuration is in configs/plmodule/nop_rollout.yaml.
We use the Kuramoto-Shivashinsky (KS) equation simulation dataset. The dataset is implemented in src/datasets/ks/ks.py. The corresponding configurations are in configs/data/ks/ folder. Note that we put the training, validation, and testing configurations in the train/, valid/, and test/ subfolders, and create a main dataset yaml file configs/data/ks/ks.yaml to list all training, validation, and testing datasets to be used in the project.
In this project, we use two validation datasets: ks_short and ks_long, for validating the model's performance on short-term and long-term predictions, respectively. Therefore we have two corresponding validation configurations in configs/data/ks/valid/ folder, and listed them in the main dataset yaml file configs/data/ks/ks.yaml.
We don't need new dataloader logic for this project, so we just reuse the existing BaseDataModule class.
We implement two callbacks in src/callbacks/viz_rollout_error.py and src/callbacks/viz_rollout_1d.py to visualize the rollout error and the rollout trajectory, respectively. Notably, we inherit from the Viz class in src/callbacks/viz.py for visualization.
We created two corresponding configuration files in configs/callbacks/ folder: viz_rollout_error.yaml and viz_rollout_1d.yaml, and listed them in the main callback yaml file configs/callbacks/many_callbacks_nop_rollout.yaml, together with other existing callback configurations.
The main configuration file is configs/train_nop_rollout.yaml.
We didn't implement the running script, but here are two simple examples:
#!/bin/sh
uv sync --extra cpu
export TORCH_COMPILE_DISABLE=1
uv run python src/train.py --config-name=train_nop_rollout trainer=cpu trainer.max_steps=10 trainer.val_check_interval=5 trainer.limit_val_batches=5
echo "Done"
uv sync --extra cu126
uv run python src/train.py --config-name=train_nop_rollout
echo "Done"
Whenever you modify project components (those without the header in the beginning of the file), especially if you change their initialization parameters, be sure to update the relevant configuration files accordingly.
You can add unit tests code in the same file as the code to be tested, under the if __name__ == "__main__": block. Alternatively, you can add individual test files test_your_component.py for complicated tests, but it is suggested to keep the test code in the same folder as the code to be tested.
You may have difficulty in importing local modules. An easy way is to run the test code in the root directory as follows:
uv sync --extra cpu # for cpu tests
# uv sync --extra cu126 # for gpu tests
uv run python -m src.subfolder.test_your_component
Here uv run ensures running in the virtual environment.
Refer to the scripts in scripts_core/ for how to run code end-to-end.