Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9f19b2c
feat: adapt torchtitan dev 20260713
hann-wang Jul 14, 2026
3a46ed3
fix: apply_rotary_emb_complex patch
hann-wang Jul 14, 2026
b9786c9
fix: token dispatcher with paded tokens;
hann-wang Jul 14, 2026
a9efbdb
feat: basic DTensor support in wanda
hann-wang Jul 15, 2026
ff64beb
fix: restore from_linear() classmethod and update test constructor usage
Copilot Jul 15, 2026
06e4f2f
fix: gpt_oss_20b optimizer and dataloader issues
hann-wang Jul 17, 2026
e84bc2d
Potential fix for pull request finding
hann-wang Jul 17, 2026
a1a8fab
fix: propagate lora_rank to DecomposedLinear.Config
hann-wang Jul 17, 2026
e45f460
Merge branch 'han/torchtitan-20260713' of https://github.com/AMD-AGI/…
hann-wang Jul 17, 2026
536c13d
fix: checkpoint manager failed to access untyped storage if tensor wr…
hann-wang Jul 20, 2026
db5fcf3
Potential fix for pull request finding
hann-wang Jul 20, 2026
dfc194a
Potential fix for pull request finding
hann-wang Jul 20, 2026
24ed297
fx: missing trainer for de-osc
hann-wang Jul 24, 2026
5e20087
[WIP] feat: madam optimizer
hann-wang Jul 27, 2026
ec147ef
test: decompsoed linear with svd init
hann-wang Jul 28, 2026
046589e
feat: universal optimal scaling (uos) for mxfp4
hann-wang Aug 4, 2026
5bb9208
fix: _quantize_then_mxfp_scaled_grouped_mm with uos
hann-wang Aug 4, 2026
29aab52
fix: de-osc with uos
hann-wang Aug 7, 2026
88b7d5a
feat: pre-split microbatches
hann-wang Aug 10, 2026
e9d3f5a
fix: token dispatcher swap
hann-wang Aug 11, 2026
04e87d7
fix: missing loop index
hann-wang Aug 12, 2026
7d88e38
Merge branch 'main' into han/torchtitan-20260713
hann-wang Aug 17, 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
2 changes: 1 addition & 1 deletion 3rdparty/torchtitan
Submodule torchtitan updated 591 files
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v0.1.0 [dev]

- Changed
- Mixed precision is now handled by FSDP even if world_size=1.
- Dropped Instella-3B model config.
Comment thread
hann-wang marked this conversation as resolved.
Comment on lines +5 to +7


## v0.0.2 [dev]

- Changed
Expand Down
8 changes: 8 additions & 0 deletions alto/components/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: MIT

from typing import TYPE_CHECKING
from dataclasses import dataclass

import torch
Expand All @@ -15,6 +16,9 @@

from alto.config import Recipe

if TYPE_CHECKING:
from torchtitan.models.base import BaseModel


class ModelOptConverter(ModelConverter, Configurable):

Expand Down Expand Up @@ -45,6 +49,10 @@ def convert(self, model: nn.Module):

for modifier in self.recipe.modifiers:
modifier.convert(model)

def convert_config(self, model_config: "BaseModel.Config"):
for modifier in self.recipe.modifiers:
modifier.convert_config(model_config)

def pre_step(self, model_parts: list[nn.Module], **kwargs):
for modifier in self.recipe.modifiers:
Expand Down
4 changes: 2 additions & 2 deletions alto/kernels/dispatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from .config import TrainingOpConfig
from .conversion import swap_params
from .attention import LPScaledDotProductAttentionWrapper
from .attention import LPScaledDotProductAttention

__all__ = [
"TrainingOpConfig",
"swap_params",
"LPScaledDotProductAttentionWrapper",
"LPScaledDotProductAttention",
]
32 changes: 23 additions & 9 deletions alto/kernels/dispatch/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# SPDX-License-Identifier: MIT

import torch
from torchtitan.models.common.attention import (ScaledDotProductAttentionWrapper)
from torchtitan.models.common.attention import (ScaledDotProductAttention)

from alto.kernels.fp4.mxfp4.triton_flash_attention_mxfp4 import triton_attention_mxfp4
from .config import TrainingOpConfig

__all__ = ["LPScaledDotProductAttentionWrapper"]
__all__ = ["LPScaledDotProductAttention"]


class LPScaledDotProductAttentionWrapper(ScaledDotProductAttentionWrapper):
class LPScaledDotProductAttention(ScaledDotProductAttention):

def __init__(self, config: TrainingOpConfig):
super().__init__()
Expand All @@ -25,17 +25,30 @@ def __init__(self, config: TrainingOpConfig):

def _get_name(self) -> str:
return f"{self.__class__.__name__}[{self.config}]"

