Skip to content

Warn at load when Ring's Lightning Attention-2 backward runs in torch on Hopper - #331

Merged
hivaze merged 1 commit into
mainfrom
fix/hopper-warning-ring
Dec 2, 2026
Merged

hivaze merged 1 commit into
mainfrom
fix/hopper-warning-ring

Conversation

@hivaze

@hivaze hivaze commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Approval

  • This PR addresses an accepted issue (link it below) and my PR path was approved (I'm on .github/APPROVED_CONTRIBUTORS, or I have write access).
  • I understand and can explain every line of this change (no unreviewed AI output).

What & why

Follow-up to #312, where the review asked for the load warning to cover Ring too.

On H100 and H200 under Triton 3.4.0 to 3.7.0, Ring-mini-linear-2.0 trains its Lightning Attention-2 backward on the torch kernel from #312. Its remote code calls fla's chunk_simple_gla with a per-token gate at lines 1048 to 1052 of modeling_bailing_moe_linear_v2.py. In fla 0.6.0 that op's backward calls chunk_bwd_dqkwg at line 108 of fla/ops/simple_gla/chunk.py. The load warning looked only for GatedDeltaNet layers in the config. Ring's config declares layer_group_size and no layer_types, so Ring ran the slow path with no warning.

_warn_on_torch_gated_backward now asks one predicate, _has_gated_chunk_backward_layers. It is true for GatedDeltaNet layers read off the config, as before, and for any module that holds Lightning Attention-2's decay slope. That module test is the one the slope repair in buffer_repair.py already used; I moved it into is_lightning_attention so both callers share it. A config check cannot single Ring out: Ling 3.0's remote config declares the same layer groups, and its KDA backward never calls chunk_bwd_dqkwg (I grepped every caller in fla 0.6.0). The warning text now says "fla's gated chunk backward", because both ops share that kernel. The bailing and Qwen3.5 pages say what happens now.

  • This change comes from Halo Competition work.

Type of change

  • Bug fix
  • New feature / behavior
  • Performance
  • Docs
  • Refactor / no behavior change

Proof of Value

  • No-op / refactor: loss is bitwise-identical (fixed seed, deterministic) and the
    original checkpoint still loads.
  • Behavior change: added/updated a test demonstrating the new behavior.
  • Performance: before/after tokens/s/GPU and peak memory below.
test_load_names_the_torch_backward_for_rings_lightning_attention builds the tiny Ring, Ling 3.0 (with KDA layers)
and Ling 2.0 models from the cached remote code and sets fla's Hopper flags:
  ring_main_rank            warns once
  ring_other_rank           no warning
  ring_not_hopper           no warning
  ling3_kda_layers          no warning
  ling2_softmax_attention   no warning

On 68ecc4bbb (main before this change):   1 failed, 36 passed  (ring_main_rank: 0 warnings, expected 1)
With this change:                          37 passed
With a layer-group check in place of the slope test, ling3_kda_layers fails instead.

CPU, halo:blackwell 1.3.0:
  tests/cpu/kernels tests/cpu/model_loading   1594 passed, 48 skipped
  tests/cpu/conventions                       767 passed

Environment (optional)

  • GPU(s): none (CPU); the test sets fla's flags as they read on an H100
  • Image tag: halo:blackwell 1.3.0
  • Parallelism / model: none

AI assistance

  • This PR was written with AI assistance
    • Scaffold(s): Claude Code
    • Model(s): Claude Fable 5.2, Claude Opus 5.5
  • I reviewed, ran, and understand every line; it follows CLAUDE.md and the project standards (no unreviewed AI-slop).

Checklist

  • make lint and make format pass
  • Tests added/updated; make test-cpu (and make test-gpu-core if GPU-affecting) pass
  • Docs updated for any user-facing change (make docs is green)
  • No internal infra / secrets / credentials added
  • Every commit carries a verified signature (Verified badge), forks included — a PR with an unsigned commit cannot merge; re-sign with git rebase --exec 'git commit --amend --no-edit -S' <base> and force-push
  • Focused diff (large PRs ~2,000+ lines are reviewed later — consider splitting)

The whole make test-cpu ran on 147a7de68 in the 1.3.0 image: 22,817 passed and 0 failed across tests/cpu, and 1,868 passed in tests/cpu/environments, which ran apart.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Model loading now displays a one-time warning on the main rank for affected linear-attention models on Hopper systems, including Ring models.
  • Documentation

    • Clarified which Ring and Ling attention layers use the relevant backward path and when the loading warning applies.

… on Hopper

On H100 and H200 under Triton 3.4.0 to 3.7.0, Ring-mini-linear-2.0 trains its
Lightning Attention-2 backward on the torch kernel from #312: its remote code
calls fla's chunk_simple_gla with a per-token gate, and that op's backward calls
chunk_bwd_dqkwg. The load warning looked only for GatedDeltaNet layers in the
config, and Ring's config declares layer_group_size with no layer_types, so Ring
took the slow path without a word.

The warning now asks one predicate, _has_gated_chunk_backward_layers: GatedDeltaNet
layers read off the config, or a module holding Lightning Attention-2's decay
slope. That module test is the one the slope repair already used, now named
is_lightning_attention in buffer_repair. The config cannot tell Ring apart:
Ling 3.0's remote config declares the same layer groups, and its KDA backward
never calls chunk_bwd_dqkwg in fla 0.6.0. The warning text says "fla's gated
chunk backward" now, since both ops share that kernel.

I ran these on CPU in the 1.3.0 image:
- tests/cpu/kernels/test_gated_delta_backward.py: 37 passed
- tests/cpu/kernels and tests/cpu/model_loading: 1594 passed, 48 skipped
- tests/cpu/conventions: 767 passed
- ruff check and ruff format --check (0.9.10, the uv.lock pin), and
  ./scripts/docs/check_links.sh

The new test fails on 68ecc4b (ring_main_rank logs 0 warnings, expected 1). With
a layer-group check in place of the slope test, ling3_kda_layers fails instead.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The load-time warning now covers Lightning Attention modules alongside GatedDeltaNet layers. Tests check warning conditions for Ring and Ling models, and model documentation describes the detection and warning behavior.

Changes: Hopper backward warning

Layer / File(s) Summary
Detect eligible layers and issue the warning
halo/model_loading/buffer_repair.py, halo/model_loading/finalization.py
A shared predicate identifies Lightning Attention modules. Finalization uses it alongside GatedDeltaNet config detection when deciding whether to issue the warning. The warning text now refers to the gated chunk backward.
Test and document warning coverage
tests/cpu/kernels/test_gated_delta_backward.py, agent-docs/models/bailing.md, agent-docs/models/qwen3_5.md
Parameterized tests cover Ring and Ling cases, rank and device conditions, and warning-once behavior. The model documentation describes Ring’s warning and layer detection.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Possibly related issues

  • whitecircle/halo#309 — Both this change and the issue concern FLA’s gated chunk backward on Hopper; this change extends the warning to Ring’s Lightning Attention-2 layers.

Possibly related PRs

  • whitecircle/halo#312 — This PR extends the same load-time warning path introduced for GatedDeltaNet layers to Ring’s Lightning Attention-2 layers.

Suggested reviewers: advpropsys, kevinli24

Merge Risk: Minimal · up to 147a7

This change extends the Hopper torch-backward load warning to Ring models and updates the docs. It only affects warning output, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a load-time warning for Ring's Lightning Attention-2 backward running in the torch path on Hopper. The raw summary says the warning check now covers Ring's Lightning A…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: a load-time warning for Ring's Lightning Attention-2 backward running in the torch path on Hopper. The raw summary says the warning check now covers Ring's Lightning Attention layers detected by their decay slope, and the PR objectives describe the same change, so the title matches the changeset. The title is 79 characters, which is longer than the concise style preferred, but it stays specific and readable.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit reads the warning near the load,
Then checks which layer travels down the road.
Ring’s slopes help mark the path in view,
While tests check ranks and Hopper too.
The rabbit hops; the notes are new.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 925e187f-9804-48bd-8ced-2fa9889d862d
Commits

Reviewing files that changed from the base of the PR and between 68ecc4b and 147a7de.

Files selected for processing: 5

  • agent-docs/models/bailing.md
  • agent-docs/models/qwen3_5.md
  • halo/model_loading/buffer_repair.py
  • halo/model_loading/finalization.py
  • tests/cpu/kernels/test_gated_delta_backward.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@advpropsys advpropsys left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved.

@hivaze
hivaze merged commit 8405f24 into main Dec 2, 2026
8 checks passed
@hivaze
hivaze deleted the fix/hopper-warning-ring branch December 2, 2026 21:28
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.

2 participants