Skip to content

Fix docker, cmake and imports after torch export support - #358

Merged
shijieliu merged 3 commits into
NVIDIA:mainfrom
geoffreyQiu:junyiq/fix_docker
Apr 14, 2026
Merged

shijieliu merged 3 commits into
NVIDIA:mainfrom
geoffreyQiu:junyiq/fix_docker

Conversation

@geoffreyQiu

Copy link
Copy Markdown
Collaborator
  • Fix docker file for HSTU Torch export support

  • Fix inc & lib path for HSTU C++ inference example

  • Fix (indirect) import (of Megatron) for TritonServer tests

@greptile-apps

greptile-apps Bot commented Apr 14, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes Docker build infrastructure, CMake library paths, and Python import guards to support HSTU Torch export in inference/Triton-server environments. The most notable change is that Megatron-LM is now unconditionally installed (fixing indirect import failures in Triton-server tests) and HSTU_INFERENCE_ONLY=1 now gates the HSTUBlock training import at runtime.

  • The INFERENCEBUILD build ARG is declared but no longer used anywhere in Dockerfile; it should be removed to avoid silently ignoring --build-arg INFERENCEBUILD=1.
  • The libcuda.so.1 symlink replacement and dynamicemb torch-binding build were previously opt-in (INFERENCEBUILD=1) and are now opt-out (TRITONSERVER_BUILD!=1), meaning they run in every default image build — worth verifying this is the intended default for Torch-export support.

Confidence Score: 5/5

Safe to merge; all remaining findings are P2 style/cleanup suggestions that do not block correctness.

The functional changes (unconditional Megatron-LM install, HSTU_INFERENCE_ONLY guard, pynve torch bindings, json include path) are straightforward and align with the PR intent. The two open comments are both P2: a dead ARG and a note about the inverted build condition semantics. Neither causes a runtime error in the changed paths.

docker/Dockerfile — stale INFERENCEBUILD ARG and inverted build-condition semantics worth a second look.

Important Files Changed

Filename Overview
docker/Dockerfile Megatron-LM is now always installed (was conditional on INFERENCEBUILD); libcuda/dynamicemb build condition inverted from opt-in (INFERENCEBUILD=1) to opt-out (TRITONSERVER_BUILD!=1); stale INFERENCEBUILD ARG left declared but unused; cpp_inference cmake build removed from image.
docker/Dockerfile.nve Adds PYNVE_WITH_TORCH_BINDINGS=1 and PYNVE_DISABLE_AVX512=1 env vars to enable torch bindings in pynve install; fixes missing trailing newline.
examples/hstu/inference/cpp_inference/CMakeLists.txt Removes fallback CMAKE_PREFIX_PATH from NVE library search paths (pynve only), adds /workspace/nve/third_party/json/include/ to include dirs, fixes missing EOF newline.
examples/hstu/inference/launch_triton_server.sh Adds HSTU_INFERENCE_ONLY=1 to the tritonserver launch command, enabling inference-only mode that skips Megatron/training imports.
examples/hstu/modules/inference_dense_module.py HSTUBlock import is now gated on HSTU_INFERENCE_ONLY env var; when set, HSTUBlock=None to avoid pulling in Megatron/training deps at Triton server startup.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[docker build] --> B{TRITONSERVER_BUILD=1?}
    B -- Yes --> C[Install minimal Python pkgs\ncmake, patchelf\ntorch from pytorch.org]
    B -- No --> D[Install Megatron-LM\nalways installed now]
    C --> D
    D --> E[pip install torchx, torchmetrics,\ntriton, fbgemm, torchrec, etc.]
    E --> F{TRITONSERVER_BUILD=1?}
    F -- Yes --> G[Skip libcuda symlink\nSkip dynamicemb build]
    F -- No --> H[Replace libcuda.so.1 symlink\nBuild dynamicemb torch_binding]
    G --> I[Image ready]
    H --> I

    subgraph Runtime: Triton Server
        J[launch_triton_server.sh] --> K[HSTU_INFERENCE_ONLY=1 tritonserver start]
        K --> L{os.getenv HSTU_INFERENCE_ONLY}
        L -- 1 --> M[HSTUBlock = None, skip training imports]
        L -- 0 --> N[from modules.hstu_block import HSTUBlock]
    end
Loading

Reviews (2): Last reviewed commit: "Fix upon reviews" | Re-trigger Greptile

Comment thread docker/Dockerfile Resolved

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 updates the HSTU inference/export tooling and container build so Torch export + TritonServer execution work without import/path issues.

Changes:

  • Add an inference-only mode (HSTU_INFERENCE_ONLY) to avoid importing export-only components at runtime and propagate it into Triton launch.
  • Adjust CMake configuration for the HSTU C++ inference example (include paths + library lookup paths).
  • Update Docker builds to ensure Megatron-LM is installed and adjust build conditionals for TritonServer-related images.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
examples/hstu/modules/inference_dense_module.py Conditional import/stub of HSTUBlock based on HSTU_INFERENCE_ONLY.
examples/hstu/inference/launch_triton_server.sh Sets HSTU_INFERENCE_ONLY=1 when launching tritonserver.
examples/hstu/inference/cpp_inference/CMakeLists.txt Updates library search paths and adds a JSON include dir.
docker/Dockerfile.nve Sets build env vars for pip install (Torch bindings, AVX512 disable).
docker/Dockerfile Always installs Megatron-LM; refactors build steps gated by TRITONSERVER_BUILD.

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

Comment thread docker/Dockerfile Resolved
Comment thread docker/Dockerfile Resolved
@geoffreyQiu
geoffreyQiu requested a review from shijieliu April 14, 2026 02:28
@shijieliu
shijieliu merged commit 0edd666 into NVIDIA:main Apr 14, 2026
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.

3 participants