Skip to content

fix(training): correct RTX 3070 Ti BF16 peak FLOPS - #83

Merged
SigureMo merged 2 commits into
redai-studio:mainfrom
Men1scus:fix/rtx-3070-ti-bf16-peak
Sep 26, 2026
Merged

SigureMo merged 2 commits into
redai-studio:mainfrom
Men1scus:fix/rtx-3070-ti-bf16-peak

Conversation

@Men1scus

Copy link
Copy Markdown
Contributor

What

Correct the RTX 3070 Ti entry in _DEVICE_FLOPS from 21.75e12 to 43.5e12.

Why

_DEVICE_FLOPS is documented as "BF16 theoretical peak FLOPS per device"
(relax/utils/training/flops_counter.py:12), and every other entry is a dense
BF16 Tensor Core
figure — for example H100: 989e12 and A100: 312e12, which
are the dense (non-sparsity) Tensor Core numbers.

The RTX 3070 Ti entry instead held 21.75e12, which is that card's FP32
non-Tensor
peak. It is the only entry in the table whose value equals the
card's plain FP32 rate rather than its Tensor Core rate.

Because MFU is computed as achieved_tflops / device_peak_tflops
(relax/utils/training/train_metric_utils.py:69-73), a peak that is ~2x too low
inflates reported MFU by roughly 2x on this GPU. The failure is silent: the value
is finite and positive, so it passes every existing guard and renders as a
plausible-looking number on the dashboard.

How

NVIDIA's RTX Blackwell GPU Architecture whitepaper (Appendix B, Table 5) lists
both figures for the RTX 3070 Ti in the same table:

Row RTX 3070 Ti
Peak BF16 TFLOPS (non-Tensor) 21.7
Peak BF16 Tensor TFLOPS with FP32 Accumulate 43.5 (87 with sparsity)
CleanShot 2026-07-23 at 18 26 11@2x

Source: NVIDIA RTX Blackwell GPU Architecture whitepaper, Appendix B, Table 5
(RTX 5070 Ti vs RTX 4070 Ti vs RTX 3070 Ti).

The current entry (21.75e12) matches the non-Tensor row. Since _DEVICE_FLOPS
is a BF16 Tensor Core table and MFU is measured against Tensor Core throughput,
the correct value is the dense Tensor figure with FP32 accumulate — 43.5.
BF16 always accumulates in FP32, so that is the applicable row.

CleanShot 2026-07-23 at 18 32 32@2x

Note the argument does not rest on this document alone: the entry is also
inconsistent with the table's own stated convention, which is verifiable from
the surrounding entries by themselves.

Only the single value is changed. The lookup logic, the unknown-device sentinel,
and all other entries are untouched.

Testing

$ pre-commit run --all-files
check for added large files..............................................Passed
check for merge conflicts................................................Passed
check for broken symlinks................................................Passed
detect private key.......................................................Passed
fix end of files.........................................................Passed
debug statements (python)................................................Passed
trim trailing whitespace.............................(no files to check)Skipped
ruff (legacy alias)......................................................Passed
ruff format..............................................................Passed
mdformat.................................................................Passed
clang-format.............................................................Passed
docformatter.............................................................Passed
check-conflict-markers...................................................Passed
format-ascii-boxes.......................................................Passed
Detect hardcoded secrets.................................................Passed

$ pytest tests/utils/test_flops_counter.py -q
....................                                                     [100%]
20 passed in 0.04s

Device lookups after the change — all existing known-GPU entries resolve
unchanged, the corrected entry resolves to 43.5 TFLOPS, and unknown devices
still return float("inf"):

OK  NVIDIA H100 80GB HBM3          989.0
OK  NVIDIA H800                    989.0
OK  NVIDIA A100-SXM4-80GB          312.0
OK  NVIDIA A800-SXM4-80GB          312.0
OK  NVIDIA L40S                    362.05
OK  NVIDIA H20                     148.0
OK  Ascend910B3                    354.0
OK  NVIDIA GeForce RTX 3070 Ti     43.5   (corrected entry)
unknown device still returns inf: True
  • pre-commit run --all-files passes
  • Tests pass (pytest tests/) (ran tests/utils/test_flops_counter.py: 20 passed; the full suite needs a distributed GPU environment)
  • New tests added (if applicable) (not applicable: this corrects the value of an existing table entry)
  • Documentation updated (if applicable)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • CI/CD or build changes

Screenshots / Logs

