Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ea1af52
fix: align THD MoE aux-loss token accounting with valid tokens
DAISY-gh Apr 9, 2026
da9d926
fix: wire padding_mask through qwen3-vl gpt forward path
DAISY-gh Apr 9, 2026
653dd62
fix: pass padding_mask into qwen gpt postprocess mtp path
DAISY-gh Apr 9, 2026
88a8ac2
fix: update Megatron-LM pointer for main-based THD support
DAISY-gh Apr 9, 2026
924497c
fix: make diffusion recipe imports optional
DAISY-gh Apr 10, 2026
552282d
fix: guard optional deps for Qwen-VL recipe startup
DAISY-gh Apr 10, 2026
2464771
feat: add qwen35_vl_35b_a3b_sft_energon_config recipe
DAISY-gh Apr 10, 2026
7d4502d
fix: add packing_buffer_size to EnergonProvider and harden Qwen3VLPro…
DAISY-gh Apr 13, 2026
9422407
feat: Add Energon THD packing support for QwenVL TaskEncoder and vlm_…
DAISY-gh Mar 31, 2026
6af4f0f
feat: Add Energon SFT recipe for Qwen3.5-VL 35B-A3B with THD packing
DAISY-gh Mar 31, 2026
fd4215f
fix: QwenVLTaskBatch missing Energon 7.x __key__/__restore_key__ and …
DAISY-gh Apr 1, 2026
cfffa6a
fix: patch MTP attention with Qwen3VLSelfAttention for correct M-RoPE
DAISY-gh Apr 2, 2026
a6cd85f
fix: correctly pass padded/unpadded cu_seqlens for packed sequence TH…
DAISY-gh Apr 7, 2026
1bafcda
fix: extend last segment boundary instead of adding zero-length paddi…
DAISY-gh Apr 7, 2026
be4105d
fix: use padded cu_seqlens for all fields following Megatron-LM data_…
DAISY-gh Apr 7, 2026
32ae832
fix: compute MRoPE per sub-sequence for packed sequences to fix 22x l…
DAISY-gh Apr 8, 2026
198b12e
fix: force Qwen-VL to recompute MRoPE in-model for THD
DAISY-gh Apr 8, 2026
cf7c7c5
fix: restore THD diagnostic helper symbols in Qwen3VL model
DAISY-gh Apr 13, 2026
cbeb228
fix: harden Energon QwenVL batch assembly for packed visual inputs
DAISY-gh Apr 13, 2026
0f51a2c
fix: remove temporary THD debug logging noise
DAISY-gh Apr 13, 2026
c57be63
fix: gate THD diagnostics and remove hardcoded IterStats token id
DAISY-gh Apr 13, 2026
8e07070
chore: add THD low-content dataloader diagnostics
DAISY-gh Apr 13, 2026
be70e4f
fix: wire THD runtime switches into vlm step paths
DAISY-gh Apr 14, 2026
24b0503
fix: split packed boundaries for rope and kernels
DAISY-gh Apr 14, 2026
583f185
fix: keep THD kernels padded while using unpadded rope boundaries
DAISY-gh Apr 14, 2026
5813386
chore: add THD mask alignment diagnostics
DAISY-gh Apr 14, 2026
bacf813
fix: use explicit THD MoE padding mask
DAISY-gh Apr 14, 2026
552d4a7
fix: cast attention mask to bool for THD mask remap
DAISY-gh Apr 14, 2026
d801e7b
chore: add THD label/loss alignment diagnostics
DAISY-gh Apr 14, 2026
bab9f91
chore: add THD MRoPE position diagnostics
DAISY-gh Apr 14, 2026
10f6d78
fix: enforce bool masks for THD packed remap
DAISY-gh Apr 14, 2026
03711a9
chore: add strict THD MRoPE remap check
DAISY-gh Apr 14, 2026
c68367c
chore: add THD boundary diagnostics switch
DAISY-gh Apr 14, 2026
85a54c2
chore: clarify packed-seq boundary documentation
DAISY-gh Apr 14, 2026
03ca9c7
feat: expose energon shuffle buffer override
DAISY-gh Apr 14, 2026
a0b5fd5
chore: sync nodebug training updates without submodule bump
DAISY-gh Apr 14, 2026
0525c55
refactor: split batch-level and in-batch packing switches
DAISY-gh Apr 14, 2026
0f5ee33
fix: disable packing defaults in energon recipe
DAISY-gh Apr 14, 2026
2a018ec
fix: address optional import handling and recipe docs feedback
DAISY-gh Apr 14, 2026
23d6bc3
fix: harden packed seqlens trimming and gate unsupported qwen3 batch-…
DAISY-gh Apr 14, 2026
970e236
fix: address reviewer feedback for qwen-vl packing path
DAISY-gh Apr 20, 2026
0b71929
docs: clarify in-batch vs batch-level packing semantics
DAISY-gh Apr 20, 2026
fcd0854
refactor: move qwen3-vl diag helpers into existing utils
DAISY-gh Apr 20, 2026
34f8e58
chore: align Megatron-LM submodule pointer with main
DAISY-gh Apr 20, 2026
a85bce1
fix: enforce strict qwen-vl task encoder config sourcing
DAISY-gh Apr 22, 2026
3880d0f
Merge branch 'main' into thd-support-main
yaoyu-33 Apr 28, 2026
e4a88ee
chore: ruff isort fix on merge-resolved files
yaoyu-33 Apr 28, 2026
50b5557
fix: resolve lint blockers in qwen-vl checks
DAISY-gh Apr 28, 2026
5cfd9a9
Merge branch 'main' into thd-support-main
yaoyu-33 Apr 30, 2026
d2b73cc
style: ruff-format vlm_step.py after merge
yaoyu-33 Apr 30, 2026
db73764
refactor(vlm_step): use shared is_rank_0() helper instead of local _r…
yaoyu-33 Apr 30, 2026
b319cd1
style: ruff lint and format fixes
yaoyu-33 May 1, 2026
6c46f04
fix: restore qwen3-vl is_rank_0 re-export
DAISY-gh May 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions src/megatron/bridge/data/energon/energon_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
from dataclasses import dataclass
from typing import Any, Optional

