cli-configuration
Build and troubleshoot LightningCLI and LightningArgumentParser workflows for YAML, environment-variable, subclass, optimizer, scheduler, and saved-config driven Lightning training.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- cli-configuration
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Build and troubleshoot LightningCLI and LightningArgumentParser workflows for YAML, environment-variable, subclass, optimizer, scheduler, and saved-config driven Lightning training.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/cli-reference.md10.0 KB
- 参考文档references/configuration.md7.9 KB
- 参考文档references/troubleshooting.md8.7 KB
- 脚本scripts/lightning_cli_smoke.py5.1 KB
03 SKILL.md 正文
Lightning CLI Configuration
Use this sub-skill when a task involves LightningCLI, LightningArgumentParser, config files, environment variables, --print_config, subclass modes, command subcommands, optimizer/scheduler CLI injection, or saved run configuration.
Route First
- For LightningModule, LightningDataModule, Trainer loop, callback, logger, checkpoint, or metric semantics, use
../training-core/SKILL.mdfirst and return here only for CLI wiring. - For
accelerator,devices,strategy, precision, FSDP, DDP, DeepSpeed, TPU, MPS, or GPU behavior through CLI flags, use../distributed-accelerators/SKILL.mdfor the strategy decision and this sub-skill for config syntax. - For prediction-only exports,
ServableModule, endpoint validation, or production serving scripts, use../deployment-serving/SKILL.md; use this sub-skill only if the serving script is intentionally wrapped inLightningCLI.
Start Here
- Confirm CLI extras are installed:
python -c "from lightning.pytorch.cli import LightningCLI, LightningArgumentParser". If it fails, installjsonargparse[signatures]orlightning[pytorch-extra]. - Pick the CLI mode:
LightningCLI(Model, DataModule)for normalfit,validate,test,predictsubcommands.LightningCLI(Model, DataModule, run=False)for parse/instantiate-only flows where code callstrainer.fit(...)manually.LightningCLI(BaseModel, BaseData, subclass_mode_model=True, subclass_mode_data=True)or omit a class to select implementations from config.
- Generate an inspectable config before running training:
python train.py fit --print_config > config.yaml. - Keep config changes in YAML or environment variables, then override only the last-mile settings on the command line.
Reference Map
references/cli-reference.mdcovers API signatures, subcommands, parser extension hooks, subclass modes, callbacks, optimizer/scheduler injection, and checkpoint loading support.references/configuration.mdcovers YAML layout, config precedence, default config files, environment variables,--print_config, config saving, and validation commands.references/troubleshooting.mdcovers missing extras, import issues, parse errors, subclass resolution, optimizer/scheduler mistakes, saved config collisions, optional dependencies, and CPU/GPU boundary checks.scripts/lightning_cli_smoke.pyis a safe, synthetic CLI demo for--help,--print_config, env parsing, and a tiny CPUfast_dev_runsmoke.
Common Commands
python train.py --help
python train.py fit --help
python train.py fit --print_config > config.yaml
python train.py fit --config config.yaml --trainer.max_epochs=10
python train.py fit --model.help my_package.models.MyModel
python train.py fit --model my_package.models.MyModel --print_config
PL_FIT__TRAINER__MAX_EPOCHS=1 python train.py fit
JSONARGPARSE_DEBUG=true python train.py fit --config config.yaml
Bundled Smoke Script
Run from this sub-skill directory or with an explicit path:
python scripts/lightning_cli_smoke.py --help
python scripts/lightning_cli_smoke.py fit --print_config
PL_FIT__TRAINER__MAX_EPOCHS=1 python scripts/lightning_cli_smoke.py fit --trainer.fast_dev_run=1
The script uses generated tensors, CPU-safe defaults, save_config_callback=None, and no downloads. It is intended to prove CLI parsing and minimal execution, not GPU, distributed, or dataset behavior.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).