def forward(
self,
q: torch.Tensor,
k: torch.Tensor,
v: torch.Tensor,
q_BLNH: torch.Tensor,
k_BLNH: torch.Tensor,
v_BLNH: torch.Tensor,
*,
attention_masks: None = None,
scale: float | None = None,
Comment on lines 34 to 36
enable_gqa: bool = False,
is_causal: bool = True,
):
**kwargs,
) -> torch.Tensor:
if attention_masks is not None:
raise ValueError(
"ScaledDotProductAttention does not support attention_masks; it "
"only supports causal/non-causal attention via is_causal."
)
# Transpose to (B, N, L, H) for SDPA
q, k, v = (
q_BLNH.transpose(1, 2),
k_BLNH.transpose(1, 2),
v_BLNH.transpose(1, 2),
)
batch, num_head_q, seqlen_q, head_dim_qk = q.shape
batch_k, num_head_kv, seqlen_kv, head_dim_qk_k = k.shape
batch_v, num_head_kv_v, seqlen_kv_v, head_dim_v = v.shape
Expand Down Expand Up @@ -64,4 +77,5 @@ def forward(
use_exp2=True,
layout="bhsd",
)[0]
return o
# Transpose back to (B, L, N, H)
return o.transpose(1, 2)
2 changes: 1 addition & 1 deletion alto/kernels/dispatch/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def post_order_traversal(
continue
module_prefix = f"{module_name}." if module_name else ""
full_param_name = f"{module_prefix}{cur_fqn}{'.' if cur_fqn else ''}{param_name}"
if target_parameter_name is None and param_name.endswith("bias"):
if target_parameter_name is None and "bias" in param_name:
logger.debug(f"Skipped {full_param_name} because it is a bias parameter")
continue
if not isinstance(param.data, TrainingWeightWrapperBaseTensor):
Expand Down
9 changes: 4 additions & 5 deletions alto/models/deepseek_v3/config_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

def deepseek_v3_debugmodel() -> Trainer.Config:
config = deepseek_v3_debugmodel_orig()
config.profiling.enable_profiling = False
config.profiler.enable_profiling = False
config.training.steps = 10
config.training.local_batch_size = 4
config.training.global_batch_size = 16
config.training.seq_len = 2048
config.activation_checkpoint.mode = "none"
config.activation_checkpoint = None
config.debug.seed = 1234
return config

Expand All @@ -43,7 +43,7 @@ def deepseek_v3_16b() -> Trainer.Config:
config = deepseek_v3_16b_orig()
config.hf_assets_path = "/huggingface/hub/models--deepseek-ai--deepseek-moe-16b-base/snapshots/521d2bc4fb69a3f3ae565310fcc3b65f97af2580"
config.dump_folder = "deepseek_v3_16b-outputs"
config.profiling.enable_profiling = False
config.profiler.enable_profiling = False
config.training.steps = 0
config.training.local_batch_size = 1
config.training.seq_len = 4096
Expand All @@ -61,8 +61,7 @@ def deepseek_v3_16b() -> Trainer.Config:
config.validator.dataloader.dataset = "wikitext_test"
config.validator.freq = 10
config.validator.steps = 10
config.activation_checkpoint.mode = "none"
config.activation_checkpoint.selective_ac_option = "1"
config.activation_checkpoint = None
config.debug.seed = 1234
return config

Expand Down
2 changes: 1 addition & 1 deletion alto/models/deepseek_v3/configs/lpt_recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ training_stage:
LowPrecisionTrainingModifier:
scheme: "mxfp4"
targets: ["Linear", "GroupedExperts"]
ignore: ["output", "re:.*\\.router\\.gate"]
ignore: ["lm_head", "re:.*\\.router\\.gate"]
use_2dblock_x: false
use_2dblock_w: true
use_hadamard: true
Expand Down
12 changes: 6 additions & 6 deletions alto/models/gpt_oss/config_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

def gpt_oss_debugmodel() -> Trainer.Config:
config = gpt_oss_debugmodel_orig()
config.profiling.enable_profiling = False
config.profiler.enable_profiling = False
config.training.steps = 10
config.training.local_batch_size = 4
config.training.global_batch_size = 16
config.training.seq_len = 2048
config.activation_checkpoint.mode = "none"
config.activation_checkpoint = None
config.debug.seed = 1234
return config

Expand All @@ -44,7 +44,7 @@ def gpt_oss_20b() -> Trainer.Config:
config = gpt_oss_20b_orig()
config.hf_assets_path = "/huggingface/hub/models--openai--gpt-oss-20b/snapshots/6cee5e81ee83917806bbde320786a8fb61efebee/"
config.dump_folder = "gpt_oss_20b-outputs"
config.profiling.enable_profiling = False
config.profiler.enable_profiling = False
config.training.steps = 0
config.training.local_batch_size = 1
config.training.seq_len = 8192
Expand All @@ -63,7 +63,7 @@ def gpt_oss_20b() -> Trainer.Config:
config.validator.dataloader.dataset = "wikitext_test"
config.validator.freq = 10
config.validator.steps = 10
config.activation_checkpoint.mode = "none"
config.activation_checkpoint = None
config.debug.seed = 1234
return config

Expand All @@ -72,7 +72,7 @@ def gpt_oss_20b_pretrain() -> Trainer.Config:
config = gpt_oss_20b_orig()
config.hf_assets_path = "/huggingface/hub/models--openai--gpt-oss-20b/snapshots/6cee5e81ee83917806bbde320786a8fb61efebee/"
config.dump_folder = "gpt_oss_20b-pretrain-subset-lr4e-4-outputs"
config.profiling.enable_profiling = False
config.profiler.enable_profiling = False
config.training.steps = 1200000
config.training.local_batch_size = 1
config.training.global_batch_size = 16
Expand Down Expand Up @@ -101,7 +101,7 @@ def gpt_oss_20b_pretrain() -> Trainer.Config:
config.validator.dataloader.dataset_path = "/workspace/workspace/megatron_dataset/data/c4-validation-91205-samples.en_text_document.idx"
config.validator.freq = 768
config.validator.steps = 64
config.activation_checkpoint.mode = "none"
config.activation_checkpoint = None
config.debug.seed = 1234
return config

Expand Down
2 changes: 1 addition & 1 deletion alto/models/gpt_oss/configs/lpt_recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ training_stage:
scheme: "mxfp4"
targets: ["Linear", "GptOssGroupedExperts"]
# targets: ["Linear"]
ignore: ["output", "re:.*\\.router\\.gate"]
ignore: ["lm_head", "re:.*\\.router\\.gate"]
use_2dblock_x: false
use_2dblock_w: true
use_hadamard: true
Expand Down
Loading