MLX
File size: 3,574 Bytes
ced11e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# Contributing to SAM3 MLX

Thank you for considering contributing to SAM3 MLX! This document provides guidelines for contributing to the project.

## Code of Conduct

Be respectful and professional. We're all here to build great software together.

## How to Contribute

### Reporting Bugs

If you find a bug, please open an issue with:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Your environment (Mac model, macOS version, MLX version)
- Error messages and stack traces

### Suggesting Features

Feature requests are welcome! Please include:
- Clear use case
- Why this feature would be useful
- How it might work

### Pull Requests

1. **Fork the repository**
   ```bash
   git clone https://github.com/yourusername/sam3-mlx.git
   cd sam3-mlx
   ```

2. **Create a branch**
   ```bash
   git checkout -b feature/your-feature-name
   ```

3. **Make your changes**
   - Write clear, documented code
   - Follow the existing code style
   - Add tests for new functionality
   - Update documentation as needed

4. **Test your changes**
   ```bash
   # Run tests
   python tests/test_models.py

   # Run benchmarks
   python tests/benchmark.py

   # Check code style
   black sam3_mlx/
   ruff check sam3_mlx/
   ```

5. **Commit and push**
   ```bash
   git add .
   git commit -m "Add feature: your feature description"
   git push origin feature/your-feature-name
   ```

6. **Open a Pull Request**
   - Describe what you changed and why
   - Link any related issues
   - Wait for review

## Development Setup

```bash
# Clone the repository
git clone https://github.com/yourusername/sam3-mlx.git
cd sam3-mlx

# Install in development mode
pip install -e ".[dev]"

# Run tests
python tests/test_models.py
```

## Code Style

- **Python**: Follow PEP 8
- **Line length**: 100 characters
- **Formatting**: Use `black` for auto-formatting
- **Linting**: Use `ruff` for linting
- **Type hints**: Add type hints for function signatures

Example:
```python
def process_image(image: mx.array, size: int = 1024) -> mx.array:
    """
    Process image for SAM3 input

    Args:
        image: Input image array
        size: Target size

    Returns:
        Processed image
    """
    # Implementation here
    return processed_image
```

## Testing

- Add tests for all new features
- Maintain or improve code coverage
- Test on actual Apple Silicon hardware when possible
- Verify performance benchmarks don't regress

## Documentation

- Document all public functions and classes
- Update README.md for major changes
- Add examples for new features
- Keep docstrings up to date

## Performance

- Profile new code for performance
- Avoid unnecessary copies with MLX arrays
- Use MLX operations instead of numpy when possible
- Benchmark performance-critical changes

## Commit Messages

Write clear commit messages:
- Use present tense ("Add feature" not "Added feature")
- Keep first line under 72 characters
- Add detailed description if needed

Good examples:
```
Add RoPE attention implementation

Implements Rotary Position Embeddings for spatial awareness
in the vision transformer.
```

```
Fix memory leak in mask decoder

The transformer was not releasing intermediate tensors,
causing memory to grow with each inference.
```

## Release Process

Maintainers will:
1. Update version in `pyproject.toml`
2. Update CHANGELOG.md
3. Create a git tag
4. Publish to PyPI

## Questions?

Open an issue or start a discussion!

## License

By contributing, you agree that your contributions will be licensed under the MIT License.