Repository navigation
Add opt-in Liger vocab-parallel cross entropy through ops/loss - #8720
Draft
vaibhavjindal wants to merge 2 commits into
Draft
vaibhavjindal wants to merge 2 commits into
vaibhavjindal wants to merge 2 commits into
Conversation
Bind the optional Liger loss through the shared selector, preserve explicit TP groups and expose original argmax predictions for MTP. Add semantic, model, replay and optional-backend CI coverage independently of normalization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Vaibhav Jindal <vaibhav.jndl@gmail.com>
Use the latest stable release while preserving optional runtime installation and the existing dev-image-only test guard. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Vaibhav Jindal <vaibhav.jndl@gmail.com>
This branch has not been deployed
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.
What does this PR do?
Add opt-in Liger vocab-parallel cross entropy through
ops/loss.Stacked on #8656; this is the CE-only successor to the corresponding part of #5438. It does not depend on the separate RMSNorm contribution.
--cross-entropy-loss-fusion --cross-entropy-fusion-impl ligerbinds the adapter through the existing shared selector. No model-forward dispatch or normalization changes. Disabled fusion remains native unfused CE, and unselected paths do not import Liger.The adapter returns FP32 per-token losses, preserves incoming gradient dtype, and uses the supplied TP group. Optional original global argmax preserves MTP prediction semantics, including smallest-index ties. Missing selected dependencies fail through
ops._backends.require.CI: the H100 ops, models and determinism-kernel buckets install
liger-kernel==0.8.5with--no-depsin latest/dev runs on dev images. The shared export check fails before tests on a broken installation. The image'sIMAGE_TYPEmarker excludes LTS even when GitHub labels its recipe environmentdev; runtime installation remains optional.Performance (Liger v0.8.5)
Measured on H100 80GB with exact release
v0.8.5(1ab779f), PyTorch 2.13.0.2+cu130, Triton 3.7.1 and TE 2.20.2.0+cu130. Times are median synchronized wall latency; lower is better.Vocab-parallel CE, forward + backward: BF16, sequence 2048, batch 1, global vocabulary 128K. 10 warmups, 3 x 50 samples. TP results use the slowest rank; fresh input clones are outside timing for every backend.
At TP8, peak extra allocated memory is 188.5 MiB native fused / 188.5 MiB Liger / 0.30 MiB TE, excluding the live input. Liger improves native CE latency here; TE remains faster and uses less extra memory.
Full-model ablation: 32-layer Llama2-7B shape, H4096, FFN11008, vocab32K, BF16, batch1, TP8; only this PR's operation changes. Three independent process launches/backend, 5 warmups +20 steps/sequence, forward + backward without optimizer or CUDA graphs. Table latencies are medians of the three process medians; the last column shows paired trial ranges (positive = slower).
The isolated CE win does not establish a material general end-to-end speedup.
Numerics: the separate full-gradient diagnostic has BF16 relative-L2 differences of 1.94-1.98% versus native and approximately 2.45e-06 in FP32. These are not convergence-equivalence claims.
Issue tracking
Related to #5488 and #5438. Retarget to
mainafter #8656 lands, before merging.Code provenance
No external kernel source copied. The adapter calls the installed Liger API; installation guidance identifies v0.8.5 or a newer compatible version.
Contribution process
tools/autoformat.shagainstpull-request/8656Validated independently on H100: FP32/BF16, TP=1/2/4, interleaved non-WORLD groups, strided inputs, arbitrary upstream gradients, and native/PyTorch parity.
Latest-release focused regression suite: 495 passed per rank on four GPUs (Liger v0.8.5, locally built from the release tag).