File size: 9,371 Bytes
5e820f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# Contributing to Musubi Tuner

Thank you for your interest in contributing to Musubi Tuner! We welcome contributions from the community and are excited to work with you to make this project even better.

## Table of Contents

- [Getting Started](#getting-started)
- [Before You Contribute](#before-you-contribute)
- [How to Contribute](#how-to-contribute)
  - [Reporting Issues](#reporting-issues)
  - [Suggesting Features](#suggesting-features)
  - [Contributing Code](#contributing-code)
- [Development Setup](#development-setup)
- [Code Style and Guidelines](#code-style-and-guidelines)
- [Testing](#testing)
- [Pull Request Process](#pull-request-process)
- [Licensing and Attribution](#licensing-and-attribution)
- [Community and Support](#community-and-support)

## Getting Started

Before contributing, please:

1. Read through this contributing guide
2. Review the [README.md](README.md) to understand the project
3. Check the [existing issues](https://github.com/kohya-ss/musubi-tuner/issues) and [discussions](https://github.com/kohya-ss/musubi-tuner/discussions)
4. Set up your development environment

## Before You Contribute

### Important Notes

- This project is under active development with limited maintainer resources
- PR reviews and merges may take time
- Breaking changes may occur as the project evolves
- For questions and general discussion, use [GitHub Discussions](https://github.com/kohya-ss/musubi-tuner/discussions)
- For bug reports and feature requests, use [GitHub Issues](https://github.com/kohya-ss/musubi-tuner/issues)

### Types of Contributions We Welcome

- Bug fixes
- Performance improvements
- Documentation improvements
- New features (with prior discussion)
- Code quality improvements

## How to Contribute

### Reporting Issues

Before creating a new issue:

1. **Search existing issues** to avoid duplicates
2. **Check discussions** as your question might already be answered

When creating a bug report, include:

- **Clear, descriptive title**
- **Detailed description** of the problem
- **Steps to reproduce** the issue
- **Environment details**:
  - Operating System
  - GPU model and VRAM
  - Python version
  - PyTorch version
  - CUDA version
- **Error messages or logs**
- **Expected vs actual behavior**
- **Screenshots or videos** (if applicable)

### Suggesting Features

For feature requests:

1. **Open an issue first** to discuss the feature
2. **Explain the problem** your feature would solve
3. **Describe the proposed solution**
4. **Consider alternatives** and their trade-offs
5. **Wait for feedback** before starting implementation (there's always a chance the PR won't be merged)

For significant features, consider posting in [GitHub Discussions](https://github.com/kohya-ss/musubi-tuner/discussions) first to gather community input.

### Contributing Code

1. **Open an issue** to discuss your proposed changes (unless it's a trivial fix)
2. **Wait for approval** before starting work on significant changes
3. **Fork the repository** and create a feature branch
4. **Make your changes** following our code style guidelines
5. **Test your changes** thoroughly
6. **Submit a pull request**

## Development Setup

### Prerequisites

- Python 3.10 or later
- Git
- CUDA-compatible GPU (for testing GPU features)
- 12GB+ VRAM recommended

### Installation

1. **Fork and clone the repository**:
   ```shell
   git clone https://github.com/your-username/musubi-tuner.git
   cd musubi-tuner
   ```

2. **Set up the development environment**:

   **Option A: Using pip**
   ```shell
   # Create virtual environment
   python -m venv .venv

   # Activate virtual environment
   # On Windows:
   .venv/Scripts/activate
   # On Linux/Mac:
   source .venv/bin/activate

   # Install PyTorch (adjust for your CUDA version)
   pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128

   # Install the package in development mode
   pip install -e .

   # Install development dependencies
   pip install --group dev
   ```

	**Option B: Using uv**
   ```shell
   # Install uv if not present
   curl -LsSf https://astral.sh/uv/install.sh | sh  # Linux/Mac
   # or
   powershell -c "irm https://astral.sh/uv/install.ps1 | iex"  # Windows

   # Install dependencies
   uv sync --extra cu128  # or cu124 based on your CUDA version
   ```

3. **Configure Accelerate**:
   ```shell
   accelerate config
   ```

## Code Style and Guidelines

### Python Code Style

This project uses **Ruff** for code linting and code formatting:

- **Line length**: 132 characters
- **Indentation**: 4 spaces
- **Quote style**: Double quotes
- **Target Python version**: 3.10

### IDE

https://docs.astral.sh/ruff/editors/setup/

### Running Code Quality Tools

```shell
# Check code style and potential issues
ruff check

# Auto-fix issues where possible
ruff check --fix

# Format code (note: use ruff for formatting, not black)
ruff format src
```

### Code Guidelines

- **Follow existing patterns** in the codebase
- **Write clear, descriptive variable names**
- **Add type hints** where appropriate
- **Keep functions focused** and reasonably sized
- **Add docstrings** for public functions and classes
- **Handle errors appropriately** - Let unrecoverable errors fail fast; only catch and handle errors you can meaningfully recover from

### Import Organization

- Standard library imports first
- Third-party imports second
- Local imports last
- Use absolute imports when possible

### Code Modification Guidelines

When working with existing code:

- **Maintain compatibility** with existing interfaces
- **Follow the existing module structure**
- **Update relevant documentation** in the `docs/` directory
- **Test across different architectures** if your changes affect multiple architectures and you have the capability to do so

When working with architecture-specific code (HunyuanVideo, Wan2.1/2.2, FramePack, FLUX.1 Kontext, Qwen-Image):

- **Follow naming conventions**: When adding a new architecture, follow the `{arch}_train_network.py` and `{arch}_generate_{type}.py` naming pattern
- **Consider cross-architecture impact** when making changes within shared modules
- **Test with representative models** if possible

## Testing

### Running Tests

```shell
# Run code quality checks
ruff check

# Format code
ruff format src

# Test your changes manually with the relevant scripts
```

### Manual Testing Guidelines

Since this project deals with machine learning models:

1. **Test with small datasets** first
2. **Verify memory usage** is within expected boundaries
3. **Test on different GPU configurations** if possible
4. **Validate output quality** for generation/training features

## Pull Request Process

### Before Submitting

1. **Ensure your branch is up to date** with the main branch
2. **Run code quality tools**:
   ```shell
   ruff check --fix
   ruff format src
   ```
3. **Test your changes** thoroughly
4. **Update documentation** if needed
5. **Write clear commit messages**

### Pull Request Template

When creating a PR, include:

- **Clear title** describing the change
- **Description** of what changed and why
- **Issue reference** (e.g., "Closes #123")
- **Testing performed**
- **Breaking changes** (if any)
- **Documentation updates** (if any)

### Review Process

- Maintainers will review PRs when time permit
- Be patient as reviews may take time due to limited resources
- Address feedback constructively
- Keep discussions focused and professional

## Licensing and Attribution

### Attribution Requirements

When contributing code derived from or inspired by other projects:

1. **Add appropriate license headers** to new files
2. **Include attribution comments** for copied/modified code
3. **Update the LICENSE section on README.md** if introducing new license requirements for new architectures
4. **Document the source** in your pull request description

### Third-Party Code

If your contribution includes third-party code:

1. **Ensure license compatibility** with the project
2. **Include the original license file** or header
3. **Document the source and license** clearly. Incorporate this in your pull request description as well
4. **Fulfill all obligations** from the source license

## Community and Support

### Communication Channels

- **GitHub Discussions**: General questions, ideas, and community interaction
- **GitHub Issues**: Bug reports and feature requests
- **Pull Requests**: Code contributions and reviews

### Getting Help

If you need help with:

- **Using the software**: Check [GitHub Discussions](https://github.com/kohya-ss/musubi-tuner/discussions)
- **Development setup**: Create an issue with the "question" label or ask in discussions
- **Contributing process**: Reference this guide or ask in discussions

### Recognition

Contributors are recognized through:

- **Git commit history**
- **Release notes** for significant contributions
- **README acknowledgments** for major features

---

## Final Notes

We appreciate your interest in contributing to Musubi Tuner! This project benefits greatly from community contributions, and we're grateful for your time and effort.

Remember:
- **Start small** with your first contribution
- **Ask questions** if anything is unclear
- **Be patient** with the review process
- **Have fun** building amazing tools!

Thank you for helping make Musubi Tuner better for everyone!