Skip to content

feat(mars): add native Mars kernels and htcc wrapper - #939

Closed
Ceng23333 wants to merge 2 commits into
InfiniTensor:masterfrom
Ceng23333:feat/mars-native-kernels-htcc
Closed

feat(mars): add native Mars kernels and htcc wrapper#939
Ceng23333 wants to merge 2 commits into
InfiniTensor:masterfrom
Ceng23333:feat/mars-native-kernels-htcc

Conversation

@Ceng23333

@Ceng23333 Ceng23333 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add Mars/HPCC device backend under src/native/cuda/mars/ (mirrors src/native/cuda/metax/ layout).
  • Thin Operator<…, Device::Type::kMars> specializations reuse shared src/native/cuda/ops/*/kernel.h (same pattern as metax — not #include of metax headers).
  • HPCC-only glue: hcblas, scripts/htcc_wrapper.sh, CMake WITH_MARS, htcc compile path.

Motivation

Enable InfiniOps on MetaX X203 / HPCC Mars (--device mars / InfiniLM --refactor-dev) without going through the MetaX/MACA stack. Layout policy: Mars impl stays under src/native/cuda/mars/, sharing generic CUDA ops like metax.

Closes # (none)

Type of Change

  • feat — new feature / new operator / new platform
  • fix — bug fix
  • perf — performance improvement (no behavioral change)
  • refactor — code restructuring without behavior change
  • test — adding or fixing tests only
  • docs — documentation only
  • build / ci — build system or CI configuration
  • chore — tooling, formatting, or other non-code changes
  • Breaking change (requires a ! in the Conventional Commits prefix or a BREAKING CHANGE: footer)

Platforms Affected

  • CPU (WITH_CPU)
  • NVIDIA (WITH_NVIDIA)
  • Iluvatar (WITH_ILUVATAR)
  • MetaX (WITH_METAX)
  • Cambricon (WITH_CAMBRICON)
  • Moore (WITH_MOORE)
  • Ascend (WITH_ASCEND)
  • PyTorch C++ bindings (WITH_TORCH)
  • Build system / CMake / CI
  • Python bindings / user-facing API

Note: Mars / HPCC (WITH_MARS) is the affected GPU backend; it is not yet a checkbox in this template.

Smoke Test Result

Host: MetaX X203 / HPCC, container infinilm-dev-refactor-dev (/opt/conda torch 2.8.0+mars, HPCC).
Branch feat/mars-native-kernels-htcc @ 9805393.
INFINI_RT_ROOT = /workspace/InfiniLM/build/integration/mars/prefix.

python -m pip install .[dev] --no-build-isolation --no-deps \
  --config-settings=cmake.define.INFINI_RT_ROOT=/workspace/InfiniLM/build/integration/mars/prefix \
  --config-settings=cmake.define.WITH_MARS=ON \
  --config-settings=cmake.define.INFINI_OPS_SMOKE_BUILD=ON
# Successfully built InfiniOps (cp310-linux_aarch64 wheel); install exit 0

python -m pytest tests -m smoke -q --devices cuda
# 92 passed, 35 skipped, 6235 deselected in 7.59s

Follow-up on this branch for smoke enablement:

  • compile Mars torch unity with system g++ + -DUSE_HPCC=1 (MetaX/Moore pattern);
  • TorchDeviceName<kMars>"cuda";
  • Mars torch C10 helper + generated/hand-written torch instantiations;
  • htcc_wrapper.sh places .cu symlinks beside sources (not /tmp).

Test Results on Supported Platforms

Platform Affected Build / Smoke Result Full Result / Notes
NVIDIA no N/A - not affected
Iluvatar no N/A - not affected
MetaX no N/A - not affected
Cambricon no N/A - not affected
Moore no N/A - not affected
Ascend no N/A - not affected
Mars/HPCC (WITH_MARS) yes pip smoke + pytest -m smoke passed (92 passed, 35 skipped) Container infinilm-dev-refactor-dev; --devices cuda (Mars torch).
Full `pytest` output (optional)
s......ssssssssss....ssssssss........................................... [ 62%]
......................ssss.......s..........                             [100%]
92 passed, 35 skipped, 6235 deselected in 7.59s

Benchmark / Performance Impact

N/A

Notes for Reviewers

  • Mars kernels live under src/native/cuda/mars/ and reuse src/native/cuda/ops like metax; do not rewrite to #include metax headers (Device::Type::kMars vs kMetax).
  • Cherry-picked onto current master as a Mars-only change (does not include the older linked/ops.json commits from the Ceng refactor-dev line).
  • Personal fork PR for the freeze-base review surface will be closed in favor of this upstream PR.
  • Mars CONTRIBUTING smoke (pip install + pytest -m smoke) is green on this PR tip (9805393).

Port MetaX CUDA kernels to native/cuda/mars, compile .cc via htcc_wrapper,
and link HPCC libhtomp so InfiniOps can build WITH_MARS.
…vice

Compile Mars torch sources with system g++ (USE_HPCC) like MetaX/Moore,
map TorchDeviceName to cuda, instantiate Mars torch backends, and keep
htcc .cu rewrites beside sources so bindings includes resolve correctly.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Ceng23333

Copy link
Copy Markdown
Contributor Author

Superseded by a stacked PR split that isolates Mars kernels from platform/torch:

Upstream (InfiniTensor/InfiniOps) — merge order

  1. feat(mars): add WITH_MARS platform and htcc wrapper #941feat(mars): add WITH_MARS platform and htcc wrapper
  2. feat(mars): add native Mars operator specializations #942feat(mars): add native Mars operator specializations (depends on feat(mars): add WITH_MARS platform and htcc wrapper #941)
  3. fix(mars): enable torch bindings and CONTRIBUTING smoke #943fix(mars): enable torch bindings and CONTRIBUTING smoke (depends on feat(mars): add native Mars operator specializations #942)

Fork base-branch stack (isolated diffs)

  1. Platform branch feat/mars-platform-htcc (upstream feat(mars): add WITH_MARS platform and htcc wrapper #941)
  2. feat(mars): add native Mars operator specializations Ceng23333/InfiniOps#2 — kernels, base feat/mars-platform-htcc
  3. fix(mars): enable torch bindings and CONTRIBUTING smoke Ceng23333/InfiniOps#3 — torch/smoke, base feat/mars-native-kernels

After #941 merges, retarget #942master; after #942 merges, retarget #943master.

Closing this monolithic PR (#939) in favor of the stack.

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