Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
2bdd509
expr: mi308 config
hann-wang Apr 16, 2026
40fd074
fix: fsdp sharded param without gradient
hann-wang Apr 20, 2026
a0a1056
Merge branch 'han/static_clip' into han/gpt_oss_mi308
hann-wang Apr 27, 2026
f1a8f49
Merge remote-tracking branch 'origin/han/static_clip' into han/gpt_os…
hann-wang Apr 28, 2026
a03db10
expr: mxfp4 with mbs
hann-wang Apr 28, 2026
b6e082f
chore: refactor mbs to use the same grid for both 1D/2D blocks
hann-wang Apr 28, 2026
27fa9e4
chore: skip unnecessary init
hann-wang Apr 28, 2026
86f0f28
fix: rescale gradients only when clip_mode=static
hann-wang Apr 28, 2026
fdc2de0
Merge branch 'han/static_clip' into han/gpt_oss_mi308
hann-wang Apr 28, 2026
145e68d
expr: mixed-precision
hann-wang May 11, 2026
c585096
Merge remote-tracking branch 'origin/main' into han/gpt_oss_mi308
hann-wang May 11, 2026
f5f68ae
fix: llama3_8b_lpt config
hann-wang May 11, 2026
72c7613
expr: skip qkvo proj
hann-wang May 14, 2026
c3dece2
Merge branch 'han/gpt_oss_mi308' of https://github.com/AMD-AGI/ALTO i…
hann-wang May 14, 2026
4decef7
Merge remote-tracking branch 'origin/han/decomposed-linear' into han/…
hann-wang May 14, 2026
0ce40ee
Merge remote-tracking branch 'origin/han/decomposed-linear' into han/…
hann-wang May 14, 2026
856cbb2
expr: decomp linear
hann-wang May 18, 2026
8532ab2
expr: k8s entrypoint
hann-wang May 18, 2026
5337b61
Merge remote-tracking branch 'origin/main' into han/gpt_oss_mi308
hann-wang May 25, 2026
2cf03c6
hotfix: init failure on meta device
hann-wang May 25, 2026
4748662
mounted submodule, smoke scripts
YBouquet May 27, 2026
3513023
adahop internal packaging
YBouquet May 27, 2026
f9499c7
calibration wrapper, swap_params extension
YBouquet May 27, 2026
9875451
logging
YBouquet May 27, 2026
931d22c
fixture TrainingOpConfig
YBouquet May 27, 2026
e4331b8
Merge branch 'han/weight-deosc' into han/gpt_oss_mi308
hann-wang May 28, 2026
2c6667b
feat: enable de-osc by env var
hann-wang May 28, 2026
d6dc693
hotfix: de-osc with FSDP for GPT-OSS 20B model
hann-wang May 28, 2026
ec9a5b9
update short bash
YBouquet May 29, 2026
7eb313a
fix(mxfp4): use ctx.original_dtype in backward to match saved x_dq/w_dq
YBouquet May 29, 2026
3426fde
update integration test bashes
YBouquet May 29, 2026
8d4be68
Merge branch 'fix/mxfp4-backward-dtype' into yann_adahop
YBouquet May 29, 2026
1e46eac
Merge branch 'fix/mxfp4-backward-dtype' into yann_adahop
YBouquet Jun 1, 2026
e05ab9b
Merge branch 'yann_adahop' of github.com:AMD-AGI/ALTO into yann_adahop
YBouquet Jun 1, 2026
19e102e
unwrap DTensor in discovery and preserve sharding in re-swap
YBouquet Jun 1, 2026
f0364fe
Merge branch 'yann_adahop' of github.com:AMD-AGI/ALTO into yann_adahop
YBouquet Jun 1, 2026
187b65a
update dispatch to detect callback on the source wrapper
YBouquet Jun 1, 2026
acf6f0b
Merge branch 'yann_adahop' of github.com:AMD-AGI/ALTO into yann_adahop
YBouquet Jun 1, 2026
20fdbbb
fsdp_post_all_gather in MXFP4CalibrationWrapper
YBouquet Jun 1, 2026
ac8b92e
Merge branch 'yann_adahop' of github.com:AMD-AGI/ALTO into yann_adahop
YBouquet Jun 1, 2026
1bba2e1
use pre-hooks for inputs and weights
YBouquet Jun 1, 2026
e78d2ff
Merge branch 'yann_adahop' of github.com:AMD-AGI/ALTO into yann_adahop
YBouquet Jun 1, 2026
8b99288
add log for torch_function *mxfp4* path
YBouquet Jun 1, 2026
2298c7f
update logs
YBouquet Jun 1, 2026
f75bceb
update log
YBouquet Jun 1, 2026
083737c
remove pre-hook, try wrapper again by solving the id mismatch issue
YBouquet Jun 1, 2026
2a3addd
fix: attach calibration callback to canonical wrapper, not weight.data
YBouquet Jun 1, 2026
e137966
log for ngpu=2 debugging
YBouquet Jun 1, 2026
0df3c96
debug fsdp state
YBouquet Jun 1, 2026
66e4948
fix: attach calibration callback via fsdpparam._shared_local_tensor
YBouquet Jun 1, 2026
9733642
fix cdna3
YBouquet Jun 1, 2026
f22e06c
lpt_adahop recipe
YBouquet Jun 1, 2026
c010697
port adahop strategies (inner_outlier_extract_[right/left])
YBouquet Jun 1, 2026
18aa82a
fix: iht_quantization.py imports from torchtitan.experiments.kernels.…
YBouquet Jun 1, 2026
bfb17ab
fix: explicit importation for foid
YBouquet Jun 1, 2026
ce5418b
increase number of iteration steps
YBouquet Jun 1, 2026
1a94536
feat: add DEOSC_RATIO env
hann-wang Jun 2, 2026
1b5f297
expr: llama3 mxfp4
hann-wang Jun 2, 2026
71ff836
fix: tensor dispatch with TP enabled
hann-wang Jun 2, 2026
99586d5
Merge remote-tracking branch 'origin/main' into han/gpt_oss_mi308
hann-wang Jun 2, 2026
2b06b23
expr: decrease lbs of llama3-8b
hann-wang Jun 3, 2026
6969041
solve llama parallelization issue
YBouquet Jun 7, 2026
e179f5e
llama 3 registry
YBouquet Jun 7, 2026
f93288b
fix: nvfp4 de-osc padding
hann-wang Jun 8, 2026
262631d
config registry for gpt oss pretrain
YBouquet Jun 8, 2026
f782060
Merge remote-tracking branch 'origin/main' into han/gpt_oss_mi308
hann-wang Jun 9, 2026
c603d39
feat: enable nvfp4 tensor-wise scaling in de-osc
hann-wang Jun 9, 2026
80aca3f
add midmax implementation
nfrumkin Jun 11, 2026
dfbbd6d
Add new c4 dset paths
nfrumkin Jun 12, 2026
3fa55e3
Merge branch 'main' into yann_adahop
YBouquet Jun 16, 2026
883a7c8
debug observers
YBouquet Jun 16, 2026
1d50932
update config registry
YBouquet Jun 16, 2026
74b90e9
Merge branch 'yann_adahop' of github.com:AMD-AGI/ALTO into yann_adahop
YBouquet Jun 16, 2026
f10f283
fix viz
YBouquet Jun 17, 2026
5f40c74
Merge branch 'yann_adahop' of github.com:AMD-AGI/ALTO into yann_adahop
YBouquet Jun 17, 2026
dcc2a25
debug viz
YBouquet Jun 17, 2026
d638528
gradient clipping:
YBouquet Jun 17, 2026
649fca1
fix viz
YBouquet Jun 17, 2026
d913056
correct debug observer
YBouquet Jun 17, 2026
9268860
disable TP
YBouquet Jun 17, 2026
918c865
bf16 training mode when debugging
YBouquet Jun 17, 2026
3d43990
update lpt mode
YBouquet Jun 17, 2026
60363c1
correct histograms
YBouquet Jun 17, 2026
311a3ec
fsdp drops the module_id which affects the clipping
YBouquet Jun 17, 2026
1c9eb58
prepend clipping hook
YBouquet Jun 17, 2026
c331eac
remove fsdp
YBouquet Jun 17, 2026
69a4d69
debug clipping
YBouquet Jun 17, 2026
9a99fa8
check absmax
YBouquet Jun 17, 2026
26b85bf
clip before quantization, observe after clipping
YBouquet Jun 17, 2026
1c4e801
Apply working LPT fixes on yann_adahop: bias-skip in swap_params, dec…
arkhodamoradi Jun 23, 2026
40c0063
Add gpt_oss AdaHOP recipe and wire gpt_oss_20b_lpt to lpt_adahop.yaml
arkhodamoradi Jun 24, 2026
8261e20
checkpoint correction
arkhodamoradi Jun 24, 2026
551a2dc
AdaHOP: make it run + checkpoint on MI300 (gfx942/CDNA3) under FSDP
arkhodamoradi Jun 26, 2026
6a49876
moe patterns
YBouquet Jul 6, 2026
0b0af3a
Fix MXFP4 dw grouped-GEMM kernel compile on MI350 (gfx950/CDNA4)
YBouquet Jul 8, 2026
de658ba
correct adahop: router-gate ignored
YBouquet Jul 8, 2026
112dec0
add multinode dockerfile for distributed training
nfrumkin Jul 8, 2026
b75bc54
Fix AdaHOP weight gradient detached from autograd graph
YBouquet Jul 15, 2026
b23158d
Pass use_sr to inner_outlier_extract_right for unbiased grad quant
YBouquet Jul 15, 2026
f1f1746
Add AdaHOP investigation configs + randomized Hadamard for lpt_adahop
YBouquet Jul 15, 2026
a16f8b3
Add AdaHOP numerical-parity test and resume-divergence diagnostic
YBouquet Jul 15, 2026
3dc4364
Fix AdaHOP weight gradient detached from autograd graph
YBouquet Jul 15, 2026
abc0b9c
working training script
nfrumkin Jul 22, 2026
16e97ef
update c4 with pre-tokenized dset
nfrumkin Jul 22, 2026
e817426
Merge remote-tracking branch 'origin/main' into rad/lpt
nfrumkin Jul 22, 2026
bd4047c
checkpoint fix and dataloader for pre-tokenized c4
Jul 23, 2026
ed7f35c
add gptoss20b training script
nfrumkin Jul 24, 2026
6d268ca
fix mount of data directory into docker
nfrumkin Jul 24, 2026
532be0b
clean up script
nfrumkin Jul 24, 2026
2ba2e16
add faster docker cleanup after ctrl-c
nfrumkin Jul 24, 2026
b155dce
add more description to run script
nfrumkin Jul 24, 2026
1a51591
add notes to run script about ALTO dir
nfrumkin Jul 24, 2026
9892cdd
add description on how to view loss curves
nfrumkin Jul 24, 2026
7aed68a
rename container and data dir
nfrumkin Jul 24, 2026
2d02ae3
rename container
nfrumkin Jul 24, 2026
5dc525e
rename container and data dir
nfrumkin Jul 24, 2026
8ad51a3
fix printout so it's not always saying "bf16"
nfrumkin Jul 28, 2026
3420846
add experiment plotting script
nfrumkin Jul 28, 2026
447a406
make sure node's python env is not leaked to container, make checkpoi…
nfrumkin Jul 28, 2026
478b632
update plotting structure and add training grad norm & loss
nfrumkin Jul 28, 2026
72edc28
add M+Adam implementation and configs for M+Adam + Deosc
nfrumkin Jul 28, 2026
c454c3d
add checkpointing files to .gitignore
nfrumkin Jul 28, 2026
9bd0283
Ali's checkpointing fix
nfrumkin Jul 28, 2026
b1e6f2a
standardize config names
nfrumkin Jul 29, 2026
5aa8694
fix name of config in madam_stable
nfrumkin Jul 29, 2026
94a28df
fix __all__ with correct configs
nfrumkin Jul 29, 2026
b6e2c8c
add compatibility with several out files
nfrumkin Jul 30, 2026
9b6e455
fix multinode dockerfile so it's compatible with OCI
nfrumkin Jul 30, 2026
d90c26f
add info about testing RDMA
nfrumkin Jul 30, 2026
9ff72ca
add rdma testing procedures
nfrumkin Jul 30, 2026
83925cf
docker command to pass relevant RDMA devices to image
nfrumkin Jul 30, 2026
f7e8a1c
add automatic detection of libibverbs and RDMA provide modules
nfrumkin Jul 30, 2026
9a166bc
add update to test rdma backend
nfrumkin Jul 30, 2026
9ef9864
add info about testing RDMA
nfrumkin Jul 30, 2026
ffacea0
add multinode sbatch script
nfrumkin Jul 30, 2026
b727ad5
add mxfp4 base to config registry
nfrumkin Jul 31, 2026
57de119
add optional details arg and tensorboard support
nfrumkin Jul 31, 2026
935a9d2
config registry modif
YBouquet Aug 4, 2026
54b5c24
Merge branch 'yann_adahop_updated' into yann_moe
YBouquet Aug 4, 2026
8a52d89
update midmax implementation w/ comments and improve readability
nfrumkin Aug 4, 2026
b914268
test build multinode docker
nfrumkin Aug 4, 2026
5769da6
Merge branch 'main' into yann_moe
YBouquet Aug 5, 2026
4d0d3d3
add correct torchao version and slurm job id into run_id
nfrumkin Aug 5, 2026
c49fc62
add midmax compatibility w/ bw and grouped gemm
nfrumkin Aug 4, 2026
bfdff95
instead of dedicated "midmax" path, create more general scale selecti…
nfrumkin Aug 5, 2026
d8e36b1
make checkpoint dir have only slrum name so it auto loads when pre-em…
nfrumkin Aug 5, 2026
3bc7530
add plotting end step for viz
nfrumkin Aug 5, 2026
866202d
add more scale-selection options
nfrumkin Aug 6, 2026
294f0f4
add new scale selection configs
nfrumkin Aug 6, 2026
16ca725
update blockscale selection choices
nfrumkin Aug 6, 2026
eba7bee
assume ALTO dir is pwd
nfrumkin Aug 6, 2026
e31673e
fix dtype mxfp_linear, forward only quant on llama
YBouquet Aug 7, 2026
e979e83
make plot only have one loss value per step
nfrumkin Aug 7, 2026
9025df8
Merge branch 'rad/midmax' into rad/lpt
nfrumkin Aug 7, 2026
19db92b
Merge remote-tracking branch 'origin/yann_moe' into rad/lpt
nfrumkin Aug 7, 2026
9a97bec
Merge branch 'rad/scale-selection' into rad/lpt
nfrumkin Aug 7, 2026
a387724
fix bug with run_id
nfrumkin Aug 7, 2026
8ddb7a6
fix configs to point to original rad/lpt baseline lpt recipes
nfrumkin Aug 7, 2026
88c0bb5
make adahop configs point to original rad/lpt config files
nfrumkin Aug 7, 2026
5d611db
fix bug in plotting script
nfrumkin Aug 7, 2026
fa88c9f
adjustments to run script and config registery
Aug 7, 2026
47927a8
Update train_gptoss20b.sh
arkhodamoradi Aug 10, 2026
c6dc75d
Merge branch 'rad/lpt' into origin/rad/lpt_temp_ali
nfrumkin Aug 10, 2026
4170a41
Merge pull request #38 from AMD-AGI/origin/rad/lpt_temp_ali
nfrumkin Aug 10, 2026
951f444
update #steps to 17k
nfrumkin Aug 10, 2026
f2255f2
fix config error with ali-temp branch renaming
nfrumkin Aug 10, 2026
4d07a9f
Update 3RHT implementation
Aug 13, 2026
9e213d4
comment on legacy dataset ingestion for C4
nfrumkin Aug 14, 2026
bfb7f01
Merge pull request #41 from AMD-AGI/origin/rad/lpt_temp_ali
nfrumkin Aug 14, 2026
912cad8
some optimizations
arkhodamoradi Aug 16, 2026
49a7057
Merge pull request #42 from AMD-AGI/origin/rad/lpt_temp_ali
nfrumkin Aug 17, 2026
4501d4e
Update for fw and dgrad projection support and GPT-OSS config
arkhodamoradi Aug 27, 2026
88d1dbb
Restore hadamard transform weights
arkhodamoradi Aug 27, 2026
7fb56cc
Merge pull request #44 from AMD-AGI/rad/lpt_temp_ali
nfrumkin Aug 31, 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
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Build context for alto/Dockerfile.multinode is this directory (ALTO/).
# Keep large / irrelevant paths out of the context sent to the Docker daemon.
# gptoss_chkpt alone is ~9.6TB and must never be tarred into the build context.
.git
gptoss_chkpt/
logs/
comm_traces/
plotting/
examples/
tests/
slurm-*.out
*.out
error*.txt
sendit.toml
wait_and_run.sh
**/__pycache__/
**/*.pyc
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,19 @@ __marimo__/
datasets/
/models/
comm_traces/


# Slurm
*.out

# Checkpoints
*.distcp
gptoss_chkpt/
plotting/plots

*.safetensors

docker/
gpt_*/
*/plotting/
docs/
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "3rdparty/torchtitan"]
path = 3rdparty/torchtitan
url = https://github.com/hann-wang/torchtitan
[submodule "3rdparty/adahop"]
path = 3rdparty/adahop
url = git@github.com:AMDResearch/low-precision-training.git
branch = AdaHOP_C42
1 change: 1 addition & 0 deletions 3rdparty/adahop
Submodule adahop added at 38b475
98 changes: 98 additions & 0 deletions Dockerfile.multinode
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# torch 2.11 (+ matching torchvision/triton) is required by the bundled torchtitan,
# which uses torch>=2.11 APIs (torch.nn.attention.varlen, the
# wrap_inductor_compiled_regions inductor option, ...). There is no prebuilt
# torch 2.11 + ROCm 7.2 image, so this pins the validated ROCm 7.14 + torch 2.11.0
# build. NOTE: this bumps ROCm 7.2 -> 7.14; the Slurm hosts' amdgpu/KFD driver must
# support a ROCm 7.14 container userspace.
FROM rocm/pytorch:rocm7.14_ubuntu24.04_py3.12_pytorch_release_2.11.0

