一键导入
tensor-parallel
Add, review, update, and validate recipe-local tensor-parallel plans, TP metadata postprocessors, and compatible mesh config for mvp-engine models.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Add, review, update, and validate recipe-local tensor-parallel plans, TP metadata postprocessors, and compatible mesh config for mvp-engine models.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use and extend the MVP-Engine MLLM data kit with explicit specs, handlers, and sample objects. Use for recipe data wiring, MLLMDataSpec construction, source resample/resolve_refs policy, schema/media/tokenization handlers, packing, guards, collation, dataloader setup, Qwen VL data support, and multimodal data extensions.
Add, review, update, and validate recipe-local sequence-parallel plans that reuse the tensor-parallel mesh in mvp-engine models.
Add, review, update, and validate VLM/MLLM data pipelines using the current spec/handler-based MLLMDataKit design. Use for raw schema normalization, MLLMDataSpec wiring, source resample/resolve_refs policy, media extensions, processor setup, packing, guards, collation, step estimation, and recipe integration.
Add, review, update, and validate VLM/MLLM packing behavior around the current MLLMDataKit design, including MLLMPackingSpec, MLLMPackingAssembler, MLLMPack metadata, block-causal masks, model-specific packed input preparation, token accounting, and step estimation.
Use LigerKernelKit for reusable Liger Kernel integration before model construction, covering official model-family dispatch, custom-model symbol patching via LigerPatch, module selection validation, and loss-kernel guards.
Decide where and how to wire Liger Kernel into an MVP-Engine recipe using LigerKernelKit, including official family dispatch, authoring a custom or composite model's LigerPatch map, module selection, and loss-kernel safety.
| name | tensor-parallel |
| description | Add, review, update, and validate recipe-local tensor-parallel plans, TP metadata postprocessors, and compatible mesh config for mvp-engine models. |
Add tensor parallelism without changing model math:
TP_MODULE_CONFIG;TP_MODULE_CONFIG;TP_MODULE_POSTPROCESSORS only when sharding changes module-local runtime
metadata;parallel.mesh.tensor layout;The repo runtime contract is fixed: mvp_engine/distributed/tp.py reads
model.__class__.TP_MODULE_CONFIG, applies parallelize_module(...), then runs
optional TP_MODULE_POSTPROCESSORS.
Identify these before editing:
prepare_model() path;nn.Linear modules;RuntimeContext,
DataLoadMesh, sampler, or rank/world-size logic;parallel.mesh values and intended TP size;tests/test_structure.py and tests/test_smoke.py.Ask the user only if TP size, available devices, or target module ownership cannot be derived from the task.
Search the recipe first:
rg -n "TP_MODULE_CONFIG|TP_MODULE_POSTPROCESSORS|parallelize_model|parallel.mesh" recipes/<recipe>
rg -n "RuntimeContext|DataLoadMesh|device_mesh|dp_dims|DistributedSampler|rank|world_size" recipes/<recipe>
rg -n "q_proj|k_proj|v_proj|out_proj|fc1|fc2|gate_proj|up_proj|down_proj" recipes/<recipe>
Find:
parallelize_model(...) is called;Build TP_MODULE_CONFIG as:
MODEL_TP_MODULE_CONFIG: dict[str, object] = {
"<RuntimeBlockClass>": {
"q_proj": "col",
"k_proj": "col",
"v_proj": "col",
"o_proj": "row",
},
}
Use runtime class names as keys. Use direct child linear names as plan keys.
Plan values should be "col" or "row" unless the recipe has a documented
custom ParallelStyle.
Read references/tp_rules.md when mapping attention, MLP, VLM projector, MoE,
or metadata-sensitive modules.
Bind the plan on the top-level class that training actually instantiates:
class <TopModelClass>(...):
TP_MODULE_CONFIG = MODEL_TP_MODULE_CONFIG
If the top-level class already carries APPLY_FSDP2_CUSTOM_PREFETCHING or other
runtime class attributes, merge TP_MODULE_CONFIG onto that same class. Do not
create a second wrapper class with the same purpose.
Add TP_MODULE_POSTPROCESSORS only when module-local metadata must change after
TP sharding. Common examples:
num_heads, num_key_value_heads, or all_head_size;view, reshape, split, loops, or indexing based on
global head/expert/hidden dimensions.Keep postprocessors local and idempotent. Mutate module runtime fields, not the global config.
Set parallel.mesh.tensor to the desired TP size. In this repo, pure TP without
FSDP2 is rejected by parallelize_model(...), so parallel.mesh.shard must be
greater than one when tensor > 1.
Preserve the intended data-parallel product:
parallel:
mesh:
replicate: <D>
shard: <S>
tensor: <T>
Data-loading rules:
tensor group must read the same samples and
micro-batches;tensor is model-parallel, not data-parallel, and must not multiply global
batch size or dataset slots;replicate and
FSDP2 shard;tensor and any other non-data-parallel dimensions such as context
from dataloader sharding;mvp_dataset, pass a device_mesh plus dp_dims that excludes
tensor, or provide an equivalent sampler/loader guarantee.Review the modified recipe without running tests:
TP_MODULE_CONFIG is bound on the real top-level model class;replicate, shard, and tensor are compatible with the intended world
size;tensor
mesh dimension;tensor and includes only data-parallel
dimensions such as replicate and shard;mvp_engine/ runtime change was added;Copy and adapt references/asserts.py into:
recipes/<recipe>/tests/skills/tensor-parallel/asserts.py
Ensure the recipe has tests/test_structure.py and tests/test_smoke.py; use
tests/templates/ if missing.
Run in fresh subagents, in order, stopping on first failure:
pytest recipes/<recipe>/tests/test_structure.py -q
pytest recipes/<recipe>/tests/test_smoke.py -q --config-override parallel.mesh.tensor=2
Also supply a compatible shard override if the base config has shard: 1.
Add optional sharding impact validation when the task requires proof of local shard shapes. Use a recipe-local file such as:
recipes/<recipe>/tests/skills/tensor-parallel/test_sharding_impact.py
The impact test should compare TP-covered parameter local shapes against pre-parallel reference shapes under the active tensor mesh.
Add optional numerical impact validation when the task requires proof that TP preserves model semantics. Use a recipe-local file such as:
recipes/<recipe>/tests/skills/tensor-parallel/test_loss_parity_impact.py
The impact test should run the same deterministic batch through TP-off and TP-on models and compare loss or logits within recipe-appropriate tolerances. Use eval mode, fixed seeds, no optimizer step, identical weights, and the same mixed precision policy where feasible.
Add a dataloader identity impact test when changing recipe data loading: within
one tensor group, assert sample ids or a stable batch fingerprint are identical
across tensor ranks, while data-parallel ranks receive distinct slots.
references/asserts.py: recipe-local hard-validation assertion template.references/tp_rules.md: TP plan, postprocessor, mesh, and impact rules.