Expand All @@ -33,20 +34,47 @@ class EnergonProvider(DatasetProvider):
num_workers: int_repr
dataloader_type: str = "external"
task_encoder: Optional[Any] = None
# Enable batch-level online sequence packing
# Existing in-batch packing switch.
# Semantics: pack samples *within each already formed micro-batch*.
# This path keeps historical behavior used by existing recipes.
pack_sequences_in_batch: bool = False
# THD dataloader switch for batch-level online packing.
# Semantics: pack samples *across a dataloader-side candidate buffer*
# before a micro-batch is formed.
# This mode is independent from pack_sequences_in_batch.
batch_level_packing: bool = False
packing_buffer_size: Optional[int] = None
shuffle_buffer_size: int = 100
# Optional bin selector for datasets split into bin directories.
# Used to pin data selection and align comparisons with Energon BSHD.
cord_bins_root: Optional[str] = None
cord_bin_prefix: str = "cord_bin_"
cord_bin_id: Optional[str] = None

def build_datasets(self, context: DatasetBuildContext):
assert self.path, "EnergonProvider.path must be set. Use CLI override: dataset.path=<path>"
resolved_path = self.path
if self.cord_bin_id is not None and self.cord_bin_id != "":
assert self.cord_bins_root, (
"EnergonProvider.cord_bins_root must be set when dataset.cord_bin_id is provided."
)
resolved_path = os.path.join(self.cord_bins_root, f"{self.cord_bin_prefix}{self.cord_bin_id}")

assert resolved_path, "EnergonProvider.path must be set. Use CLI override: dataset.path=<path>"
if self.task_encoder is not None and hasattr(self.task_encoder, "seq_len"):
self.task_encoder.seq_len = self.seq_length
self.task_encoder.seq_length = self.seq_length
effective_packing_buffer_size = self.packing_buffer_size if self.batch_level_packing else None
dataset = EnergonMultiModalDataModule(
path=self.path,
path=resolved_path,
tokenizer=context.tokenizer if context.tokenizer is not None else self.tokenizer,
image_processor=self.image_processor,
seq_length=self.seq_length,
task_encoder=self.task_encoder,
micro_batch_size=self.micro_batch_size,
global_batch_size=self.global_batch_size,
num_workers=self.num_workers,
packing_buffer_size=effective_packing_buffer_size,
shuffle_buffer_size=self.shuffle_buffer_size,
pg_collection=context.pg_collection,
)
return (
Expand Down
16 changes: 15 additions & 1 deletion src/megatron/bridge/models/conversion/auto_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

from megatron.core.transformer.module import MegatronModule
from megatron.core.transformer.transformer_config import MLATransformerConfig, TransformerConfig
from modelopt.torch.quantization.utils import is_quantized
from safetensors.torch import save_file
from transformers.configuration_utils import PretrainedConfig
from typing_extensions import Unpack
Expand All @@ -51,6 +50,21 @@

logger = logging.getLogger(__name__)

try:

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.

why change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good question. The change intentionally narrows the optional-import fallback from broad Exception to ImportError, so we do not mask unrelated runtime errors while still keeping graceful fallback when modelopt/scipy is unavailable. This keeps the quantized-export path optional but makes real failures visible in logs.

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.

is this still needed now that modelopt version is bumped?

from modelopt.torch.quantization.utils import is_quantized
except ImportError as exc:
# modelopt/scipy is optional for recipe import and training startup.
# Keep quantization-only export path available when dependency exists.
logger.warning(
"modelopt quantization utils unavailable; quantized-export detection disabled: %s",
exc,
)

def is_quantized(_model: object) -> bool:
"""Fallback quantization probe when ModelOpt is unavailable."""
return False
Comment thread
coderabbitai[bot] marked this conversation as resolved.


MegatronModelT = TypeVar("MegatronModelT", bound=MegatronModule)
DataclassT = TypeVar("DataclassT")

Expand Down
Loading
Loading