ARG DEBIAN_FRONTEND=noninteractive

# Port 80 to archive.ubuntu.com/security.ubuntu.com is blocked in this build
# environment, but 443 works. Rewrite every apt source (including the deb822
# /etc/apt/sources.list.d/ubuntu.sources used on noble) from http:// to https://.

# Packages
# ibverbs-utils for debug via to `rdma link show`
# iproute2 debug ip addresses such as RDMA ips
# perftest RDMA debug

RUN find /etc/apt -type f \
\( -name '*.list' -o -name '*.sources' \) \
-exec sed -i 's|http://|https://|g' {} + \
&& apt-get \
-o Acquire::ForceIPv4=true \
-o Acquire::Retries=5 \
-o Acquire::https::Timeout=30 \
update \
&& apt-get install -y \
git-lfs \
pkg-config \
clang \
libclang-dev \
libunwind-dev \
libnl-3-dev \
libnl-route-3-dev \
libibverbs-dev \
ibverbs-utils \
iproute2 \
perftest \
ibverbs-providers \
cmake \
pciutils \
&& (update-pciids || true)
# /var/lib/apt/lists is intentionally NOT removed, to keep apt usable for debugging.

RUN pip install --no-cache-dir huggingface_hub "datasets>=3.6.0" \
transformers tabulate wandb fsspec tyro "tokenizers>=0.15.0" safetensors \
tensorboard pre-commit yapf pybind11 meson-python torchdata pytablewriter \
"antlr4-python3-runtime==4.11.0" sympy math_verify more_itertools peft \
accelerate pillow "numpy<2" opencv-python-headless scipy \
numba huggingface-hub[cli,hf_transfer] "packaging>=24.2" \
"setuptools>=77.0.3,<80.0.0" "setuptools-scm>=8" \
protobuf-protoc-bin fmt

RUN mkdir -p /var/lib/jenkins && \
cd /var/lib/jenkins && \
git clone --depth 1 https://github.com/EleutherAI/lm-evaluation-harness && \
cd lm-evaluation-harness && \
pip install -e .

ENV PYTORCH_ROCM_ARCH="gfx90a;gfx942;gfx950"

# RDMA providers (the libibverbs plugins, e.g. libmlx5 / libbnxt_re) are ABI-tied
# to each host's rdma-core and kernel, which vary across our machines, so they are
# deliberately NOT baked into the image. rdma_tests/start_container.sh mounts the
# host's libibverbs userspace (library + provider modules + /etc/libibverbs.d)
# read-only at runtime, so the in-container RDMA stack always matches the host it
# runs on. The ibverbs-providers/libibverbs-dev apt packages above remain as a
# self-contained fallback for same-ABI hosts (USE_HOST_RDMA=0).

RUN FSDP_PARAM=$(python3 -c "import torch, os; print(os.path.join(os.path.dirname(torch.__file__), 'distributed/fsdp/_fully_shard/_fsdp_param.py'))") && \
sed -i 's/self.sharded_param = nn.Parameter(self.to_sharded_dtensor(sharded_param))/self.sharded_param = nn.Parameter(self.to_sharded_dtensor(sharded_param), requires_grad=param.requires_grad)/' "$FSDP_PARAM" && \
sed -i 's/ self.sharded_param.requires_grad_(param.requires_grad)//' "$FSDP_PARAM"

