Add a rule file for the python launch and model scripts - #2357
Merged
Conversation
Zhichenzzz
force-pushed
the
zhichen/model-script-py-rule
branch
from
August 10, 2026 21:27
7d49caf to
10327f7
Compare
yueming-yuan
pushed a commit
that referenced
this pull request
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2356 (base is
yueming/script-rewrite, review that first). Docs only — no runtime code changes.#2356 finishes moving
scripts/to python, but the convention that produced it lives only in that PR's description and in the tests. This adds.claude/rules/launch-and-model-scripts.mdso the next launcher follows it without archaeology, and registers it inAGENTS.mdnext togeneral-code-style.md.Every rule is taken from the post-#2356 code or from a test that already enforces it, not from preference:
load_model_argsresolvesscripts/models/<megatron_model_type>.pyby file name, so a shell model definition cannot be found at all — andtest_shell_script_hygiene.pyalready rejects asource scripts/models/x.shin a docker patch. The survivingexamples/**/*.share named as legacy awaiting a port, so nobody copies one as a template.megatron_model_type; one puremodel_args(**kwargs) -> str; variants derive viaload_sibling_model_args/moe_layer_freq; any environment knob a model script reads has to be inCLEARED_ENV, whichtest_every_environment_knob_a_model_script_reads_is_frozenenforces.scripts/**/run_*.py, so the naming rule is what buys snapshot coverage. Public module-level functions are entrypoints (prepare,execute) and the suite asserts each issues commands, so helpers must be_-prefixed. Shell access goes throughcommand_utils; the self-executing launchers underexamples/are called out as legacy pinned bytest_self_executing_launchers.py.--model-dir/--data-dir/--output-dirinstead of literals,U.repo_base_dirinstead of a checkout path, wandb only viaget_default_wandb_args, environment read at call time (thenum_nodesdefault_factory),--num-gpus-per-nodealways passed,--rollout-num-gpusdropped under--colocate, an already-joined cluster expressed withMILES_SCRIPT_EXTERNAL_RAY=1._Recipetable keyed by aLiteral--model-name; keep separate files when the recipes are different experiments, withrun_glm45_355b_a32b_8node.pyas the worked example and a stated threshold for when not to merge.MILES_UPDATE_LAUNCH_SCRIPT_SNAPSHOTS=1 pytest tests/manual/launch_scriptsand read the diff; launchers must import and run without GPU, checkpoints or network; don't grow the harness denylists without a test that fails once the entry stops being true.hf download --local-dirdestinations.Testing
pre-commit run --files .claude/rules/launch-and-model-scripts.md AGENTS.mdclean. No code paths touched.