[feat] Add streaming and GPU-accelerated LoRA extraction - #1784
Open
shaoxiongduan wants to merge 6 commits into
Open
[feat] Add streaming and GPU-accelerated LoRA extraction#1784shaoxiongduan wants to merge 6 commits into
shaoxiongduan wants to merge 6 commits into
Conversation
Contributor
Merge Protections🔴 1 of 1 protections blocking · waiting on 👀 reviews and 🤖 CI
🔴 PR merge requirementsWaiting for
This rule is failing.
|
… merges Review follow-ups on the streaming extractor. - extract_lora removed the whole --work-dir tree, so pointing it at a directory that held anything else destroyed those files. Scratch now lives in a dedicated subdirectory and cleanup only removes the manifest and tensor shards this script writes. Assembly is manifest-driven, so dropping the manifest is what makes a rerun start clean. - An --exact-tensor-pattern that matched nothing silently rank-truncated the tensors it was meant to keep exact, and the doubled backslashes in the MiniMax-H3 README command did exactly that. Patterns are now validated against the checkpoint keys before any SVD runs, and the README uses single-escaped dots. - merge_lora only understood the lora_A/lora_B half of an adapter, so every .diff / .diff_b / .diff_param / .set_weight / .set_param tensor was dropped with no warning, including the two the docs now tell users to extract. It applies them and reports anything it still cannot place. - A stale work dir made a fresh (non-resume) rerun fail with a resume error; the config check is now gated on --resume. - --out with a non-.safetensors suffix wrote a safetensors file under that name; it is rejected instead. Tests: fastvideo/tests/lora_extraction/ -> 17 passed, 1 failed. The failure is test_lora_extraction_pipeline, which needs an HF download and fails identically on the parent commit.
SolitaryThinker
requested changes
Aug 30, 2026
SolitaryThinker
left a comment
Collaborator
There was a problem hiding this comment.
Requesting changes for several silent correctness failures in the documented extraction and merge paths. I reproduced the namespace mismatch, stale-resume behavior, ignored revisions, and low-precision dense round-trip locally. The focused CPU tests and pre-commit pass, but the current tests do not exercise these production cases; Buildkite fastcheck is also still red across all microscope lanes.
shaoxiongduan
force-pushed
the
shao/generic-lora-extractor-gpu
branch
from
August 31, 2026 03:13
3906bd8 to
d0dcee7
Compare
Contributor
|
This PR has merge conflicts with the base branch. Please rebase: git fetch origin main
git rebase origin/main
# Resolve any conflicts, then:
git push --force-with-lease |
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.
Purpose
Add a streaming, GPU-accelerated path to
scripts/lora_extraction/extract_lora.pyfor large video transformers while preserving the existing exact CPU workflow and mixed LoRA/dense adapter format.Previously, extraction materialized both transformer state dictionaries in host memory and performed full SVD on CPU. This is prohibitively expensive for models such as MiniMax-H3. The updated extractor streams indexed tensors, supports exact or randomized factorization on a selected device, and adds controls for accuracy, storage precision, resumability, and adapter validation.
Changes
transformer/*when resolving Hugging Face repositories.--load-mode auto:--device--svd-method exact|randomized--randomized-q--oversample--niter--seed.diff/.diff_b/.diff_parampayloads;.set_weight/.set_paramparameters.--exact-tensor-patternrules for matrices that should remain exact dense deltas instead of being rank-truncated.--work-dirand--resume.scale_shift_tablethrough.diff_param/.set_parampayloads instead of silently dropping them.lora_rankandlora_alphatensors whenalpha == rank, which is already the loader default.lora_B @ lora_A;.diff/.diff_b;scale_shift_table→.diff_param;.set_weight;.set_param;Exact CPU SVD remains the default for backward compatibility. GPU and randomized SVD are opt-in.
Test Plan
A full MiniMax-H3 extraction was also run on one GB200:
The extracted adapter was then loaded through the MiniMax-H3 LoRA inference path and used to generate an eight-step FastH3 video.
Test Results
Test output
Full MiniMax-H3 extraction:
Comparison against the adapter previously produced by the specialized MiniMax-H3 extractor:
{ "old_keys": 852, "new_keys": 852, "key_sets_equal": true, "unequal_tensors": 0, "max_abs_difference": 0.0 }End-to-end FastH3 inference:
The existing Wan2.2 integration example now extracts on
cuda:0, retains runtime-unsupported boundary matrices as exact deltas, constructs the real FastVideoWanDMDPipeline, and asserts that all 300 factorized matrices reach a layer.Checklist
pre-commit run --all-filesand fixed all issuesFor model/pipeline changes, also check:
Not applicable; this PR changes the extraction utility and does not modify model or pipeline numerics.