Before this change, on an RTX 3070 Ti, perf/device_peak_tflops was reported as
21.75 and all perf/mfu/* values were consequently ~2x too high. After the
change the peak is 43.5 and MFU is scaled correctly.

# 🐛 Bug Fix

## Correct RTX 3070 Ti entry in _DEVICE_FLOPS

- Change `21.75e12` to `43.5e12` in `relax/utils/training/flops_counter.py`
- `21.75e12` is the card's FP32 non-Tensor peak, not its BF16 Tensor peak
- The table is documented as "BF16 theoretical peak FLOPS per device", and
  every other entry is a dense BF16 Tensor Core figure
- MFU is `achieved_tflops / device_peak_tflops`, so the too-low peak inflated
  reported MFU by roughly 2x on this GPU
- The failure was silent: the value is finite and positive, so it passed every
  existing guard and rendered as a plausible number on the dashboard
- NVIDIA lists the RTX 3070 at 20.3 TFLOPS FP32 and 40.6 TFLOPS dense BF16
  Tensor (a 2x ratio); applying that ratio to the Ti's 21.75 TFLOPS FP32
  gives 43.5 TFLOPS
Copilot AI review requested due to automatic review settings July 23, 2026 11:14
@Men1scus
Men1scus requested a review from NINGBENZHE as a code owner July 23, 2026 11:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR corrects the RTX 3070 Ti entry in Relax’s BF16 theoretical peak device FLOPS table, which is used to compute MFU (achieved TFLOPS / device peak TFLOPS) in training metrics.

Changes:

  • Update _DEVICE_FLOPS["RTX 3070 Ti"] from 21.75e12 to 43.5e12 in get_device_peak_flops()’s backing table.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 29 to 32
"910B": 354e12,
"Ascend910": 354e12,
"RTX 3070 Ti": 21.75e12,
"RTX 3070 Ti": 43.5e12,
}

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.

同意补充这一用例,并补充一个使它更有必要的回归风险证据:

_DEVICE_FLOPS 表整体改编自 verl(见文件头部来源说明,随 7c534c9 引入),而 verl 上游 main 至今仍是 "RTX 3070 Ti": 21.75e12。因此本 PR 属于对上游数据源的有意偏离——今后若有人从 verl 重新同步该表,这处修正会被静默回退,且现有测试全部通过,MFU 会再次被无声放大约 2 倍。

按现有参数化约定补一行 ("NVIDIA GeForce RTX 3070 Ti", 43.5e12) 即可把这一偏离固化为可回归验证的契约。非阻塞建议,修正本身的正确性我已核对无误。

@rai-studio-bot

rai-studio-bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

审查状态: 💬 已完成 · 有补充意见

审查版本: 7a346d3

常规审查完成,无阻塞问题:diff 仅为 _DEVICE_FLOPS 中 RTX 3070 Ti 一处常量修正(21.75e12 → 43.5e12),旧值为 FP32 非张量峰值,与表声明的 dense BF16 张量峰值约定不符;新值 43.5e12 与 PR 引用的 NVIDIA 白皮书及表内其余条目约定一致,本地 20 项测试通过,设备名解析与 MFU 链路核对无误。唯一建议(P2,非阻塞):按现有参数化约定为该条目补一行测试,防止将来从 verl 上游(仍为旧值)同步该表时修正被静默回退。

审查阶段进度范围与结果
常规审查 ✅ 已完成 已完整审查 7a346d3 的全量 diff(单行常量修正):核对表约定自洽性(旧值恰为 GA104 FP32 非张量峰值 2×6144×1.77GHz,新值为 dense BF16 Tensor FP32 累加峰值 43.5/87-sparse);本地运行 tests/utils/test_flops_counter.py 20 项全部通过;验证 get_device_peak_flops 对 "NVIDIA GeForce RTX 3070 Ti" 解析为 43.5、未知设备返回 inf;追踪 MFU 调用链(megatron/actor.py:407 → train_metric_utils.py:66-74)确认修正恢复正确比例;确认全仓库无其他引用;查证该表继承自 verl(7c534c99)且上游仍为 21.75e12。CI 集成测试在审查时仍在运行,与改动文件相关的单元测试已本地通过。
深度审查 ➖ 无需执行 无深度审查必要:单行机械常量修正,不引入新抽象、边界或生命周期变化(独立设计跳过理由见 review-plan 记录);生产与测试必要性审计由父级直接完成并记录于 simplification 字段,未派遣子任务。

审查发现

待处理
编号 严重性 问题状态规则来源
F1 Medium severity 为修正后的 RTX 3070 Ti 峰值补充参数化测试用例,固定对 verl 上游的有意偏离 🚧 未解决 —
已解决或已取代
编号 严重性 问题状态规则来源
暂无已解决或已取代的记录。
提交范围 · 接收 1 · 建议移出 0 · 待确认 0

接收 1 个文件 · 建议移出 0 个文件 · 待确认 0 个文件。移出与待确认部分暂停深审,不代表审查通过。

文件结论仓库维护必要性依据替代去向或方案
relax/utils/training/flops_counter.py
接收 Corrects a wrong constant in the existing _DEVICE_FLOPS production table (21.75e12 FP32 non-tensor rate → 43.5e12 dense BF16 tensor rate), restoring the table's documented convention. The table is a maintained production lookup used by get_device_peak_flops(); MFU reporting on this GPU is silently ~2x inflated without the fix. PR #83 description (BF16 Tensor Core convention, NVIDIA whitepaper Appendix B Table 5); production caller relax/utils/training/train_metric_utils.py computing MFU from this peak. Moving the mapping outside the repository or adding a runtime override would add machinery for a single corrected constant and would not fix the in-tree default; keeping the corrected entry in the existing table is the minimal production fix.
精简审查与验证依据
审查范围进度结论
生产代码 ✅ 已完成 整处生产改动为表格单个常量,无新增分支/包装/推测性兼容,保留即最优;无可删除或合并的复杂度。
测试 ✅ 已完成 PR 未改测试;对既有相关测试族的必要性审计:已知 GPU 参数化固定族与表键存在性测试保留,另确认一处缺失用例(修正条目未固定),已作为 F1 记录并归入既有 copilot 线程,不重复发起新发现。

生产代码的必要性与替代方案

范围必须保留的契约更简单的方案结论依据与限制
relax/utils/training/flops_counter.py 中 _DEVICE_FLOPS["RTX 3070 Ti"] 常量修正 get_device_peak_flops 返回设备 dense BF16 张量峰值;调用方为 FlopsCounter.estimate → log_perf_data_raw 的 MFU 计算(relax/utils/training/train_metric_utils.py:66-74,构造于 relax/backends/megatron/actor.py:407)。 备选:运行时通过 torch 能力查询理论峰值(跨 CUDA/NPU 不可移植,且无标准 API 返回理论峰值);或保持与 verl 上游一致(上游仍是错误的 21.75e12);或引入外部配置覆盖机制。 保留 静态表是既有既定机制(文件注明 adapted from verl);运行时探测不可行,配置覆盖对单常量修正属过度设计。新值已对照 PR 引用的 NVIDIA 白皮书表(dense 43.5 / sparse 87)与表内 dense 约定(H100 989e12)核实;diff 恰为 1 行。局限:本环境无法独立访问该白皮书原文,核验依据为 PR 内白皮书截图引用值与架构比例(GA104 BF16 = 2×FP32)的一致性。

测试的必要性与替代方案

范围必须保留的契约更简单的方案结论依据与限制
tests/utils/test_flops_counter.py 的 test_get_device_peak_flops_known_gpus 参数化族与 test_device_flops_table_has_common_gpus 为 _DEVICE_FLOPS 提供按条目固定的回归锚点,防止表值被静默改动;该测试文件是本 PR 唯一相关的测试边界。 备选:删除参数化固定族(视其为同义反复)或改为遍历全表断言键值(无独立预言,反而更弱)。 保留 对常量表而言,固定条目即契约(预言来源为厂商规格,行内期望值是对规格的显式记录);本地 20 项通过。缺失项:RTX 3070 Ti 条目未固定,而该表继承自 verl 且上游仍为旧值,重新同步会静默回退修正——已在既有线程补充该证据并建议补一行参数化用例(F1,P2,非阻塞)。
Powered by Nyanpasu with glm-5.3[1m] xhigh, please check the suggestions carefully.

@rai-studio-bot rai-studio-bot 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.

审查结论:无阻塞问题,建议合并前顺手处理一条非阻塞补充(见 F1 线程)

针对 7a346d3 完成全量审查,diff 仅为 relax/utils/training/flops_counter.py 中 RTX 3070 Ti 的单常量修正(21.75e12 → 43.5e12)。核对确认:旧值恰为该卡 FP32 非张量峰值(2×6144×1.77GHz = 21.75e12),与表头声明的 dense BF16 张量峰值约定不符;新值 43.5e12 为 GA104 dense BF16 Tensor(FP32 累加)峰值,与 PR 引用的 NVIDIA 白皮书表(43.5 dense / 87 sparse)及表内其余条目的 dense 约定一致。本地 pytest tests/utils/test_flops_counter.py 20 项全部通过,get_device_peak_flops 对 "NVIDIA GeForce RTX 3070 Ti" 解析为 43.5、未知设备仍返回 inf,MFU 链路(train_metric_utils.py:66-74)随峰值修正恢复正确比例。

唯一待处理项为非阻塞建议(P2):按现有参数化约定补一行该条目的测试用例,防止将来从 verl 同步该表时修正被静默回退,详见审查线程;其余无问题。

审查看板:#83 (comment)

Powered by Nyanpasu with glm-5.3[1m] xhigh, please check the suggestions carefully.

@SigureMo SigureMo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTMeow 🐾

@SigureMo
SigureMo merged commit 99a0b6a into redai-studio:main Sep 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants