Skip to content

Return an empty stack, not a blank frame, when no trace is available (#3855) - #3855

Open
Scusemua wants to merge 2 commits into
meta-pytorch:mainfrom
Scusemua:export-D117752032
Open

Return an empty stack, not a blank frame, when no trace is available (#3855)#3855
Scusemua wants to merge 2 commits into
meta-pytorch:mainfrom
Scusemua:export-D117752032

Conversation

@Scusemua

@Scusemua Scusemua commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary:

captureNativeErrorStack() promises "an empty vector when it is unavailable",
but does not deliver it. folly::split('\n', "", v) yields a vector holding one
empty string, so an unavailable trace is reported to Scuba as a single blank
frame rather than as no frames.

Two paths reach that empty string, and only one was considered. The header
guarded on __has_include(<dwarf.h>), treating a missing header as the only way
capture can be unavailable. But Symbolizer.h:292-293 documents that the
real implementation also returns "" when a trace is not available, so the
bug is reachable in a build with a fully working symbolizer. Gating on a header
was never the right test.

This replaces the header probe with a test of the actual result. Symbolizer.h
is now included unconditionally -- it already supplies an inline stub returning
"" in builds without a symbolizer, so duplicating folly's capability macros
here served no purpose -- and the empty case is handled where it is observable.
folly::split also now ignores empty tokens, so a trailing newline no longer
contributes a blank trailing frame.

The split/demangle/skipInternalFrames sequence is unchanged and moves intact
into detail::normalizeStackTrace, which is exposed so the behaviour can be
tested directly. Without that seam the empty case could only be reached by
building against a folly without a symbolizer, which is not something a unit
test can arrange.

No behavioural change for a healthy capture: the same frames, in the same order,
with the same plumbing frames stripped.

Differential Revision: D117752032

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 27, 2026
@meta-codesync

meta-codesync Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

@Scusemua has exported this pull request. If you are a Meta employee, you can view the originating Diff in D117752032.

@meta-codesync meta-codesync Bot changed the title Return an empty stack, not a blank frame, when no trace is available Return an empty stack, not a blank frame, when no trace is available (#3855) Aug 28, 2026
Scusemua added a commit to Scusemua/torchcomms that referenced this pull request Aug 28, 2026
…eta-pytorch#3855)

Summary:

`captureNativeErrorStack()` promises "an empty vector when it is unavailable",
but does not deliver it. `folly::split('\n', "", v)` yields a vector holding one
empty string, so an unavailable trace is reported to Scuba as a single blank
frame rather than as no frames.

Two paths reach that empty string, and only one was considered. The header
guarded on `__has_include(<dwarf.h>)`, treating a missing header as the only way
capture can be unavailable. But `Symbolizer.h:292-293` documents that the
**real** implementation also returns `""` when a trace is not available, so the
bug is reachable in a build with a fully working symbolizer. Gating on a header
was never the right test.

This replaces the header probe with a test of the actual result. `Symbolizer.h`
is now included unconditionally -- it already supplies an inline stub returning
`""` in builds without a symbolizer, so duplicating folly's capability macros
here served no purpose -- and the empty case is handled where it is observable.
`folly::split` also now ignores empty tokens, so a trailing newline no longer
contributes a blank trailing frame.

The split/demangle/`skipInternalFrames` sequence is unchanged and moves intact
into `detail::normalizeStackTrace`, which is exposed so the behaviour can be
tested directly. Without that seam the empty case could only be reached by
building against a folly without a symbolizer, which is not something a unit
test can arrange.

No behavioural change for a healthy capture: the same frames, in the same order,
with the same plumbing frames stripped.

Differential Revision: D117752032
Summary:
`build_mccl.sh` already converts `TORCH_CUDA_ARCH_LIST` into
`-DCMAKE_CUDA_ARCHITECTURES`, but only for wheel builds. The iterative and
feedstock paths leave it unset, CMake falls back to its own default of `75`,
and every ctran/mccl TU compiles -- and device-links -- for `sm_75` on top of
the requested arch. Visible in CI as:

    -- prims CUDA_ARCHITECTURES: OFF (from CMAKE_CUDA_ARCHITECTURES=75)
    "--generate-code=arch=compute_75,code=[compute_75,sm_75]" ... -gencode=arch=compute_90a,code=sm_90a

This drops the wheel-only gate. The inner guard is kept, so a caller-supplied
`-DCMAKE_CUDA_ARCHITECTURES` still wins.

**Measured, not assumed.** Two CI runs of the same source, differing only in
this setting, both reaching `[708/712]` and stopping at the same pre-existing
link error (T286255802):

    arch=75 (today)   1h16m55s   min free 15.62 GiB   peak scratch 4.38 GiB
    arch=90a          43m35s     min free 16.34 GiB   peak scratch 3.66 GiB
                      -43%       +736 MiB             -16%

The case for landing this is **build time**, not disk. 43% is large and
unambiguous. The scratch improvement is real but both arms finished with 15+
GiB free on a 26 GiB tmpfs, so this run does not demonstrate it prevents the
ENOSPC failures -- those occurred on smaller workers not reproduced here.

Two honest caveats:

- The measurement moves two things at once. `comms/prims/CMakeLists.txt`
  filters only 5x-8x, so 90a survives and prims goes from
  `CUDA_ARCHITECTURES: OFF` to `90a`. The experiment therefore ADDS prims
  codegen while removing ctran/mccl's sm_75, which biases against the change:
  the 43% is a lower bound, not an inflated figure.
- n=1 per arm.

Also deletes the dead architecture filters in `comms/ctran/CMakeLists.txt`.
All four (`compute_50/60/70/75`) were inert for three independent reasons:
`CMAKE_CUDA_FLAGS` is a string not a list, so `list(FILTER)` could only drop
the whole element; the regexes do not match CMake's actual
`arch=compute_NN,code=[compute_NN,sm_NN]` emission; and the architecture comes
from the `CUDA_ARCHITECTURES` target property rather than the flags string. The
trailing `message(status ...)` used a lowercase mode string, so it never
printed as a status line and existed only to show the deleted filters' result.

**Blast radius.** `conda/feedstock/mccl/build.sh:20` invokes `build_mccl.sh`
with no wheel flag, so this changes feedstock behavior for the first time.

Reviewed By: saifhhasan, shr

Differential Revision: D117526986
…eta-pytorch#3855)

Summary:

`captureNativeErrorStack()` promises "an empty vector when it is unavailable",
but does not deliver it. `folly::split('\n', "", v)` yields a vector holding one
empty string, so an unavailable trace is reported to Scuba as a single blank
frame rather than as no frames.

Two paths reach that empty string, and only one was considered. The header
guarded on `__has_include(<dwarf.h>)`, treating a missing header as the only way
capture can be unavailable. But `Symbolizer.h:292-293` documents that the
**real** implementation also returns `""` when a trace is not available, so the
bug is reachable in a build with a fully working symbolizer. Gating on a header
was never the right test.

This replaces the header probe with a test of the actual result. `Symbolizer.h`
is now included unconditionally -- it already supplies an inline stub returning
`""` in builds without a symbolizer, so duplicating folly's capability macros
here served no purpose -- and the empty case is handled where it is observable.
`folly::split` also now ignores empty tokens, so a trailing newline no longer
contributes a blank trailing frame.

The split/demangle/`skipInternalFrames` sequence is unchanged and moves intact
into `detail::normalizeStackTrace`, which is exposed so the behaviour can be
tested directly. Without that seam the empty case could only be reached by
building against a folly without a symbolizer, which is not something a unit
test can arrange.

No behavioural change for a healthy capture: the same frames, in the same order,
with the same plumbing frames stripped.

Differential Revision: D117752032
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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant