Skip to content

fep(sig-operator): add spacemit backend support for FlagGems#33

Open
alex-spacemit wants to merge 2 commits into
flagos-ai:mainfrom
alex-spacemit:feat/add-flaggems-spacemit-backend
Open

fep(sig-operator): add spacemit backend support for FlagGems#33
alex-spacemit wants to merge 2 commits into
flagos-ai:mainfrom
alex-spacemit:feat/add-flaggems-spacemit-backend

Conversation

@alex-spacemit

Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings June 5, 2026 08:36

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new FEP document describing SpacemiT backend enablement for FlagGems on FlagOS 2.1, including goals, integration details, and a basic validation test plan.

Changes:

  • Introduces an FEP summarizing SpacemiT backend scope, operator coverage, and integration approach.
  • Documents optional dependency behavior for triton.backends.spine_triton and device discovery via spacemit-tcm-smi.
  • Adds setup/test instructions and references to related PRs.

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

Comment on lines +19 to +21
- Adding SpacemiT runtime backend with operator implementations.
- Refactored the import structure and initialization logic for the SpacemiT backend.
Made the SpacemiT Triton configuration optional if triton.backends.spine_triton is unavailable, and added device detection via the spacemit-tcm-smi query command.
Comment on lines +79 to +84
| Category | Operators | Status | Notes |
|---|---|---|---|
| Exported forward-only operators | `argmax`, `argmin`, `bmm`, `bmm_out`, `global_avg_pool`, `mean_dim`, `mm`, `mm_out`, `mv`, `pow_scalar`, `pow_tensor_scalar`, `pow_tensor_scalar_`, `pow_tensor_tensor`, `pow_tensor_tensor_`, `rsqrt`, `where_scalar_other`, `where_scalar_self`, `where_self`, `where_self_out` | Enabled | Forward path is available; no backward/autograd registration |
| Exported operators with `torch.autograd.Function` integration | `layer_norm`, `silu` | Enabled | `layer_norm`: full forward/backward with weight/bias gradient kernels; `silu`: full forward/backward, also has in-place `silu_` (not exported) |
| Exported operators with separate backward function (no autograd.Function) | `gelu`, `softmax`, `sigmoid` | Enabled | `gelu`: supports `none` and `tanh` approximate modes, backward via `gelu_backward`; `softmax`: forward uses SpacemiT custom kernel (`softmax_kernel_spacemit`), backward delegates to `common_softmax_backward`; `sigmoid`: backward via `sigmoid_backward`, also has in-place `sigmoid_` (not exported) |
| Existing but not exported operator files | `addmm`, `conv1d`, `conv2d`, `conv_depthwise2d`, `flash_attention`, `thnn_conv2d` | Not exported | Operator files exist with full implementations, but imports/exports are commented out in `ops/__init__.py`. `conv1d` and `thnn_conv2d` are thin wrappers around `conv2d`; `conv_depthwise2d` delegates to `conv2d` with `groups`; `flash_attention` supports GQA, causal/non-causal modes, and `scaled_dot_product_attention`; `addmm` uses smt.dot with alpha/beta scaling |
Comment on lines +173 to +175
uv venv --python 3.12 .venv

source ./venv/bin/activate

Related PR:

- https://github.com/flagos-ai/FlagGems/pull/2527 — Add Spacemit runtime backend with operator implementations
- SpacemiT device query command is configured as `spacemit-tcm-smi`.

## Related PRs
- https://github.com/flagos-ai/FlagGems/pull/2527 — Add Spacemit runtime backend with operator implementations
- Enable SpacemiT device query through `spacemit-tcm-smi`.
- Add setup support for SpacemiT.
- Use Python 3.12 for SpacemiT setup compatibility.
- Record initial validation result from `tests/test_abs.py`、`tests/test_mm.py`.
```

### Expected Results
- `tests/test_abs.py`、`tests/test_mm.py` passes in the reported validation environment.
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.

2 participants