Repository navigation
[megatron] GLM-5.3-Flash (glm5_next) support: KDA + k-pool DSA + mHC MoE, full fine-tuning and LoRA sync to vLLM (merge_lora=false) #2179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
7e0a541
x
erictang000 44dd547
Merge upstream/main into glm5.3-flash
erictang000 40f13ab
Merge upstream/main into glm5.3-flash
erictang000 21d6781
[test][megatron] Add an opt-in full GLM-5.3-Flash parity row for a si…
erictang000 30158df
[fix][glm5.3-flash] Unblock GLM-5.3-Flash RL: TileLang toolkit, vLLM …
erictang000 5a2aece
[example][glm5.3-flash] Add GSM8K and DAPO LoRA recipes for GLM-5.3-F…
erictang000 ca7ccec
[experiment][glm5.3-flash] Vendor NVIDIA/Megatron-LM#7054 for the DSA…
erictang000 2467dcb
[test][glm5.3-flash] Add a DSA parity row past dsa_indexer_topk
erictang000 235e4b8
Merge k-pool vendoring: adopt NVIDIA/Megatron-LM#7054 instead of impl…
erictang000 390f13d
[deps] Drop the experiment framing from the megatron-core pin comment
erictang000 c67ce3e
[example][glm5.3-flash] Raise DAPO context now that k-pool lifts the …
erictang000 d5451f6
Merge branch 'main' of https://github.com/NovaSky-AI/SkyRL into glm5.…
erictang000 dd1b26b
[docs] Add a merge_lora=false investigation handoff for GLM-5.3-Flash
erictang000 21d2b63
[example][glm5.3-flash] DAPO: per-expert LoRA at rank 64, and stop pe…
erictang000 47c53af
[example][glm5.3-flash] Size the DAPO recipes for a 2-node cluster
erictang000 ac927d4
add a test for lora + glm5.3flash
erictang000 ab8d9f4
Merge branch 'glm5.3-flash' of https://github.com/erictang000/SkyRL i…
erictang000 5908cc4
[example][glm5.3-flash] Give the DAPO recipes their vLLM LoRA plumbing
erictang000 ac9a073
[glm5.3-flash] Apply the kv_b_proj LoRA adapter on MLA's decode path
erictang000 e14c1f6
[test][glm5.3-flash] Cover full trainer checkpointing with LoRA
erictang000 f3f8f3a
[docs][glm5.3-flash] Record the full-scale merge_lora=false results a…
erictang000 12ed2f2
[glm5.3-flash] Make VLLM_START_PORT overridable via SKYRL_VLLM_START_…
erictang000 b8784aa
Merge origin/main into glm5.3-flash (vLLM 0.30, R3 + LoRA)
erictang000 b179e9c
[docs][glm5.3-flash] Record the 25-step DAPO results and the R3 relau…
erictang000 6b58a2e
[example][glm5.3-flash] Make the sync DAPO recipe the 2k/8k run, drop…
erictang000 b6d98e4
[test][glm5.3-flash] Split the k-pool checks and label them as megatr…
erictang000 e0e9590
[docs] Fix the documented CPU test commands and note the Ray-attach p…
erictang000 b5bd182
[glm5.3-flash] Drop the FA4 cute-import patch, superseded by the comb…
erictang000 7e76219
[glm5.3-flash] Vendor the k-pool DSA indexer and return megatron-core…
erictang000 806a800
[docs][glm5.3-flash] Add validation gates for the vendored k-pool ind…
erictang000 de3b9b0
[glm5.3-flash] Re-anchor the MLA kv_b_proj LoRA patch for vLLM 0.30
erictang000 92ea966
[glm5.3-flash] Keep the DSA indexer's submodules when swapping in Glm…
erictang000 ac7055b
Merge remote-tracking branch 'upstream/main' into pr-2179
erictang000 f136147
[glm5.3-flash] Run the k-pool top-k inside DSAttention.forward
erictang000 fb2b424
[glm5.3-flash] Move glm5_next and mcore_ext under patches/megatron
erictang000 c456190
[glm5.3-flash] Put the Megatron upstreaming/removal plan in patches/m…
erictang000 14d2b6d
[glm5.3-flash] Prepare for merge: drop branch/experiment references a…
erictang000 0b2b17e
Merge remote-tracking branch 'upstream/main' into pr-2179
erictang000 d7216d4
[glm5.3-flash] Move the GLM-5.3-Flash LoRA row into test_megatron_lor…
erictang000 3f1fd69
[tests] Mirror patches/ in the test tree: tests for patched code live…
erictang000 94acaf3
[glm5.3-flash] Apply ruff/black to glm5_next/dsa.py
erictang000 3bf0640
[glm5.3-flash] Backport vllm#56718: apply kv_b_proj LoRA in MLA prefill
erictang000 a6fa500
[glm5.3-flash] Raise the GLM LoRA row's LoRA-B multiplier to 8.0
erictang000 d9719a6
[glm5.3-flash] Rename the LoRA DAPO recipe to 2node; add an 8-node fu…
erictang000 7837009
[glm5.3-flash] Credit the upstream authors of the vendored GLM-5.3-Fl…
erictang000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
53 changes: 53 additions & 0 deletions
53
skyrl/backends/skyrl_train/patches/megatron/patch_fa4_cute_import.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| """Keep a broken FlashAttention-4 (``flash_attn.cute``) install from taking down ``megatron.core``. | ||
|
|
||
| flash-attn 2.8.x ships the FA4 ``flash_attn.cute`` package alongside FA2. It is written against | ||
| a specific ``nvidia-cutlass-dsl`` release; vLLM >= 0.28.1 pins a newer cutlass DSL whose | ||
| ``cutlass.cute.core`` no longer has the symbols FA4 imports (``ThrMma``), so importing | ||
| ``flash_attn.cute`` raises ``AttributeError`` rather than ``ImportError``. | ||
|
|
||
| ``megatron.core.transformer.attention`` probes FA4 with ``from flash_attn.cute import | ||
| flash_attn_varlen_func`` guarded only by ``except ImportError`` (megatron-core 0.20), so the | ||
| ``AttributeError`` escapes and every ``import megatron.core`` fails. SkyRL never uses FA4 (TE | ||
| dispatches to FA2 or cuDNN fused attention), so when the probe import fails for any reason | ||
| other than a plain ``ImportError`` we register ``flash_attn.cute`` as unavailable | ||
| (``sys.modules[name] = None`` makes any later import of it raise ``ImportError``), which is | ||
| exactly the state megatron-core handles. | ||
|
|
||
| No-op when ``flash_attn.cute`` imports cleanly or is genuinely absent. Call it before the first | ||
| ``megatron`` import in a process; ``skyrl.backends.skyrl_train.workers.megatron`` does so on | ||
| package import. | ||
|
|
||
| DELETE THIS PATCH once megatron-core's FA4 probe catches ``Exception`` or the flash-attn / | ||
| cutlass DSL pins agree again. | ||
| """ | ||
|
|
||
| import importlib | ||
| import sys | ||
|
|
||
| from loguru import logger | ||
|
|
||
| _MODULE = "flash_attn.cute" | ||
| _PATCHED_FLAG = "_skyrl_fa4_cute_import_patched" | ||
|
|
||
|
|
||
| def patch_fa4_cute_import() -> bool: | ||
| """Return True if ``flash_attn.cute`` was marked unavailable, False if nothing was needed.""" | ||
| if getattr(sys, _PATCHED_FLAG, False): | ||
| return sys.modules.get(_MODULE, True) is None | ||
| setattr(sys, _PATCHED_FLAG, True) | ||
| if _MODULE in sys.modules: | ||
| return sys.modules[_MODULE] is None | ||
| try: | ||
| importlib.import_module(_MODULE) | ||
| return False | ||
| except ImportError: | ||
| return False # genuinely absent: megatron-core already handles this | ||
| except Exception as exc: # e.g. AttributeError from a cutlass DSL mismatch | ||
| for name in [m for m in sys.modules if m == _MODULE or m.startswith(_MODULE + ".")]: | ||
| del sys.modules[name] | ||
| sys.modules[_MODULE] = None | ||
| logger.warning( | ||
| f"`{_MODULE}` (FlashAttention-4) failed to import with {type(exc).__name__}: {exc}. " | ||
| "Marking it unavailable so megatron-core falls back to FA2 / cuDNN attention." | ||
| ) | ||
| return True |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """Megatron backend workers. | ||
|
|
||
| The package import runs :func:`patch_fa4_cute_import` first: with the pinned flash-attn and | ||
| the cutlass DSL that vLLM >= 0.28.1 pulls in, ``import megatron.core`` otherwise aborts on a | ||
| broken FlashAttention-4 probe (see the patch module). Every Megatron entry point in SkyRL | ||
| lives under this package, so this is the earliest common place to apply it. | ||
| """ | ||
|
|
||
| from skyrl.backends.skyrl_train.patches.megatron.patch_fa4_cute_import import ( | ||
| patch_fa4_cute_import, | ||
| ) | ||
|
|
||
| patch_fa4_cute_import() |
14 changes: 14 additions & 0 deletions
14
skyrl/backends/skyrl_train/workers/megatron/glm5_next/__init__.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| """GLM-5.3-Flash (HF ``glm5_next``) for the Megatron backend. | ||
|
|
||
| Shaped for an upstream home in Megatron-Bridge (``megatron/bridge/models/glm/``): | ||
|
|
||
| - ``provider``: ``Glm5NextModelProvider`` (MLA provider + KDA / mHC / kpool fields). | ||
| - ``layer_specs``: per-layer KDA-or-DSA, dense-or-MoE block spec built on | ||
| ``HyperConnectionTransformerLayer``. | ||
| - ``dsa``: the GLM-5.3-Flash flavour of ``DSAttention`` (NoPE MLA + kpool-compressed indexer). | ||
| - ``bridge``: ``Glm5NextBridge``, HF <-> Megatron parameter mapping for the language model of the | ||
| ``Glm5NextForConditionalGeneration`` checkpoint. Importing it registers the bridge. | ||
|
|
||
| The Megatron-Core-side building blocks (mHC layer, KDA module) live in | ||
| ``skyrl.backends.skyrl_train.workers.megatron.mcore_ext``. | ||
| """ |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.