Skip to content

[None][fix] Kimi Linear / Kimi K3: make fla-core a runtime dependency - #19837

Closed
vsabavat wants to merge 1 commit into
NVIDIA:mainfrom
vsabavat:k3-up/p10-fla-runtime-dependency
Closed

vsabavat wants to merge 1 commit into
NVIDIA:mainfrom
vsabavat:k3-up/p10-fla-runtime-dependency

Conversation

@vsabavat

@vsabavat vsabavat commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Description

What goes wrong. The Kimi Delta Attention layers of Kimi Linear and Kimi K3
(tensorrt_llm/_torch/modules/kimi_kda/) need flash-linear-attention at runtime:

  • kimi_kda_mixer.py imports fla.modules.ShortConvolution when it loads (and builds its short convolutions with
    it);
  • prefill batches below four 64-token chunks run fla.ops.kda.chunk_kda, and the decode / verify fallbacks
    fla.ops.kda.fused_recurrent_kda.

flash-linear-attention is listed only in requirements-dev.txt. CI installs that file in every test stage, so all
tests pass. A plain pip install of the wheel does not, and neither does the release container, which installs the
wheel with its runtime requirements. There, loading either model fails with ModuleNotFoundError: No module named 'fla'. Checked in the 1.3.0rc28 release container: it ships kimi_kda_mixer.py with that import at line 26 and no
fla package.

Fix. Require fla-core==0.5.2:

  • it is the distribution that provides fla.modules and fla.ops;
  • it is the version requirements-dev.txt already installs through flash-linear-attention==0.5.2, so CI's
    environments do not change;
  • its only base dependency, einops, is a runtime requirement already;
  • it is MIT-licensed and a pure-Python wheel (fla_core-0.5.2-py3-none-any.whl). Its Triton kernels use the
    triton and torch this package already requires.

Test Coverage

tests/unittest/others/test_kimi_kda_runtime_dependencies.py (CPU; l0_cpu.yml collects unittest/others):

  • it maps every package the KDA layers import when they load (their module-level absolute imports) to the
    distributions that provide it, and requires one of them in requirements.txt;
  • it requires fla to be mappable, so it cannot pass vacuously.

Results, in the trtllm container with main's own build:

  • on main's requirements.txt the test fails: kimi_kda_mixer.py imports fla, provided by fla-core, flash-linear-attention;
  • with this PR it passes.

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title. (No API change.)

  • Any new dependencies have been scanned for license and vulnerabilities (New runtime dependency fla-core==0.5.2, MIT; already installed in CI through requirements-dev.txt. The license / vulnerability scan is for the maintainers' tooling.)

  • CODEOWNERS updated if ownership changes (No ownership change.)

  • Documentation updated as needed (No documentation change; ATTRIBUTIONS-Python.md is generated.)

  • Update tava architecture diagram if there is a significant design change in PR. (No design change.)

  • The reviewers assigned automatically/manually are appropriate for the PR. (To check once the PR is open.)

  • Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

The KDA layers (tensorrt_llm/_torch/modules/kimi_kda) import
flash-linear-attention's ShortConvolution when they load and run its chunked
KDA for prefill batches below four 64-token chunks, but flash-linear-attention
is listed only in requirements-dev.txt. CI installs that file, so every test
passes, while a plain pip install of the wheel, and the release container,
which installs the wheel with its runtime requirements only, cannot load
either model: No module named 'fla'.

Require fla-core, the distribution that provides fla.modules and fla.ops,
at the version requirements-dev.txt already installs through
flash-linear-attention 0.5.2. Its only base dependency, einops, is a runtime
requirement already. A CPU test checks that every package the KDA layers
import when they load is a runtime requirement.

Signed-off-by: Vasanth Sabavat <[email protected]>
Comment thread requirements.txt
peft>=0.18.1,<0.19.0
patchelf
einops
fla-core==0.5.2 # the Kimi Linear / Kimi K3 KDA layers import fla.modules and fla.ops when they load

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to move the whole flash-linear-attention==0.5.2 to here and remove it from requirements-dev.txt.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'd keep fla-core here rather than the full flash-linear-attention:

  • The runtime needs only fla-core. Outside the tests, fla is imported only as fla.modules (kimi_kda_mixer.py)
    and fla.ops (fla.ops.kda, fla.ops.utils.index), and both are in fla-core. flash-linear-attention adds only
    fla.layers and fla.models, which nothing in the repo imports, tests included.
  • The full package changes what import fla does. fla-core's fla/__init__.py imports fla.layers and
    fla.models whenever they are installed. fla.models then registers 35 model types with
    AutoConfig / AutoModel / AutoModelForCausalLM, with exist_ok=True.
    • Checked in the 1.3.0rc28 image with transformers 5.5.4: with the full package installed,
      from fla.modules import ShortConvolution replaces transformers' own mamba and mamba2 configs.
      AutoConfig then returns fla.models.mamba2.configuration_mamba2.Mamba2Config for mamba2.
    • With fla-core alone, nothing is registered.
    • That would happen in every process that loads the KDA layers.
  • Otherwise the two are equivalent. flash-linear-attention 0.5.2's only extra base requirement is
    transformers>=4.45.0, which is already pinned, and both are MIT.

If you'd like one pin in one place, I can drop flash-linear-attention from requirements-dev.txt in this PR instead.
The tests also import only fla.modules / fla.ops, so CI would then install exactly what the runtime does.

@vsabavat

vsabavat commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by the consolidated draft PR: #19988. Source commits and follow-ups are retained; prior reviews remain historical evidence, not approval of the replacement heads.

@vsabavat vsabavat closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants