Skip to content

fla: fix relative import depths in the vendored source - #1129

Open
qgallouedec wants to merge 2 commits into
huggingface:mainfrom
qgallouedec:fla-fix-relative-imports
Open

fla: fix relative import depths in the vendored source#1129
qgallouedec wants to merge 2 commits into
huggingface:mainfrom
qgallouedec:fla-fix-relative-imports

Conversation

@qgallouedec

Copy link
Copy Markdown
Member

Fixes #1128.

Sets the correct dot count on the 10 imports that have one. I found them by resolving every relative import in fla/torch-ext/fla against the file layout, and each of these has exactly one depth that resolves.

Verified on the published build (aa89c60) with the repro from the issue: the chunk_gated_delta_rule backward runs, and the gradients match this repo's own naive_chunk_gated_delta_rule to 1.9e-3 relative in fp32. That exercises ops/common/backends/tilelang/__init__.py:99 only, the other nine I can't reach from here (NPU-only, multi-card CP, TYPE_CHECKING-only). chunk_kda fwd+bwd still passes.

Not fixed: ops/deltaformer/parallel.py:26, from ...utilslayers.utils import pad_input, unpad_input. No dot count works, layers.py here is a slim shim and those two functions aren't vendored. Either pull in layers/utils.py or drop deltaformer, your call.

Ten imports in `fla/torch-ext/fla` use a dot count that is one or two levels
too shallow. In an `__init__.py` the current package is the directory itself,
one level deeper than for a plain module, so `from ...ops.common...` inside
`ops/common/backends/tilelang/__init__.py` resolves against `fla.ops.common`
and the original path is appended to it, giving `fla.ops.common.ops.common...`.

The imports sit inside functions, so nothing fails at import time. The
gated_delta_rule backward hits three of them and raises ModuleNotFoundError,
but only when tilelang is installed, otherwise it falls through to triton.
@sayakpaul

Copy link
Copy Markdown
Member

/kernel-bot build-and-stage fla

@sayakpaul
sayakpaul requested a review from vasqu September 1, 2026 09:31
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Build request processed.

Command: /kernel-bot build-and-stage fla
Mode: build and stage
Target branch: pr-1129
PR head SHA: 700443d1ad20a2c2dd30301eb16f64ca7720c40b
Workflows: build.yaml, build-mac.yaml, build-windows.yaml

Dispatched (1):

Hub uploads:

vasqu
vasqu previously approved these changes Sep 1, 2026

@vasqu vasqu left a comment

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.

Thanks for the fix 🫡

Not fixed: ops/deltaformer/parallel.py:26, from ...utilslayers.utils import pad_input, unpad_input. No dot count works, layers.py here is a slim shim and those two functions aren't vendored. Either pull in layers/utils.py or drop deltaformer, your call.

Imo, we could just copy those functions into the file. I'd like to avoid dropping it for now

@danieldk

danieldk commented Sep 3, 2026

Copy link
Copy Markdown
Member

Oh, there was already an existing PR that just got merged: #1074

Let me try to resolve the conflicts, because I think this PR has more fixes.

@danieldk

danieldk commented Sep 3, 2026

Copy link
Copy Markdown
Member

/kernel-bot build-and-stage fla

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Build request processed.

Command: /kernel-bot build-and-stage fla
Mode: build and stage
Target branch: pr-1129
PR head SHA: e8fd372598f5bf661e855595e70a83362878512f
Workflows: build.yaml, build-mac.yaml, build-windows.yaml

Dispatched (1):

Hub uploads:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Version bumps, releases, misc maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backward is broken when tilelang is installed: relative imports rewritten with the wrong depth

4 participants