refactor(ops): route Llama paths through InfiniOps - #1508
Draft
voltjia wants to merge 1 commit into
Draft
Conversation
voltjia
force-pushed
the
refactor/use-infiniops-for-llama-routes
branch
from
August 19, 2026 04:38
e02976d to
0bd84a6
Compare
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.
Summary
flash_attn_varlen_funcandflash_attn_with_kvcacheproviders for MetaX prefill and decode.select_last_token_hiddenprovider on NVIDIA and MetaX with canonical InfiniOpsaddandindex_selectcalls.ops.jsonmechanism.Motivation
The basic Llama/Qwen inference path still bypassed canonical InfiniOps for MetaX FlashAttention and last-token selection. This change keeps those paths in InfiniCore but routes their operator work through open-source-aligned InfiniOps interfaces, without calling any
Infinilm-suffixed InfiniOps operator.Dependency
ops.jsonimplementation selection added by feat(build): select operator implementations fromops.jsonInfiniOps#931; no separate linked-provider selector is introduced.Implementation
multi_head_attention_varlenaccepts MetaX in its existing InfiniOps eligibility check.mha_kvcacheaccepts MetaX in its existing InfiniOps eligibility check.select_last_token_hiddencomputesinput_offsets[1:] - 1with canonicaladd, then gathers rows with canonicalindex_select.ops.json: FlashAttention uses linked slot 16,argmaxandindex_selectuse generated ATen slot 8, and operators that also have unrelated linked providers remain on native slot 0.Validation
infinicore_cpp_apiand_infinicorebuilds passed on MetaX with the dependent InfiniOps branch.flash_attn_varlen_funcandflash_attn_with_kvcachesource files.ops.jsonmigration with a 2-token smoke run.Operator<FlashAttnVarlenFunc, Device::Type::kMetax, 16>through the linked Torch adapter.select_last_token_hidden_impl::infiniops::run.Operator<FlashAttnWithKvcache, Device::Type::kMetax, 16>through the linked Torch adapter.src/infinicoreandinclude/infinicorereturned noInfinilmor_infinilmreferences.INFINI_OPS_LINKED_OPSreferences.clang-format 16.0.6 --dry-run --Werrorwith the repository.clang-format.git diff --check origin/main...HEADpasses.Scope
This PR only changes the basic Llama/Qwen routes described above. Other models, layouts, and fallback behavior are intentionally unchanged.