Thank you for your interest in contributing to MLX-Node! We welcome contributions from the community and are excited to work with you.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/yourusername/mlx-node.git cd mlx-node - Install dependencies:
yarn install
- Build the project:
yarn build
- Run tests to ensure everything works:
yarn test
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes following our code style and conventions
-
Add tests for new functionality
-
Run tests to ensure nothing is broken:
yarn test yarn typecheck yarn lint -
Commit your changes with a descriptive message:
git commit -m "feat: add new sampling method"
-
Push your branch to your fork:
git push origin feature/your-feature-name
-
Open a Pull Request on GitHub
-
Describe your changes clearly in the PR description
-
Wait for review - we'll review your PR as soon as possible
- Use TypedArrays for all numeric data
- Follow the existing patterns in the codebase
- Add JSDoc comments for public APIs
- Use meaningful variable names
- Follow Rust naming conventions (snake_case for functions/variables)
- Use
#[napi]attributes for exports to Node.js - Add documentation comments with
/// - Handle errors with
Result<T>types
- Write tests for all new features
- Use descriptive test names
- Test edge cases and error conditions
- Aim for high test coverage
To add a new MLX operation:
- Add FFI binding in
mlx-sys/src/lib.rs - Add C++ bridge in
mlx-sys/src/mlx.cppif needed - Implement Rust wrapper in appropriate module (e.g.,
node/src/array.rs) - Run
yarn buildto generate TypeScript definitions - Add comprehensive tests
To add a new layer:
- Implement in
node/src/nn.rswith#[napi]exports - Add gradient computation if needed in
node/src/gradients.rs - Update TypeScript re-exports in
src/nn/ - Add tests in
__test__/core/
To add a new sampling strategy:
- Implement in
node/src/sampling.rs - Add to the unified
samplefunction - Update TypeScript types
- Add tests in
__test__/utils/sampling.test.ts
- Update relevant markdown files in
docs/ - Add JSDoc comments for TypeScript APIs
- Add documentation comments for Rust functions
- Update README.md if adding major features
- Use zero-copy operations where possible
- Leverage MLX's lazy evaluation
- Minimize data transfers between JS and Rust
- Profile performance-critical code paths
mlx-node/
├── node/src/ # Rust implementation (NAPI)
├── src/ # TypeScript orchestration
├── __test__/ # Test suite
├── mlx-sys/ # Low-level MLX bindings
└── docs/ # Documentation
We especially welcome contributions in these areas:
- New Models: Implement additional model architectures
- Optimizations: Performance improvements
- Documentation: Improve docs and examples
- Testing: Expand test coverage
- Bug Fixes: Fix reported issues
If you have questions:
- Check existing issues
- Open a new issue for discussion
- Join our community discussions
By contributing, you agree that your contributions will be licensed under the MIT License.
Please note that this project follows a Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
Thank you for contributing to MLX-Node! 🚀