Skip to content

[WIP] Allow benchmark between multiple configs - #703

Closed
H-Huang wants to merge 1 commit into
gh/H-Huang/17/basefrom
gh/H-Huang/17/head
Closed

H-Huang wants to merge 1 commit into
gh/H-Huang/17/basefrom
gh/H-Huang/17/head

Conversation

@H-Huang

@H-Huang H-Huang commented Nov 26, 2024 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

This is WIP and needs to be cleaned up but creating PR to solicit feedback.

There isn't an easy way run multiple runs together and display the metrics in a single view. We already save the metrics to tensorboard so this PR adds a data structure to retrieve these metrics and display it in a table. It is an enhancement in test_runner.py

Example:

# under test_runner.py there are 3 different configurations we want to compare metrics between
OverrideDefinitions(
    [
        [
            "--experimental.pipeline_parallel_degree 2",
            "--training.data_parallel_shard_degree 2",
            "--metrics.enable_tensorboard",
        ],
        [
            "--training.data_parallel_shard_degree 4",
            "--metrics.enable_tensorboard",
        ],
        [
            "--training.tensor_parallel_degree 4",
            "--metrics.enable_tensorboard",
        ],
    ],
    "example",
    "my_example",
    ngpu=4,
),

This can be outputted as:

Run ID: 0, args: ['--experimental.pipeline_parallel_degree 2', '--training.data_parallel_shard_degree 2', '--metrics.enable_tensorboard']
Run ID: 1, args: ['--training.data_parallel_shard_degree 4', '--metrics.enable_tensorboard']
Run ID: 2, args: ['--training.tensor_parallel_degree 4', '--metrics.enable_tensorboard']

           | wps                          | mfu(%)                       | memory/max_active(GiB)       | memory/max_active(%)         | memory/max_reserved(%)       | loss_metrics/global_avg_loss | loss_metrics/global_max_loss
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0          | 55928.27734375               | 1.6978793144226074           | 0.7439417839050293           | 0.940051257610321            | 1.0439579486846924           | 7.137195110321045            | 7.143610954284668           
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1          | 97578.0234375                | 2.9622886180877686           | 1.9954571723937988           | 2.521476984024048            | 2.6999762058258057           | 7.031539440155029            | 7.066774845123291           
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2          | 10559.697265625              | 0.3205729126930237           | 1.0774049758911133           | 1.3614182472229004           | 1.4314316511154175           | 7.13456916809082             | 7.13456916809082            

H-Huang added a commit that referenced this pull request Nov 26, 2024
ghstack-source-id: 613f40b
Pull Request resolved: #703
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 26, 2024
@H-Huang
H-Huang marked this pull request as ready for review November 26, 2024 22:09
@H-Huang H-Huang changed the title Allow benchmark between multiple configs [WIP] Allow benchmark between multiple configs Nov 26, 2024

@wconstab wconstab left a comment

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.

I think the MetricRetriever and print_metrics are nice. But I'm kinda curious why you felt they were needed. You can also just fire up tensorboard and compare all the metrics that way, right? (and then you get graphs of loss too).

Actually iirc I once tried to compare titan runs in tensorboard and I found the way the logdir was set up made it a bit annoying. It might be worth addressing that pain point if that is a pain point. (I might have just been running things in a dumb way too).

Comment thread test_runner.py
from collections import defaultdict
from dataclasses import dataclass
from typing import Sequence
from typing import Any, Dict, Sequence

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.

RE the binary files above, not sure if you meant to include those in the PR

@meta-cla

meta-cla Bot commented Mar 20, 2026

Copy link
Copy Markdown

Hi @H-Huang!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@tianyu-l tianyu-l closed this Mar 21, 2026
shuhuayu added a commit that referenced this pull request Nov 11, 2026
## Why
The Qwen3.8-Flash-Next QSA attention (#5782) will use `gather_attn`'s
grouped-KV / separate-V Triton kernels. They first appear in
attention-gym v0.0.19, after attention-gym #678, #701, #702, #713, #714,
#715 and #703. torchtitan pins `26beb363`, which predates all of these.
This PR only bumps the pin; the Flash-Next change stays in #5782.

## What changed (all mechanical)
| | Before | After |
| --- | --- | --- |
| attn-gym pin | `26beb363` (#704 merge) | `0d0197fb` (v0.0.19 tag, #703
merge) |

- `.ci/docker/requirements.txt` (root `requirements.txt` symlinks to
it): new SHA. The TODO now says to switch to the PyPI release once
v0.0.19 is published there (PyPI's newest is 0.0.18). #704, which the
old TODO waited on, is already included in both pins.
- `torchtitan/models/common/attn_gym.py` (install hint) and
`tests/unit_tests/cpu/models/common/test_optional_imports.py` (2
asserts): same SHA.

## Why v0.0.19 rather than attention-gym `main`
`26beb363..0d0197fb` changes only `attn_gym/sparse/gather_attn` (plus
its tests and docs). I diffed the two installed `attn_gym` trees to
confirm this. GDN, KDA, short_conv, the indexer, MLA and the CuTe
backend are byte-identical, so qwen3_5, qwen3_8, kimi and the
deepseek_v4 indexer can't change. `main` would also pull in the
warpdrive rewrite and the indexer/delta-H ports (~28 `_delta_rule`
files).

## Numerics
The only `gather_attn` consumer is
`torchtitan/models/deepseek_v4/attention.py`. Old vs new pin, 10 steps,
seed 42, deterministic, loss and grad_norm read from TensorBoard via
`scripts/loss_compare.py`, on GB300:

| Config | GPUs | Result |
| --- | --- | --- |
| `deepseek_v4_debugmodel_fsdp4_ep4` (DistMuon) | 4 | bitwise identical*
|
| `deepseek_v4_debugmodel_fsdp2_tp2_ep2_pp2` with dp_shard=1 (host has 4
GPUs) | 4 | bitwise identical* |

\* With `gather_attn`'s Triton tuners pinned to the same candidate in
both runs. Without pinning, deepseek_v4 isn't run-to-run reproducible on
**either** pin when the autotune cache is cold. `_FWD_TMA` and
`_BWD_DLOCAL_KV_TMA` choose `num_warps` 4 vs 8 by timing, and the two
give different bits. Ranks and cold-cache runs can pick different
winners, and torch's deterministic flag doesn't control this. This
already happens on main. I filed it upstream as
meta-pytorch/attention-gym#777, with a single-GPU repro. Because of it,
this PR adds no deepseek_v4 golden; see follow-ups.

## Testing
- `pre-commit run --all-files` passes, including `pyrefly-check`.
- `pytest tests/unit_tests/cpu/models/common` plus the deepseek_v4,
qwen3_5, qwen3_8 and kimi_k3 CPU tests: 416 passed. The same 9 tests
fail with both the old and new pin on this aarch64 host
(`test_lora_forward` and 8 qwen3_5 tests). The one I inspected,
`test_lora_forward`, fails with "torch.compile on current platform is
not supported for CPU".

## Known issues / follow-ups
- deepseek_v4 golden numerics: add once attention-gym#777 lets us fix
the tile config. The golden then has to be exported on CI's A10G
runners, not on GB300.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants