General MTP (Multi-Token Prediction)
Use this skill when designing or debugging a general MTP implementation (not tied to a specific project).
Workflow
- Read
references/mtp-general.mdfor the current design, inputs/targets, and inference flow. - Keep training and inference consistent: head0 uses the base LLM output; subsequent heads use MTP fusion blocks with shifted speech tokens and eos alignment.
- When changing the MTP structure, update both
prepare_lm_input_targetand inference logic together. - If integrating into a project, ensure config/registry points to the new MTP class and model selection logic supports it.
Guardrails
- Preserve token alignment rules: each extra head removes one speech token and appends one eos token to keep lengths aligned.
- Do not add extra eos to head0 inputs (targets already include eos).
- Keep module grouping: MTP fusion block encapsulates norm, projector, and decoder layer.