veomni-gpu-to-npu
Skill2.3k starsChanged 3 days agoApache-2.0View on GitHub
Plan and migrate an existing VeOmni GPU model implementation to Ascend NPU. Use when the GPU patchgen path already works and the model needs a migration file inventory, dependency auditing, NPU operator selection, patchgen integration, multimodal wrapper adaptation, or focused model tests. Gemma 3 is the worked example.
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Read these references before changing model code:
- Very specific: line 20
Use veomni/models/transformers/qwen3/, seed_oss/, qwen3_vl/, and qwen3_5/ as reference implementations.
- Distinctive: line 26
Before editing code, report a migration file inventory and ordered implementation steps.
- Very specific: line 62
Check device-neutral behavior as part of the audit: allocations must derive their device from inputs or parameters, no .cuda() calls may …
- Distinctive: line 68
Prefer an NPU sibling patch spec that reuses the complete device-neutral GPU patch.
- Very specific: line 98
Update __init__.py so model classes are selected at import time by device availability.
- Very specific: line 113
Read .agents/skills/veomni-patchgen-model/references/multimodal.md, then audit the vision or audio tower, multimodal projector, placeholder …
- Very specific: line 115
Verify the checkpoint namespace as well as the operator namespace.
- Very specific: line 119
Keep the multimodal forward contract intact.
- Distinctive: line 123
When replacing the outer VLM loss, preserve the upstream shifted-label and attention-mask behavior.
- Very specific: line 135
Run the same patchgen command twice and require the second run to leave the generated .py and .diff unchanged.
- Distinctive: line 137
Run focused checks for the patch spec and generated model before hardware training.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
VeOmni GPU-to-NPU Model Migration
Produce the smallest maintainable NPU model implementation for a model that already works through VeOmni's GPU path. Keep this skill limited to model code, generated patches, registry dispatch, and focused model validation; do not add training configs, launch scripts, datasets, logs, plots, reports, or checkpoints.
Read these references before changing model code:
.agents/knowledge/constraints.md.agents/skills/veomni-patchgen-model/SKILL.md.agents/skills/veomni-new-op/SKILL.mddocs/design/patchgen.mddocs/design/op_selection.mdveomni/ops/README.md.agents/knowledge/testing.md
Use veomni/models/transformers/qwen3/, seed_oss/, qwen3_vl/, and qwen3_5/ as reference implementations. Gemma 3 under veomni/models/transformers/gemma3/ is the dense text/VLM worked example.
1. Audit The Existing Model Patch
Confirm that the installed Transformers version matches the repository pin, then inspect the GPU patch spec, generated model, upstream Transformers model, model registry, and the live operator registry.
Before editing code, report a migration file inventory and ordered implementation steps. Include only files needed for model adaptation; identify files that can be reused unchanged and explain why any expected patch, test, or registry file is unnecessary.
| File | Purpose | Planned change | Validation |
veomni/models/transformers/<model>/... | NPU patch spec or model dispatch | Add or update the minimum NPU-specific code | PatchGen, import, and focused model tests |
veomni/models/transformers/<model>/generated/... | Generated NPU model artifact | Regenerate from the patch spec; never edit by hand | Run PatchGen twice and check for no diff |
tests/models/... | Model adaptation coverage | Extend the closest existing test when needed | Run the focused test |
Adjust the rows to the target model. Do not add a file just to match this example; record an explicit no-change decision when an existing implementation already covers it.
python -c "import transformers; print(transformers.__version__)"
rg -n "transformers==" pyproject.toml
ls veomni/models/transformers/<model>/{__init__.py,*_gpu_patch_gen_config.py}
ls veomni/models/transformers/<model>/generated/patched_modeling_*_gpu.py
rg -n "cuda|triton|flash_attention|flex_attention|liger|is_cuda|\.cuda\(" \
veomni/models/transformers/<model>
rg -n "VeomniOp|ops_config|attn_implementation|RMSNorm|apply_rotary|cross_entropy" \
veomni/models/transformers/<model> \
veomni/ops/kernelsFor every patched operator, verify the registered implementations and select the NPU backend according to the exact model semantics rather than the backend name alone.
| Operation | Typical GPU backend | Typical NPU choice |
| attention | flex_attention / flash attention | sdpa or eager |
| RMSNorm | liger_kernel | torch_npu when the variant matches |
| rotary embedding | liger_kernel | torch_npu |
| causal cross entropy | liger_kernel | chunk_loss or eager |
| SwiGLU | fused GPU backend | registered NPU backend or eager |
| MoE | fused_triton | fused_npu |
| load-balancing loss | triton | registered NPU backend or eager |
Check device-neutral behavior as part of the audit: allocations must derive their device from inputs or parameters, no .cuda() calls may remain, dtype conversions must preserve the model contract, and distributed operations must use VeOmni's current parallel-state APIs.
Model-specific normalization and loss semantics are correctness-critical. Select the registry variant whose tensor contract matches the model: standard RMSNorm uses the standard variant, while Gemma 3 initializes weights to zero and uses the offset variant to apply 1 + weight. Do not apply that offset again in model code. Likewise, verify soft-capping, ignored labels, shifted labels, and reduction behavior before replacing the upstream loss.
2. Implement The NPU Patch
Prefer an NPU sibling patch spec that reuses the complete device-neutral GPU patch. Add only NPU/VLM behavior that is absent from the GPU path.
from copy import deepcopy
from veomni.models.transformers.<model>.<model>_gpu_patch_gen_config import config as gpu_config
config = deepcopy(gpu_config)
config.target_file = "patched_modeling_<model>_npu.py"
config.description = "<Model> with VeomniOp NPU replacements"Model classes must own instance-local VeomniOp handles. Resolve the configured implementation from config.ops_config during construction and call the handle unconditionally; the registry's eager row supplies the CPU/GPU fallback.
from veomni.ops import VeomniOp
rms_norm_impl = config.ops_config.rms_norm_implementation if config is not None else "eager"
self.veomni_rms_norm = VeomniOp(
"rms_norm",
"standard",
rms_norm_impl,
)
hidden_states = self.veomni_rms_norm(hidden_states, self.weight, eps=self.variance_epsilon)Inspect OP_REGISTRY before adding an implementation. If the required (op, variant, implementation) row is missing, follow veomni-new-op: implement it under veomni/ops/kernels, register it with register_op, attach NpuKernelRequirement(), and keep model-specific argument adaptation in the PatchGen model. Never import a vendor kernel directly from generated modeling. Do not duplicate a GPU patch body merely to change its target file.
Update __init__.py so model classes are selected at import time by device availability.
from ....utils.device import IS_NPU_AVAILABLE
if IS_NPU_AVAILABLE:
from .generated.patched_modeling_<model>_npu import <classes>
else:
from .generated.patched_modeling_<model>_gpu import <classes>Register every supported model_type and preserve the existing architecture fallback behavior. A VLM normally requires one registry entry for its multimodal wrapper and another for its text backbone.
3. Adapt Multimodal Model Wrappers
Read .agents/skills/veomni-patchgen-model/references/multimodal.md, then audit the vision or audio tower, multimodal projector, placeholder masks, packed metadata, sequence-parallel boundaries, and the outer ForConditionalGeneration.forward independently from the text backbone.
Verify the checkpoint namespace as well as the operator namespace. Nested generated wrappers can change parameter names even when the upstream class loads correctly, so compare source checkpoint keys with model.named_parameters() after constructing the generated wrapper and add an explicit conversion mapping when required.
For the Gemma 3 VLM, legacy keys under language_model.model.*, vision_tower.vision_model.*, and multi_modal_projector.* map to the generated wrapper's nested model.* names. Treat unexpected keys or uninitialized vision/projector parameters as hard failures; a tied lm_head alias may be the only intentional exception.
Keep the multimodal forward contract intact. Gemma 3 requires pixel_values and image-aware token_type_ids in addition to the text tensors, and its model-specific position-ID function must remain compatible with VeOmni's packing and sequence-parallel paths.
For distributed training, account for ranks that receive text-only microbatches while peer ranks receive multimodal data. Disable unused trainable auxiliary heads, run a minimal dummy forward through every modality component used by the real media path, and attach the result to the text path with a zero-valued dependency. Verify that real-media and text-only microbatches touch the same trainable modality parameters so DDP/FSDP reductions remain symmetric without changing logits or loss.
When replacing the outer VLM loss, preserve the upstream shifted-label and attention-mask behavior. Do not treat successful text-backbone execution as coverage for the multimodal wrapper.
4. Generate And Validate Model Artifacts
Generate model files through patchgen and never edit generated/ by hand.
patchgen veomni.models.transformers.<model>.<model>_npu_patch_gen_config \
-o veomni/models/transformers/<model>/generated --diff -v
git diff --checkRun the same patchgen command twice and require the second run to leave the generated .py and .diff unchanged.
Run focused checks for the patch spec and generated model before hardware training.
python -m py_compile \
veomni/models/transformers/<model>/<model>_npu_patch_gen_config.py \
veomni/models/transformers/<model>/generated/patched_modeling_<model>_npu.py
python -c "import veomni.models.transformers.<model>.generated.patched_modeling_<model>_npu"
make qualityExtend an existing model test when practical. Cover generated-module import, local VeomniOp selection, eager parity, finite forward/backward outputs, gradients, checkpoint conversion, multimodal input propagation when applicable, and patchgen reproducibility. Verify that constructing another model with a different ops configuration does not retarget handles on the first model.
Completion Checklist
- Installed Transformers version matches the repository pin
- GPU-only model dependencies are classified
- Device-neutral allocations, dtype conversions, and distributed APIs are verified
- NPU backends are verified in the live operator registry
- Every model-side operator is an instance-local
VeomniOp; no module-global dispatch remains - Model-specific normalization and loss semantics are preserved
- NPU patch spec reuses device-neutral GPU patch bodies
- Text and multimodal model types are registered as applicable
- Multimodal checkpoint namespaces and input contracts are verified
- Real-media and text-only distributed microbatches touch the same trainable modality parameters
- Generated model and diff are reproducible
- Import, quality, and focused model tests pass
- No configs, scripts, datasets, logs, plots, reports, or checkpoints are included
Trending
Quiet since September.about the whole repository
Who's talking about ByteDance-Seed/VeOmni
- verl-project/verl“[roadmap] verl 26Q2 roadmap”GitHub · Apr 1, 2026 · 28 reactions
- linkedin/Liger-Kernel“[NPU Roadmap, Updated to 2026-Q2] NPU support for Liger-Kernel”GitHub · Dec 8, 2025 · 17 reactions
- verl-project/verl-omni“[RFC] VeOmni Backend Integration Plan for H2”GitHub · May 19, 2026 · 2 reactions
- verl-project/verl“[veomni, fsdp] feat: enable fused top-K distillation kernel for OPD”GitHub · May 27, 2026 · 1 reactions
- @pythonhub.dev“VeOmni Scaling any Modality Model Training to any Accelerators with PyTorch native Training Framework.…”Bluesky · Apr 18, 2025 · 1 likes
The biggest 5 of 22 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 22
Talked about on GitHub and Bluesky (22 times).
On GitHub · 21
- Apr 1, 2026[roadmap] verl 26Q2 roadmap — verl-project/verl28 reactions · 2 comments
- Dec 8, 2025[NPU Roadmap, Updated to 2026-Q2] NPU support for Liger-Kernel — linkedin/Liger-Kernel17 reactions · 32 comments
- May 19, 2026[RFC] VeOmni Backend Integration Plan for H2 — verl-project/verl-omni2 reactions · 7 comments
- May 27, 2026[veomni, fsdp] feat: enable fused top-K distillation kernel for OPD — verl-project/verl1 reaction
- Sep 30, 2026[veomni, model, doc] feat: support MTP training for Qwen3.5 models — verl-project/verl0 reactions
16 more on GitHub
- Sep 28, 2026[RFC]: HyperParallel 统一补全 .nv-meta 在线/离线数据源能力 — mindspore-ai/hyper-parallel0 reactions
- Sep 24, 2026[model, ops, perf] feat: accelerate Qwen4-Exp QSA and NPU norm/rope — Crystal-jiang/VeOmni0 reactions
- Sep 9, 2026[algo, trainer, rollout, vllm] feat: add reverse KL top-k with fixed-token prefill scoring — verl-project/verl0 reactions · 4 comments
- Sep 3, 2026[veomni] feat: add async_activation_offload config — verl-project/verl0 reactions
- Aug 29, 2026[Feature request]Support Qwen3.5 series MTP training on Veomni Backend — verl-project/verl0 reactions
- Aug 27, 2026[veomni] feat: DeepSeek V4 QAT bf16 fake quant training — verl-project/verl0 reactions
- Aug 21, 2026[veomni] feat:add async activation offloading support — verl-project/verl0 reactions
- Aug 3, 2026[veomni] feat: add DeepSeek V4 support — verl-project/verl0 reactions · 1 comment
- Jun 22, 2026feat(glm): add GLM5 indexer LoRA targets — NVIDIA-NeMo/Megatron-Bridge0 reactions · 4 comments
- Jun 17, 2026[skills] docs: capture VeOmni MiniMax M3 migration workflow — Kirrito-k423/AutoModelMigrate0 reactions
- Jun 5, 2026[Add] VeOmni (ByteDance-Seed/VeOmni) — PyTorchKR/landscape0 reactions
- Feb 14, 2026[veomni, trainer] fix: padding pixel value with padding_scale for vl model — verl-project/verl0 reactions
- Nov 17, 2025Data duplication with `split_dataset_by_node` and `interleaved_dataset` — huggingface/datasets0 reactions · 3 comments
- Sep 12, 2025Target trajectory format investigation — ManifoldRG/software-control0 reactions · 2 comments
- Aug 9, 2025Feat: Add VeOmni-inspired trainer-free training script — smellslikeml/VQASynthX0 reactions
- Jul 23, 2025Set up finetuning scripts for UI-TARS1.5 — ManifoldRG/software-control0 reactions
On Bluesky · 1
- Apr 18, 2025VeOmni Scaling any Modality Model Training to any Accelerators with PyTorch native Training Framework.… — @pythonhub.dev1 likes and repost
In this repository14 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .cursor/rules/no-section-divider-comments.mdcCursor rule
- .cursor/rules/skills-reusable-only.mdcCursor rule
- create-prSkill
- veomni-debugSkill
- veomni-developSkill
- veomni-fix-docsSkill
- veomni-new-modelSkill
- veomni-new-opSkill
- veomni-patchgen-modelSkill
- veomni-profileSkill
- veomni-reviewSkill
- veomni-seed-omniSkill
- veomni-uv-updateSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