# Install torchtitan and ALTO training deps at build time (as root) to avoid
# /opt/venv permission errors when the container runs as a non-root user.
COPY 3rdparty/torchtitan /tmp/torchtitan_src
# Pin the ROCm torch/torchvision/triton already in the base image via a pip
# constraints file so no transitive dependency (compressed_tensors -> transformers,
# torchao, torchtitan, ...) can pull a CUDA build of torch and the nvidia-* wheels.
# Replacing the ROCm torch breaks the pre-compiled ROCm torchvision ops at runtime
# ("RuntimeError: operator torchvision::nms does not exist" -> ABI mismatch).
# Constraints still let other packages upgrade; they just cannot move torch et al.
# torchao is also installed with --no-deps as belt-and-suspenders. meson-python/
# pybind11/ninja are torchtitan's declared build backend (build-backend = "mesonpy")
# and must be present here because the torchtitan install uses --no-build-isolation.
# Read versions from package metadata (not `pip freeze`): the ROCm torch is a
# locally-built wheel that pip freeze renders as "torch @ file://...", which a
# "^torch==" grep would miss, producing an empty constraints file.
RUN python3 -c "import importlib.metadata as md; have={d.metadata['Name'].lower() for d in md.distributions()}; want=['torch','torchvision','triton','pytorch-triton-rocm']; open('/tmp/torch-constraints.txt','w').write(''.join(f'{p}=={md.version(p)}\n' for p in want if p.lower() in have))" && \
cat /tmp/torch-constraints.txt && \
pip install --no-cache-dir -c /tmp/torch-constraints.txt aim \
compressed_tensors easydict loguru \
poetry-core "poetry-dynamic-versioning>=1.0.0,<2.0.0" \
meson-python pybind11 ninja tyro && \
pip install --no-cache-dir -c /tmp/torch-constraints.txt --no-deps torchao && \
pip install --no-cache-dir --no-build-isolation --no-deps /tmp/torchtitan_src && \
rm -rf /tmp/torchtitan_src /tmp/torch-constraints.txt
30 changes: 30 additions & 0 deletions RDMA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Testing RDMA between two nodes

```bash
`ibv_devices` # list RDMA devices (e.g. mlx5_0)
`ibv_devinfo` # PortState: PORT_ACTIVE and note the link layer (IB vs. Ethernet/ROCE)
`rdma link show` # link state per device
```

# Raw RDMA loopback between two nodes

```bash
# On node A (server):
ib_write_bw -d mlx5_0 -F --report_gbits

# On node B (client), point at node A's IP:
ib_write_bw -d mlx5_0 -F --report_gbits <NODE_A_IP>

```

You can get `<NODE_A_IP>` for a given RDMA interface like this:

```bash
# Map RDMA device -> netdev:
ibdev2netdev # look for a line like: "mlx5_0 port 1 ==> rdma0 (Up)"
rdma link show # alternatively, look here. e.g. mlx5_0/1 ... netdev rdma0

# Then get that interface's IP:
ip -4 addr show rdma0 # look for the "inet x.x.x.x" line

```
172 changes: 172 additions & 0 deletions alto/_adahop_bridge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Copyright (c) 2026 Advanced Micro Devices, Inc.
#
# SPDX-License-Identifier: MIT
"""Bridge to the AdaHOP submodule at ``3rdparty/adahop``.

Loads selected AdaHOP modules by file path under non-colliding names so that
AdaHOP's vendored ``torchtitan`` package never enters ``sys.modules`` and
cannot shadow ALTO's own torchtitan submodule.
"""

