Skip to content

[Feat] kernels: Add muse spark operators and collective GEMM (2/5) - #44665

Merged
Fridge003 merged 5 commits into
mainfrom
codex/muse-spark-stack-02-kernels
Oct 16, 2026
Merged

Fridge003 merged 5 commits into
mainfrom
codex/muse-spark-stack-02-kernels

Conversation

@Fridge003

@Fridge003 Fridge003 commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Split #44530 into five review layers. This is layer 2/5, based on #44664.

Modifications

Adds the Muse Spark operators, CUDA JIT kernels, collective GEMM implementations, and shared kernel integration. AMD-specific kernels and capabilities belong to the AMD layer; the changes from radixark/sglang-muse-spark#224 belong to the final layer.

This layer changes 44 files (+13,752 / -17) relative to its immediate base. Every split commit preserves all 32 Co-authored-by trailers from the original commit.

Validation

  • The remaining stack is based on main at 92580581da6fc8542a997a00c1a8b71b03497680; CUDA Docker support from [Chore] docker: Add muse spark CUDA image and DeepGEMM patches (1/5) #44664 is already merged.
  • Renamed python/sglang/kernels/jit/csrc/muse_spark_v12/ and python/sglang/kernels/ops/muse_spark_v12/ to muse_spark/. Updated downstream imports, lazy group registration, JIT source/module names, test strings and comments. No old muse_spark_v12 references remain in any of the four branch tips.
  • Independently reproduced all four complete Git trees from their pre-rename trees using only that uniform rename plus the repository formatters. Full byte comparison passes; Python AST comparison confirms no functional edits. Per-layer file scope, dependency order and all 32 original coauthor trailers are preserved. The Add SSL Cert Functionality #224 layer is equivalent under the namespace rename plus formatter normalization.
  • All applicable pre-commit hooks pass on affected files in every layer, including registered-test validation. Python compilation and import/JIT-source path resolution pass. An isolated kernel namespace/registry import smoke check passes without importing JIT or the old package.
  • Full namespace/dispatch pytest collection is blocked locally by unavailable Triton; GPU correctness and performance tests were not run. The prior rebase's 11 targeted conflict checks remain recorded separately.
  • Reproduction script and commands: mechanical rename proof in #44665.

Mechanical rename proof

The kernels PR contains a separate mechanical_provable rename commit. The same transform was applied to each downstream tree, keeping later layers out of earlier PRs. All four reproductions passed.

Standalone reproduction script (Python 3.12+, Git and pre-commit)

Save the following as reproduce_muse_spark_rename.py. Ensure the base/target SHAs embedded in records are present in your local clone (git fetch origin <sha> if needed), then run:

python3 reproduce_muse_spark_rename.py --repo /path/to/sglang

The script checks a temporary shared clone; it does not edit the source checkout.

"""Reproduce every stack tree from its pre-rename tree and compare all bytes.

Usage: python3 reproduce.py --repo /path/to/sglang 
Requires git and the repository's pre-commit environments. Fetch the base and
target SHAs embedded below into the source clone before running this script.
"""
import argparse
import json
import os
import pathlib
import subprocess
import tempfile

"""Rename the two Muse Spark kernel trees and all references, with no code edits."""
import pathlib
import subprocess

OLD = b"muse_spark_v12"
NEW = b"muse_spark"
DIRECTORIES = ("python/sglang/kernels/jit/csrc/", "python/sglang/kernels/ops/")


def transform(root):
    root = pathlib.Path(root)
    paths = subprocess.check_output(["git", "ls-files", "-z"], cwd=root).decode().split("\0")
    changed = []
    for relative in filter(None, paths):
        path = root / relative
        if path.is_symlink() or not path.is_file():
            continue
        source = path.read_bytes()
        target = source.replace(OLD, NEW)
        if target != source:
            path.write_bytes(target)
            changed.append(relative)
    moved = []
    for prefix in DIRECTORIES:
        source = root / (prefix + OLD.decode())
        target = root / (prefix + NEW.decode())
        assert source.is_dir() and not target.exists(), (source, target)
        moved.extend(str(path.relative_to(root)) for path in source.rglob("*") if path.is_file())
        source.rename(target)
    return dict(references=changed, moved=moved)





