Feature Request: Add THD / Packed-Sequence Training Support

Open
#1,281 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@Anubhav-2003 is already working on this.

Since Jul 22, 2026.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
28/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Quiet
Tech stack
python

Research direction

The issue names no implementation files, entry points, or tests. Start by surveying the existing Liger kernels and their shape-related tests, then determine which kernels need THD inputs and sequence metadata such as cu_seqlens and max_seqlen. Done means the supported kernels accept packed layouts without padding assumptions and have coverage for variable-length training.

Written by the indexing model from the issue text.

Description

🚀 The feature, motivation and pitch

Motivation

Some training frameworks represent variable-length batches in a packed THD layout, where activations are shaped like (total_tokens, num_heads, head_dim), or more generally (total_tokens, hidden_dim), instead of the standard padded batch layout (batch_size, seq_len, ...).

This layout is useful for sequence packing and variable-length training because it avoids padding overhead.

Supporting this layout may require passing sequence metadata such as cu_seqlens or max_seqlen to kernels that need per-sequence position information.

Request

Add support for THD / packed-sequence training layouts across Liger kernels.

The long-term goal is to support inputs such as hidden_states: (total_tokens, hidden_dim) and attention tensors such as (total_tokens, num_heads, head_dim), with metadata such as cu_seqlens and max_seqlen where needed.

Alternatives

No response

Additional context

No response

Dominant language
Python
Stars
6.7k
Forks
656
Avg merge
4d 12h
Merged PRs (30d)
27

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from linkedin/Liger-Kernel

All issues in linkedin/Liger-Kernel

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.