Skip to content

[TT-Train] Fix GCC build: qualify self-referential using declarations (#37922)#37924

Open
epam-iaroslav-voitovych wants to merge 1 commit intomainfrom
ivoitovych/issue-37922-fix-gcc-self-referential-using
Open

[TT-Train] Fix GCC build: qualify self-referential using declarations (#37922)#37924
epam-iaroslav-voitovych wants to merge 1 commit intomainfrom
ivoitovych/issue-37922-fix-gcc-self-referential-using

Conversation

@epam-iaroslav-voitovych
Copy link
Contributor

Ticket

Fixes #37922

Problem description

5 tt-train device operation headers use self-referential using type alias declarations:

using operation_attributes_t = operation_attributes_t;  // unqualified — self-referential

This violates C++ [basic.scope.class]/2: the member name on the left shadows the namespace-scope type on the right, making the declaration self-referential. GCC (all versions) correctly rejects this with -fpermissive; Clang is lenient and accepts it.

8 other device operations in the same codebase already use the correct fully-qualified pattern.

What's changed

Added full namespace qualification to the using declarations in the 5 affected files, matching the pattern already used by rmsnorm_fw, rmsnorm_bw, softmax, silu_bw, cross_entropy_fw, cross_entropy_bw, sdpa_fw, and profiler_no_op.

Before (broken with GCC)

namespace ttml::metal::ops::layernorm_fw::device {
struct LayerNormForwardDeviceOperation {
    using operation_attributes_t = operation_attributes_t;
};
}

After (works with both GCC and Clang)

namespace ttml::metal::ops::layernorm_fw::device {
struct LayerNormForwardDeviceOperation {
    using operation_attributes_t = ttml::metal::ops::layernorm_fw::device::operation_attributes_t;
};
}

Files changed (5 files, 20 lines)

  • tt-train/sources/ttml/metal/ops/layernorm_fw/device/layernorm_fw_device_operation.hpp
  • tt-train/sources/ttml/metal/ops/layernorm_bw/device/layernorm_bw_device_operation.hpp
  • tt-train/sources/ttml/metal/ops/swiglu_fw/device/swiglu_fw_device_operation.hpp
  • tt-train/sources/ttml/metal/optimizers/adamw/device/adamw_device_operation.hpp
  • tt-train/sources/ttml/metal/optimizers/sgd_fused/device/sgd_fused_device_operation.hpp

Verification

Container build with --tt-train-compiler gcc-12 merging this fix + PR #37166 (compiler selection) on top of main — verifies tt-train compiles successfully with GCC 12.

Checklist

  • All post-commit tests
  • Blackhole Post commit
  • cpp-unit-tests
  • New/Existing tests provide coverage for changes

Model tests

If your changes cover model-related code, you should run tests corresponding to affected models and platforms (Single card, T3K, Galaxy). "Choose your pipeline" workflows facilitate running multiple kinds of tests in a single run. Each offers models-mandatory and models-extended presets.
The former includes a minimal set of tests, to be run always. The latter extends that with additional ones - use your best judgement in deciding which is the most appropriate for your PR.

…larations

5 device operation headers use `using operation_attributes_t =
operation_attributes_t;` which GCC rejects as self-referential per
C++ [basic.scope.class]/2 (Clang is lenient and accepts it).

Fix: use fully-qualified namespace paths, matching the pattern
already used by 8 other device operations in the same codebase
(rmsnorm_fw, rmsnorm_bw, softmax, silu_bw, cross_entropy_fw, etc.).

Fixes #37922
@epam-iaroslav-voitovych
Copy link
Contributor Author

Container verification

Verified in Docker container builds using parameterized build scripts that merge branches on top of main and optionally override the tt-train compiler:

# Test Compiler Branches merged Result
1 gcc-12 override gcc-12 This PR + PR #37166 (compiler selection) PASSED
2 Default (no override) clang-20 (inherited from CMakeCache.txt) This PR + PR #37166 PASSED

Build 1 confirms GCC 12 now compiles tt-train successfully with the qualified using declarations.
Build 2 confirms no regression on the default Clang path.

Build commands used:

# Build 1: gcc-12 override
./build_tt_docker.sh --branch main \
  --merge-branch ivoitovych/issue-36993-fix-gcc-constexpr-lambda \
  --merge-branch ivoitovych/tt-metal:ivoitovych/issue-37922-fix-gcc-self-referential-using \
  --tt-train-compiler gcc-12

# Build 2: default compiler (clang-20 inherited from tt-metal CMakeCache.txt)
./build_tt_docker.sh --branch main \
  --merge-branch ivoitovych/issue-36993-fix-gcc-constexpr-lambda \
  --merge-branch ivoitovych/tt-metal:ivoitovych/issue-37922-fix-gcc-self-referential-using

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.

[TT-Train]: GCC build failure — 5 device operation headers use self-referential using declarations

2 participants