def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--repo', required=True)
    args = parser.parse_args()
    records = [{'pr': 44665, 'base': '359030dbac3aeab909533411583646790c3ebcb9', 'target': 'a2ac2718795b16a10a6e221eefa38e234abcc9e0'}, {'pr': 44666, 'base': 'f60333c7412ef5001b4e7fbab13dcb7aa1b87993', 'target': '90785dc87625d82e18c148826f99e01fefdbb503'}, {'pr': 44667, 'base': 'caf6b36a44e01a91a1f21524ca086b04af4b3933', 'target': 'cbd25ea6497f6dcec269af385fa374e75b9e4e13'}, {'pr': 44668, 'base': '51abebf433801bd6bcfadedf398a5b9a3c27dbf3', 'target': 'e297cab65cafffc94f3224d49858820affac7019'}]
    env = dict(os.environ, SKIP='no-commit-to-branch')
    with tempfile.TemporaryDirectory(prefix='muse-spark-rename-proof-') as temporary:
        checkout = pathlib.Path(temporary) / 'repo'
        subprocess.run(['git', 'clone', '--shared', '--no-checkout', '--quiet',
                        str(pathlib.Path(args.repo).resolve()), str(checkout)], check=True)

        def git(*argv):
            return subprocess.check_output(['git', *argv], cwd=checkout, env=env).decode().strip()

        for record in records:
            git('checkout', '--detach', '--quiet', record['base'])
            transform(checkout)
            git('add', '--all')
            changed = git('diff', '--cached', '--name-only', '--diff-filter=ACMR').splitlines()
            for attempt in range(2):
                result = subprocess.run(['pre-commit', 'run', '--files', *changed],
                                        cwd=checkout, env=env, capture_output=True, text=True)
                if result.returncode == 0:
                    break
                if attempt == 1:
                    raise RuntimeError(result.stdout + result.stderr)
                git('add', '--all')
            git('add', '--all')
            actual = git('write-tree')
            expected = git('rev-parse', record['target'] + '^{tree}')
            if actual != expected:
                raise AssertionError(git('diff', expected, actual))
            print(f"PASS #{record['pr']}: full tree reproduced exactly ({actual})", flush=True)
            git('reset', '--hard', record['target'])


if __name__ == '__main__':
    main()

Stack

Merge/review order, from main upward:

  1. #44664 — CUDA Docker and DeepGEMM patches
  2. #44665 — Kernels and collective GEMM
  3. #44666 — SRT and registered tests
  4. #44667 — AMD / ROCm support
  5. #44668 — Helion verify megakernels (Add SSL Cert Functionality #224)

The original #44530 remains unchanged as the full-stack reference.


CI States

Latest PR Test (Base): 🚫 Run #38870914490
Latest PR Test (Extra): ❌ Run #38870914510
Latest PR Test (AMD ROCm 10): 🚫 Run #38870914545

@github-actions github-actions Bot added documentation Improvements or additions to documentation quant LLM Quantization sgl-kernel jit-kernel labels Oct 16, 2026
@Fridge003 Fridge003 changed the title [Feat] muse-spark: Add kernels and collective GEMM operators [MuseSpark][2/5] Add kernels and collective GEMM operators Oct 16, 2026
@Fridge003
Fridge003 force-pushed the codex/muse-spark-stack-02-kernels branch from 8eb86c0 to 1a7f3d4 Compare October 16, 2026 05:20
Base automatically changed from codex/muse-spark-stack-01-docker to main October 16, 2026 05:46
Split layer 2/5 from #44530.
Source commit: a55ab7d

Co-authored-by: 1am9trash <[email protected]>
Co-authored-by: Alex Nails <[email protected]>
Co-authored-by: Baizhou Zhang <[email protected]>
Co-authored-by: Chunan Zeng <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Co-authored-by: Ethan Che <[email protected]>
Co-authored-by: HAI <[email protected]>
Co-authored-by: HaiShaw <[email protected]>
Co-authored-by: Jiajun Li <[email protected]>
Co-authored-by: Jiajun Li <[email protected]>
Co-authored-by: Jimmy Shiu <[email protected]>
Co-authored-by: Jimmy Shong <[email protected]>
Co-authored-by: Jimmy Shong <[email protected]>
Co-authored-by: Liangsheng Yin <[email protected]>
Co-authored-by: Wookje Han <[email protected]>
Co-authored-by: Wookje Han <[email protected]>
Co-authored-by: Wookje Han <[email protected]>
Co-authored-by: Wookje Han <[email protected]>
Co-authored-by: Wookje Han <[email protected]>
Co-authored-by: Wookje Han <[email protected]>
Co-authored-by: Yuhao Yang <[email protected]>
Co-authored-by: Yuhao Yang <[email protected]>
Co-authored-by: Zijie Chen <[email protected]>
Co-authored-by: ethche <[email protected]>
Co-authored-by: jacky.cheng <[email protected]>
Co-authored-by: jianan-gu <[email protected]>
Co-authored-by: yhyang201 <[email protected]>
@Fridge003
Fridge003 force-pushed the codex/muse-spark-stack-02-kernels branch from 1a7f3d4 to 359030d Compare October 16, 2026 06:29
@Fridge003 Fridge003 changed the title [MuseSpark][2/5] Add kernels and collective GEMM operators [Feat] kernels: Add muse spark operators and collective GEMM (2/5) Oct 16, 2026
Rename muse_spark_v12 to muse_spark in the JIT sources, operator
package, import paths, registry and JIT module names.

Co-authored-by: 1am9trash <[email protected]>
Co-authored-by: Alex Nails <[email protected]>
Co-authored-by: Baizhou Zhang <[email protected]>
Co-authored-by: Chunan Zeng <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Co-authored-by: Ethan Che <[email protected]>
Co-authored-by: HAI <[email protected]>
Co-authored-by: HaiShaw <[email protected]>
Co-authored-by: Jiajun Li <[email protected]>
Co-authored-by: Jiajun Li <[email protected]>
Co-authored-by: Jimmy Shiu <[email protected]>
Co-authored-by: Jimmy Shong <[email protected]>
Co-authored-by: Jimmy Shong <[email protected]>
Co-authored-by: Liangsheng Yin <[email protected]>
Co-authored-by: Wookje Han <[email protected]>
Co-authored-by: Wookje Han <[email protected]>
Co-authored-by: Wookje Han <[email protected]>
Co-authored-by: Wookje Han <[email protected]>
Co-authored-by: Wookje Han <[email protected]>
Co-authored-by: Wookje Han <[email protected]>
Co-authored-by: Yuhao Yang <[email protected]>
Co-authored-by: Yuhao Yang <[email protected]>
Co-authored-by: Zijie Chen <[email protected]>
Co-authored-by: ethche <[email protected]>
Co-authored-by: jacky.cheng <[email protected]>
Co-authored-by: jianan-gu <[email protected]>
Co-authored-by: yhyang201 <[email protected]>
@Fridge003 Fridge003 added the run-ci CI: run the baseline test suite on this PR label Oct 16, 2026
@Fridge003 Fridge003 added bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) parallel-stages CI: stages dispatch together instead of waiting on each other labels Oct 16, 2026
@Fridge003 Fridge003 removed the parallel-stages CI: stages dispatch together instead of waiting on each other label Oct 16, 2026
@Fridge003 Fridge003 added the highest-priority CI: all three control labels, plus never batch-cancelled or stale-closed label Oct 16, 2026
@Fridge003
Fridge003 merged commit 456231e into main Oct 16, 2026
216 of 277 checks passed
@Fridge003
Fridge003 deleted the codex/muse-spark-stack-02-kernels branch October 16, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fail-fast CI: a failing job no longer aborts its siblings (lint still gates) documentation Improvements or additions to documentation highest-priority CI: all three control labels, plus never batch-cancelled or stale-closed jit-kernel quant LLM Quantization run-ci CI: run the baseline test suite on this PR sgl-kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant