Skip to content

Commit 14ca809

Browse files
authored
Merge pull request #165 from IntelPython/add-copilot-instructions
Add Copilot instructions for AGENTS.md workflow
2 parents 9305d25 + 244fe7e commit 14ca809

2 files changed

Lines changed: 49 additions & 4 deletions

File tree

.github/copilot-instructions.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# GitHub Copilot Instructions — mkl_umath
2+
3+
## Identity
4+
You are an expert Python/C/Cython developer working on `mkl_umath` at Intel.
5+
Prioritize correctness, numerical integrity, and minimal diffs.
6+
7+
## Source of truth
8+
This file is canonical for Copilot/agent behavior.
9+
`AGENTS.md` files provide project context.
10+
11+
## Precedence
12+
copilot-instructions > nearest AGENTS > root AGENTS
13+
Higher-precedence rules override lower-precedence context.
14+
15+
## Mandatory flow
16+
1. Read root `AGENTS.md`. If absent, stop and report.
17+
2. For each edited file, locate and follow the nearest `AGENTS.md`.
18+
3. If no local file exists, inherit from root `AGENTS.md`.
19+
20+
## Contribution expectations
21+
- Keep changes atomic and single-purpose.
22+
- Preserve runtime patching API (`use_in_numpy()`, `restore()`, `is_patched()`) unless explicitly requested.
23+
- For behavior changes, update tests in `mkl_umath/tests/` in the same step.
24+
- For bugs, include a regression test.
25+
- Do not modify generated artifacts directly when template/source files are the intended edit points.
26+
27+
## Authoring rules
28+
- Never invent versions, compilers, or CI matrix values.
29+
- Use source-of-truth files for dependencies and build config.
30+
- Respect precision/correctness guardrails (`fp:precise`, `fimf-precision=high`, related flags).
31+
- Avoid hardcoded ISA assumptions unless explicitly present in existing build configuration.
32+
- Never include secrets or credentials in code/docs.
33+
34+
## Source-of-truth files
35+
- Build: `CMakeLists.txt`, `pyproject.toml`, `setup.py`
36+
- Dependencies/packaging: `conda-recipe*/meta.yaml`
37+
- CI: `.github/workflows/*.{yml,yaml}`
38+
- API: `mkl_umath/__init__.py`, `mkl_umath/src/_patch.pyx`
39+
- Core implementation: `mkl_umath/src/*.{c,c.src,pyx}`
40+
- Tests: `mkl_umath/tests/`
41+
42+
## Intel-specific constraints
43+
- oneMKL is required; `icx` and `clang` toolchains are both valid when compiler-specific flags are gated correctly.
44+
- Patching behavior must remain compatible with NumPy integration semantics.
45+
- Performance optimizations must not compromise numerical correctness.

AGENTS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ It provides:
1919

2020
## Build dependencies
2121
**Required:**
22-
- Intel® C Compiler (icx)
22+
- Compiler toolchain: Intel `icx` or `clang` (with Intel-only flags gated when using clang)
2323
- Intel® OneMKL (mkl-devel)
2424
- Intel® TBB (tbb-devel)
2525
- NumPy, Cython, scikit-build, cmake, ninja
@@ -30,7 +30,7 @@ conda install -c https://software.repos.intel.com/python/conda \
3030
mkl-devel tbb-devel dpcpp_linux-64 numpy-base \
3131
cmake ninja cython scikit-build
3232
export MKLROOT=$CONDA_PREFIX
33-
CC=icx pip install --no-build-isolation --no-deps .
33+
CC=${CC:-icx} pip install --no-build-isolation --no-deps . # clang is also supported in CI
3434
```
3535

3636
## CI/CD
@@ -72,9 +72,9 @@ mkl_umath.restore() # Restore original NumPy loops
7272
- **NumPy source:** Requires Intel-optimized NumPy from Intel channel (`software.repos.intel.com/python/conda`). PyPI NumPy may cause runtime failures or incorrect results.
7373
- **Precision flags:** `fp:precise`, `fimf-precision=high` enforce IEEE 754 compliance. Removing them breaks numerical correctness in scientific computing.
7474
- **Patching order:** If using multiple Intel patches (e.g., `mkl_random` + `mkl_umath`), apply `mkl_umath` last. Verify with `is_patched()` after each.
75-
- **Compiler:** Intel `icx` is the supported compiler. `build-with-clang.yml` validates compatibility, but icx is recommended for production.
75+
- **Compiler/toolchain:** `icx` and `clang` are both supported; when using clang, keep Intel-only flags behind compiler guards.
7676
- **Build validation:**
77-
- After setup: `which icx` → should point to conda env or oneAPI location
77+
- After setup: `which ${CC:-icx}` → should resolve to the intended compiler toolchain
7878
- Verify: `echo $MKLROOT` → should be set
7979
- Check: `python -c "import numpy; print(numpy.__version__)"` → confirm Intel NumPy
8080

0 commit comments

Comments
 (0)