import importlib.util
import sys
from pathlib import Path
from typing import Any

_ALTO_ROOT = Path(__file__).resolve().parent.parent
_ADAHOP_ROOT = _ALTO_ROOT / "3rdparty" / "adahop"
_HT_DIR = _ADAHOP_ROOT / "torchtitan" / "experiments" / "kernels" / "hadamard_transform"
_MXFP4_DIR = _ADAHOP_ROOT / "torchtitan" / "experiments" / "kernels" / "mxfp4"
_TC_PATH = _MXFP4_DIR / "transform_config.py"


def _load_module(name: str, path: Path):
spec = importlib.util.spec_from_file_location(name, path)
if spec is None or spec.loader is None:
raise ImportError(f"Cannot load module {name} from {path}")
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)
return module


def _load_package(name: str, pkg_dir: Path):
init_path = pkg_dir / "__init__.py"
spec = importlib.util.spec_from_file_location(
name,
init_path,
submodule_search_locations=[str(pkg_dir)],
)
if spec is None or spec.loader is None:
raise ImportError(f"Cannot load package {name} from {pkg_dir}")
module = importlib.util.module_from_spec(spec)
sys.modules[name] = module
spec.loader.exec_module(module)
return module


if not _ADAHOP_ROOT.exists():
raise ImportError(f"AdaHOP submodule not found at {_ADAHOP_ROOT}. "
"Run `git submodule update --init --recursive` from the ALTO root.")

_ht = _load_package("_alto_adahop_ht", _HT_DIR)
_tc = _load_module("_alto_adahop_transform_config", _TC_PATH)


def _alias_ht_at_absolute_path() -> None:
"""AdaHOP's ``iht_quantization`` does an *absolute* import:
``from torchtitan.experiments.kernels.hadamard_transform.hadamard import _build_H_b32``
ALTO's vendored ``torchtitan`` package does not contain AdaHOP's
``hadamard_transform`` subpackage, so the import fails. Alias the
bridge-loaded hadamard package at the absolute path the file expects.
Also stub the intermediate ``torchtitan.experiments`` and
``torchtitan.experiments.kernels`` packages if they aren't already
populated, so the dotted lookup resolves.
"""
import types
# Build out the chain torchtitan -> .experiments -> .kernels -> .hadamard_transform
# without clobbering whatever ALTO already has installed.
if "torchtitan" not in sys.modules:
sys.modules["torchtitan"] = types.ModuleType("torchtitan")
if "torchtitan.experiments" not in sys.modules:
sys.modules["torchtitan.experiments"] = types.ModuleType("torchtitan.experiments")
if "torchtitan.experiments.kernels" not in sys.modules:
sys.modules["torchtitan.experiments.kernels"] = types.ModuleType("torchtitan.experiments.kernels")
sys.modules["torchtitan.experiments.kernels.hadamard_transform"] = _ht
# The submodule that gets cherry-picked too:
if hasattr(_ht, "hadamard"):
sys.modules["torchtitan.experiments.kernels.hadamard_transform.hadamard"] = _ht.hadamard


_alias_ht_at_absolute_path()


def _load_mxfp4_package() -> Any:
"""Load AdaHOP's ``mxfp4/`` package without triggering the colliding
``torch.ops.torchtitan.*`` registrations from ``mxfp_linear.py`` and
``mxfp_quantization.py``.

The package's ``__init__.py`` does ``from .mxfp_linear import MXFP4Linear``
and ``from .mxfp_quantization import convert_to_mxfp4, convert_from_mxfp4,
BLOCK_SIZE_DEFAULT`` at import time. Both files register ``@triton_op``s
in the ``torchtitan::`` namespace that ALTO already owns (collision would
raise ``RuntimeError: Tried to register operator ... twice``). We install
stubs at the expected ``sys.modules`` names BEFORE exec'ing the package
so those import lines succeed without touching the real source.

What we actually need from the package: ``iht_quantization``,
``foid.OUTLIER_K``, ``foid.prepare_outlier_clean_row/column``,
``outlier_extract.inner_outlier_extract_left_cdna4`` and
``..._right_cdna4``. None of these go through the stubbed modules at
call time — ``outlier_extract`` calls ``torch.ops.torchtitan.``
``blockwise_mxfp4_gemm`` (ALTO's registration, cdna-gated) directly,
and ``iht_quantization`` self-gates cdna3/cdna4 via ``is_cdna4()`` from
``fp4_common``.
"""
pkg_name = "_alto_adahop_mxfp4"
import types

# Stub mxfp_linear (only exports MXFP4Linear, referenced by __init__).
mxfp_linear_stub = types.ModuleType(f"{pkg_name}.mxfp_linear")
mxfp_linear_stub.MXFP4Linear = object # placeholder, never instantiated
sys.modules[f"{pkg_name}.mxfp_linear"] = mxfp_linear_stub

# Stub mxfp_quantization with the three symbols __init__ imports.
mxfp_quant_stub = types.ModuleType(f"{pkg_name}.mxfp_quantization")
mxfp_quant_stub.BLOCK_SIZE_DEFAULT = 32 # matches AdaHOP's real value
mxfp_quant_stub.convert_to_mxfp4 = None # never called via this stub
mxfp_quant_stub.convert_from_mxfp4 = None
sys.modules[f"{pkg_name}.mxfp_quantization"] = mxfp_quant_stub

# Stub mxfp_grouped_gemm (only referenced by the lazy mxfp4_grouped_gemm
# wrapper, never imported eagerly).
mxfp_grouped_stub = types.ModuleType(f"{pkg_name}.mxfp_grouped_gemm")
mxfp_grouped_stub.mxfp4_grouped_gemm = None
sys.modules[f"{pkg_name}.mxfp_grouped_gemm"] = mxfp_grouped_stub

pkg = _load_package(pkg_name, _MXFP4_DIR)
# __init__.py doesn't import foid / outlier_extract; force-load them
# via the package's submodule search so they hang off `pkg` as attributes.
import importlib
pkg.foid = importlib.import_module(f"{pkg_name}.foid")
pkg.outlier_extract = importlib.import_module(f"{pkg_name}.outlier_extract")
return pkg


_mxfp4 = _load_mxfp4_package()

HadamardFactory = _ht.HadamardFactory
HadamardTransform = _ht.HadamardTransform
detect_outlier_pattern = _ht.detect_outlier_pattern

transform_config = _tc
configure_global_transforms = _tc.configure_global_transforms
configure_layer_transforms = _tc.configure_layer_transforms
get_layer_transform_config = _tc.get_layer_transform_config
should_apply_transform = _tc.should_apply_transform
clear_all_configs = _tc.clear_all_configs

iht_quantization = _mxfp4.iht_quantization
OUTLIER_K = _mxfp4.foid.OUTLIER_K
prepare_outlier_clean_row = _mxfp4.foid.prepare_outlier_clean_row
prepare_outlier_clean_column = _mxfp4.foid.prepare_outlier_clean_column
inner_outlier_extract_left_cdna4 = _mxfp4.outlier_extract.inner_outlier_extract_left_cdna4
inner_outlier_extract_right_cdna4 = _mxfp4.outlier_extract.inner_outlier_extract_right_cdna4

__all__ = [
"HadamardFactory",
"HadamardTransform",
"detect_outlier_pattern",
"transform_config",
"configure_global_transforms",
"configure_layer_transforms",
"get_layer_transform_config",
"should_apply_transform",
"clear_all_configs",
"iht_quantization",
"OUTLIER_K",
"prepare_outlier_clean_row",
"prepare_outlier_clean_column",
"inner_outlier_extract_left_cdna4",
"inner_outlier_extract_right_cdna4",
]
3 changes: 3 additions & 0 deletions alto/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
# SPDX-License-Identifier: MIT

from .converter import ModelOptConverter
from .m_adam import MAdamOptimizersContainer, m_adam
from .optimizer import DeOscillationConfig, enable_de_oscillation
from .state_dict_adapter_mixin import StateDictAdapterMixin

__all__ = [
"DeOscillationConfig",
"enable_de_oscillation",
"MAdamOptimizersContainer",
"m_adam",
"ModelOptConverter",
"StateDictAdapterMixin",
]
Loading