Skip to content

Add transformer_engine.test() installation smoke check#3197

Open
CodersAcademy006 wants to merge 1 commit into
NVIDIA:mainfrom
CodersAcademy006:feat/transformerengine-test-entrypoint
Open

Add transformer_engine.test() installation smoke check#3197
CodersAcademy006 wants to merge 1 commit into
NVIDIA:mainfrom
CodersAcademy006:feat/transformerengine-test-entrypoint

Conversation

@CodersAcademy006

Copy link
Copy Markdown

Problem

There is no way to verify a Transformer Engine installation without cloning the
repository and running the test suite. Users installing from PyPI or from source
have no quick sanity check that the package and its framework extensions loaded
correctly on their machine (#170).

Solution

Add a top-level transformer_engine.test() entry point, similar to
numpy.test(). It runs a small set of smoke checks:

  • Installation integrity, reusing the existing PyPI sanity check.
  • For the PyTorch backend, when it is available: a minimal te.Linear forward
    pass on the current device, reporting the device compute capability and which
    low-precision formats it supports. Checks that need a GPU are skipped when no
    CUDA device is present, so the call is safe to run anywhere.

It prints the result of each check and returns True if every executed check
passed.

import transformer_engine
transformer_engine.test()

Closes #170

@github-actions github-actions Bot added the community-contribution PRs from external contributor outside the core maintainers, representing community-driven work. label Jul 9, 2026
@CodersAcademy006 CodersAcademy006 marked this pull request as ready for review July 9, 2026 07:16
@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a transformer_engine.test() top-level function that gives users a quick, dependency-free smoke check after installation — without needing to clone the repo and run the full test suite.

  • Installation check: reuses the existing sanity_checks_for_pypi_installation() helper; always runs and records a pass/fail result.
  • PyTorch backend check: conditionally imported; on a CUDA device, runs a minimal te.Linear(16, 16) forward pass, verifies the output shape, and probes for FP8/MXFP8/NVFP4 format availability; GPU-dependent steps are skipped (not failed) when no CUDA device is present.
  • Previously flagged issues (assert replaced with explicit if/raise, FileNotFoundError now caught alongside ImportError) are addressed in the implementation.

Confidence Score: 5/5

Safe to merge — the change is purely additive and does not touch any existing code paths.

Purely additive change; all previously flagged blocking issues are resolved; helper symbols verified as exported from transformer_engine.pytorch.

No files require special attention.

Important Files Changed

Filename Overview
transformer_engine/init.py Adds test() entry point with installation integrity check and PyTorch forward-pass smoke test; previously flagged issues (assert→if/raise, FileNotFoundError catch) are addressed

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["transformer_engine.test()"] --> B["Import sanity_checks_for_pypi_installation"]
    B -->|Success| C["Run installation check"]
    B -->|Exception| D["_record('installation', False)"]
    C -->|Success| E["_record('installation', True)"]
    C -->|Exception| D
    E --> F["from . import pytorch as te"]
    D --> F
    F -->|ImportError / FileNotFoundError| G["te = None"]
    F -->|Success| H["te = pytorch module"]
    G --> N["No PyTorch checks added"]
    H --> I{"torch.cuda.is_available?"}
    I -->|No| J["_record('pytorch', True, 'no CUDA, skipped')"]
    I -->|Yes| K["Run te.Linear forward pass\ncheck output shape\ncollect format support"]
    K -->|Success| L["_record('pytorch', True, detail)"]
    K -->|Exception| M["_record('pytorch', False, err)"]
    J --> O["all(results)"]
    L --> O
    M --> O
    N --> O
    O --> P["Return True / False"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["transformer_engine.test()"] --> B["Import sanity_checks_for_pypi_installation"]
    B -->|Success| C["Run installation check"]
    B -->|Exception| D["_record('installation', False)"]
    C -->|Success| E["_record('installation', True)"]
    C -->|Exception| D
    E --> F["from . import pytorch as te"]
    D --> F
    F -->|ImportError / FileNotFoundError| G["te = None"]
    F -->|Success| H["te = pytorch module"]
    G --> N["No PyTorch checks added"]
    H --> I{"torch.cuda.is_available?"}
    I -->|No| J["_record('pytorch', True, 'no CUDA, skipped')"]
    I -->|Yes| K["Run te.Linear forward pass\ncheck output shape\ncollect format support"]
    K -->|Success| L["_record('pytorch', True, detail)"]
    K -->|Exception| M["_record('pytorch', False, err)"]
    J --> O["all(results)"]
    L --> O
    M --> O
    N --> O
    O --> P["Return True / False"]
Loading

Reviews (3): Last reviewed commit: "Add transformer_engine.test() installati..." | Re-trigger Greptile

Comment thread transformer_engine/__init__.py Outdated
Comment thread transformer_engine/__init__.py Outdated
Comment thread transformer_engine/__init__.py Outdated
@CodersAcademy006 CodersAcademy006 force-pushed the feat/transformerengine-test-entrypoint branch from ad5c755 to 58836ea Compare July 9, 2026 07:23
Comment thread transformer_engine/__init__.py
Add a top-level test() entry point so users can verify a Transformer Engine
installation without cloning the repository, similar to numpy.test(). It reuses
the existing PyPI sanity check and, for each installed framework backend, runs a
minimal forward pass on the current device. Checks that need a GPU are skipped
when no CUDA device is available, and the PyTorch check reports the device
compute capability and which low-precision formats it supports.

Closes NVIDIA#170

Signed-off-by: Srijan Upadhyay <srjnupadhyay@gmail.com>
@CodersAcademy006 CodersAcademy006 force-pushed the feat/transformerengine-test-entrypoint branch from 58836ea to 4224e1a Compare July 9, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution PRs from external contributor outside the core maintainers, representing community-driven work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add: transformerengine.test()

1 participant