Skip to content

Add nvtx as an optional dependency with a no-op fallback - #706

Merged
AkshitaB merged 1 commit into
akshitab/moe-v2-corefrom
akshitab/moe-nvtx-optional
Jun 9, 2026
Merged

AkshitaB merged 1 commit into
akshitab/moe-v2-corefrom
akshitab/moe-nvtx-optional

Conversation

@AkshitaB

@AkshitaB AkshitaB commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

What this adds

Makes nvtx (NVIDIA Tools Extension) an optional dependency instead of a hard requirement. nvtx is only used to emit profiler ranges (@nvtx.annotate(...)), so code shouldn't fail to import when it isn't installed. This is setup for future use.

  • New profiling extra in pyproject.toml (pip install ai2-olmo-core[profiling]), also rolled into the all extra.

  • New olmo_core._nvtx module exposing a no-op nvtx stand-in whose annotate works as both a decorator and a context manager. Modules that annotate hot paths import defensively:

    try:
        import nvtx
    except ImportError:
        from olmo_core._nvtx import nvtx

    so the annotations become no-ops when nvtx isn't installed.

Testing

src/test/nvtx_test.py exercises the no-op shim as both a decorator and a context manager. Pure-Python, CPU-only.

@AkshitaB
AkshitaB force-pushed the akshitab/moe-nvtx-optional branch from ca06286 to 23eeb5e Compare June 5, 2026 18:51
nvtx (NVIDIA Tools Extension) is used only to emit profiler ranges, so make it an
optional dependency (new `profiling` extra) instead of a hard requirement. Add
olmo_core._nvtx, which provides a no-op `nvtx` stand-in exposing `annotate` as both
a decorator and a context manager, so modules can guard their imports:

    try:
        import nvtx
    except ImportError:
        from olmo_core._nvtx import nvtx

The annotations then become no-ops when nvtx is not installed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@AkshitaB
AkshitaB force-pushed the akshitab/moe-nvtx-optional branch from 23eeb5e to 1a270e2 Compare June 6, 2026 00:45
@AkshitaB
AkshitaB requested review from farhatkevin and undfined June 6, 2026 00:46
@AkshitaB
AkshitaB merged commit aa3f61c into akshitab/moe-v2-core Jun 9, 2026
24 checks passed
@AkshitaB
AkshitaB deleted the akshitab/moe-nvtx-optional branch June 9, 2026 00:29
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.

1 participant