@synsci/cli-darwin-x64 1.1.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. package/bin/skills/accelerate/SKILL.md +332 -0
  2. package/bin/skills/accelerate/references/custom-plugins.md +453 -0
  3. package/bin/skills/accelerate/references/megatron-integration.md +489 -0
  4. package/bin/skills/accelerate/references/performance.md +525 -0
  5. package/bin/skills/audiocraft/SKILL.md +564 -0
  6. package/bin/skills/audiocraft/references/advanced-usage.md +666 -0
  7. package/bin/skills/audiocraft/references/troubleshooting.md +504 -0
  8. package/bin/skills/autogpt/SKILL.md +403 -0
  9. package/bin/skills/autogpt/references/advanced-usage.md +535 -0
  10. package/bin/skills/autogpt/references/troubleshooting.md +420 -0
  11. package/bin/skills/awq/SKILL.md +310 -0
  12. package/bin/skills/awq/references/advanced-usage.md +324 -0
  13. package/bin/skills/awq/references/troubleshooting.md +344 -0
  14. package/bin/skills/axolotl/SKILL.md +158 -0
  15. package/bin/skills/axolotl/references/api.md +5548 -0
  16. package/bin/skills/axolotl/references/dataset-formats.md +1029 -0
  17. package/bin/skills/axolotl/references/index.md +15 -0
  18. package/bin/skills/axolotl/references/other.md +3563 -0
  19. package/bin/skills/bigcode-evaluation-harness/SKILL.md +405 -0
  20. package/bin/skills/bigcode-evaluation-harness/references/benchmarks.md +393 -0
  21. package/bin/skills/bigcode-evaluation-harness/references/custom-tasks.md +424 -0
  22. package/bin/skills/bigcode-evaluation-harness/references/issues.md +394 -0
  23. package/bin/skills/bitsandbytes/SKILL.md +411 -0
  24. package/bin/skills/bitsandbytes/references/memory-optimization.md +521 -0
  25. package/bin/skills/bitsandbytes/references/qlora-training.md +521 -0
  26. package/bin/skills/bitsandbytes/references/quantization-formats.md +447 -0
  27. package/bin/skills/blip-2/SKILL.md +564 -0
  28. package/bin/skills/blip-2/references/advanced-usage.md +680 -0
  29. package/bin/skills/blip-2/references/troubleshooting.md +526 -0
  30. package/bin/skills/chroma/SKILL.md +406 -0
  31. package/bin/skills/chroma/references/integration.md +38 -0
  32. package/bin/skills/clip/SKILL.md +253 -0
  33. package/bin/skills/clip/references/applications.md +207 -0
  34. package/bin/skills/constitutional-ai/SKILL.md +290 -0
  35. package/bin/skills/crewai/SKILL.md +498 -0
  36. package/bin/skills/crewai/references/flows.md +438 -0
  37. package/bin/skills/crewai/references/tools.md +429 -0
  38. package/bin/skills/crewai/references/troubleshooting.md +480 -0
  39. package/bin/skills/deepspeed/SKILL.md +141 -0
  40. package/bin/skills/deepspeed/references/08.md +17 -0
  41. package/bin/skills/deepspeed/references/09.md +173 -0
  42. package/bin/skills/deepspeed/references/2020.md +378 -0
  43. package/bin/skills/deepspeed/references/2023.md +279 -0
  44. package/bin/skills/deepspeed/references/assets.md +179 -0
  45. package/bin/skills/deepspeed/references/index.md +35 -0
  46. package/bin/skills/deepspeed/references/mii.md +118 -0
  47. package/bin/skills/deepspeed/references/other.md +1191 -0
  48. package/bin/skills/deepspeed/references/tutorials.md +6554 -0
  49. package/bin/skills/dspy/SKILL.md +590 -0
  50. package/bin/skills/dspy/references/examples.md +663 -0
  51. package/bin/skills/dspy/references/modules.md +475 -0
  52. package/bin/skills/dspy/references/optimizers.md +566 -0
  53. package/bin/skills/faiss/SKILL.md +221 -0
  54. package/bin/skills/faiss/references/index_types.md +280 -0
  55. package/bin/skills/flash-attention/SKILL.md +367 -0
  56. package/bin/skills/flash-attention/references/benchmarks.md +215 -0
  57. package/bin/skills/flash-attention/references/transformers-integration.md +293 -0
  58. package/bin/skills/gguf/SKILL.md +427 -0
  59. package/bin/skills/gguf/references/advanced-usage.md +504 -0
  60. package/bin/skills/gguf/references/troubleshooting.md +442 -0
  61. package/bin/skills/gptq/SKILL.md +450 -0
  62. package/bin/skills/gptq/references/calibration.md +337 -0
  63. package/bin/skills/gptq/references/integration.md +129 -0
  64. package/bin/skills/gptq/references/troubleshooting.md +95 -0
  65. package/bin/skills/grpo-rl-training/README.md +97 -0
  66. package/bin/skills/grpo-rl-training/SKILL.md +572 -0
  67. package/bin/skills/grpo-rl-training/examples/reward_functions_library.py +393 -0
  68. package/bin/skills/grpo-rl-training/templates/basic_grpo_training.py +228 -0
  69. package/bin/skills/guidance/SKILL.md +572 -0
  70. package/bin/skills/guidance/references/backends.md +554 -0
  71. package/bin/skills/guidance/references/constraints.md +674 -0
  72. package/bin/skills/guidance/references/examples.md +767 -0
  73. package/bin/skills/hqq/SKILL.md +445 -0
  74. package/bin/skills/hqq/references/advanced-usage.md +528 -0
  75. package/bin/skills/hqq/references/troubleshooting.md +503 -0
  76. package/bin/skills/hugging-face-cli/SKILL.md +191 -0
  77. package/bin/skills/hugging-face-cli/references/commands.md +954 -0
  78. package/bin/skills/hugging-face-cli/references/examples.md +374 -0
  79. package/bin/skills/hugging-face-datasets/SKILL.md +547 -0
  80. package/bin/skills/hugging-face-datasets/examples/diverse_training_examples.json +239 -0
  81. package/bin/skills/hugging-face-datasets/examples/system_prompt_template.txt +196 -0
  82. package/bin/skills/hugging-face-datasets/examples/training_examples.json +176 -0
  83. package/bin/skills/hugging-face-datasets/scripts/dataset_manager.py +522 -0
  84. package/bin/skills/hugging-face-datasets/scripts/sql_manager.py +844 -0
  85. package/bin/skills/hugging-face-datasets/templates/chat.json +55 -0
  86. package/bin/skills/hugging-face-datasets/templates/classification.json +62 -0
  87. package/bin/skills/hugging-face-datasets/templates/completion.json +51 -0
  88. package/bin/skills/hugging-face-datasets/templates/custom.json +75 -0
  89. package/bin/skills/hugging-face-datasets/templates/qa.json +54 -0
  90. package/bin/skills/hugging-face-datasets/templates/tabular.json +81 -0
  91. package/bin/skills/hugging-face-evaluation/SKILL.md +656 -0
  92. package/bin/skills/hugging-face-evaluation/examples/USAGE_EXAMPLES.md +382 -0
  93. package/bin/skills/hugging-face-evaluation/examples/artificial_analysis_to_hub.py +141 -0
  94. package/bin/skills/hugging-face-evaluation/examples/example_readme_tables.md +135 -0
  95. package/bin/skills/hugging-face-evaluation/examples/metric_mapping.json +50 -0
  96. package/bin/skills/hugging-face-evaluation/requirements.txt +20 -0
  97. package/bin/skills/hugging-face-evaluation/scripts/evaluation_manager.py +1374 -0
  98. package/bin/skills/hugging-face-evaluation/scripts/inspect_eval_uv.py +104 -0
  99. package/bin/skills/hugging-face-evaluation/scripts/inspect_vllm_uv.py +317 -0
  100. package/bin/skills/hugging-face-evaluation/scripts/lighteval_vllm_uv.py +303 -0
  101. package/bin/skills/hugging-face-evaluation/scripts/run_eval_job.py +98 -0
  102. package/bin/skills/hugging-face-evaluation/scripts/run_vllm_eval_job.py +331 -0
  103. package/bin/skills/hugging-face-evaluation/scripts/test_extraction.py +206 -0
  104. package/bin/skills/hugging-face-jobs/SKILL.md +1041 -0
  105. package/bin/skills/hugging-face-jobs/index.html +216 -0
  106. package/bin/skills/hugging-face-jobs/references/hardware_guide.md +336 -0
  107. package/bin/skills/hugging-face-jobs/references/hub_saving.md +352 -0
  108. package/bin/skills/hugging-face-jobs/references/token_usage.md +546 -0
  109. package/bin/skills/hugging-face-jobs/references/troubleshooting.md +475 -0
  110. package/bin/skills/hugging-face-jobs/scripts/cot-self-instruct.py +718 -0
  111. package/bin/skills/hugging-face-jobs/scripts/finepdfs-stats.py +546 -0
  112. package/bin/skills/hugging-face-jobs/scripts/generate-responses.py +587 -0
  113. package/bin/skills/hugging-face-model-trainer/SKILL.md +711 -0
  114. package/bin/skills/hugging-face-model-trainer/references/gguf_conversion.md +296 -0
  115. package/bin/skills/hugging-face-model-trainer/references/hardware_guide.md +283 -0
  116. package/bin/skills/hugging-face-model-trainer/references/hub_saving.md +364 -0
  117. package/bin/skills/hugging-face-model-trainer/references/reliability_principles.md +371 -0
  118. package/bin/skills/hugging-face-model-trainer/references/trackio_guide.md +189 -0
  119. package/bin/skills/hugging-face-model-trainer/references/training_methods.md +150 -0
  120. package/bin/skills/hugging-face-model-trainer/references/training_patterns.md +203 -0
  121. package/bin/skills/hugging-face-model-trainer/references/troubleshooting.md +282 -0
  122. package/bin/skills/hugging-face-model-trainer/scripts/convert_to_gguf.py +424 -0
  123. package/bin/skills/hugging-face-model-trainer/scripts/dataset_inspector.py +417 -0
  124. package/bin/skills/hugging-face-model-trainer/scripts/estimate_cost.py +150 -0
  125. package/bin/skills/hugging-face-model-trainer/scripts/train_dpo_example.py +106 -0
  126. package/bin/skills/hugging-face-model-trainer/scripts/train_grpo_example.py +89 -0
  127. package/bin/skills/hugging-face-model-trainer/scripts/train_sft_example.py +122 -0
  128. package/bin/skills/hugging-face-paper-publisher/SKILL.md +627 -0
  129. package/bin/skills/hugging-face-paper-publisher/examples/example_usage.md +327 -0
  130. package/bin/skills/hugging-face-paper-publisher/references/quick_reference.md +216 -0
  131. package/bin/skills/hugging-face-paper-publisher/scripts/paper_manager.py +508 -0
  132. package/bin/skills/hugging-face-paper-publisher/templates/arxiv.md +299 -0
  133. package/bin/skills/hugging-face-paper-publisher/templates/ml-report.md +358 -0
  134. package/bin/skills/hugging-face-paper-publisher/templates/modern.md +319 -0
  135. package/bin/skills/hugging-face-paper-publisher/templates/standard.md +201 -0
  136. package/bin/skills/hugging-face-tool-builder/SKILL.md +115 -0
  137. package/bin/skills/hugging-face-tool-builder/references/baseline_hf_api.py +57 -0
  138. package/bin/skills/hugging-face-tool-builder/references/baseline_hf_api.sh +40 -0
  139. package/bin/skills/hugging-face-tool-builder/references/baseline_hf_api.tsx +57 -0
  140. package/bin/skills/hugging-face-tool-builder/references/find_models_by_paper.sh +230 -0
  141. package/bin/skills/hugging-face-tool-builder/references/hf_enrich_models.sh +96 -0
  142. package/bin/skills/hugging-face-tool-builder/references/hf_model_card_frontmatter.sh +188 -0
  143. package/bin/skills/hugging-face-tool-builder/references/hf_model_papers_auth.sh +171 -0
  144. package/bin/skills/hugging-face-trackio/SKILL.md +65 -0
  145. package/bin/skills/hugging-face-trackio/references/logging_metrics.md +206 -0
  146. package/bin/skills/hugging-face-trackio/references/retrieving_metrics.md +223 -0
  147. package/bin/skills/huggingface-tokenizers/SKILL.md +516 -0
  148. package/bin/skills/huggingface-tokenizers/references/algorithms.md +653 -0
  149. package/bin/skills/huggingface-tokenizers/references/integration.md +637 -0
  150. package/bin/skills/huggingface-tokenizers/references/pipeline.md +723 -0
  151. package/bin/skills/huggingface-tokenizers/references/training.md +565 -0
  152. package/bin/skills/instructor/SKILL.md +740 -0
  153. package/bin/skills/instructor/references/examples.md +107 -0
  154. package/bin/skills/instructor/references/providers.md +70 -0
  155. package/bin/skills/instructor/references/validation.md +606 -0
  156. package/bin/skills/knowledge-distillation/SKILL.md +458 -0
  157. package/bin/skills/knowledge-distillation/references/minillm.md +334 -0
  158. package/bin/skills/lambda-labs/SKILL.md +545 -0
  159. package/bin/skills/lambda-labs/references/advanced-usage.md +611 -0
  160. package/bin/skills/lambda-labs/references/troubleshooting.md +530 -0
  161. package/bin/skills/langchain/SKILL.md +480 -0
  162. package/bin/skills/langchain/references/agents.md +499 -0
  163. package/bin/skills/langchain/references/integration.md +562 -0
  164. package/bin/skills/langchain/references/rag.md +600 -0
  165. package/bin/skills/langsmith/SKILL.md +422 -0
  166. package/bin/skills/langsmith/references/advanced-usage.md +548 -0
  167. package/bin/skills/langsmith/references/troubleshooting.md +537 -0
  168. package/bin/skills/litgpt/SKILL.md +469 -0
  169. package/bin/skills/litgpt/references/custom-models.md +568 -0
  170. package/bin/skills/litgpt/references/distributed-training.md +451 -0
  171. package/bin/skills/litgpt/references/supported-models.md +336 -0
  172. package/bin/skills/litgpt/references/training-recipes.md +619 -0
  173. package/bin/skills/llama-cpp/SKILL.md +258 -0
  174. package/bin/skills/llama-cpp/references/optimization.md +89 -0
  175. package/bin/skills/llama-cpp/references/quantization.md +213 -0
  176. package/bin/skills/llama-cpp/references/server.md +125 -0
  177. package/bin/skills/llama-factory/SKILL.md +80 -0
  178. package/bin/skills/llama-factory/references/_images.md +23 -0
  179. package/bin/skills/llama-factory/references/advanced.md +1055 -0
  180. package/bin/skills/llama-factory/references/getting_started.md +349 -0
  181. package/bin/skills/llama-factory/references/index.md +19 -0
  182. package/bin/skills/llama-factory/references/other.md +31 -0
  183. package/bin/skills/llamaguard/SKILL.md +337 -0
  184. package/bin/skills/llamaindex/SKILL.md +569 -0
  185. package/bin/skills/llamaindex/references/agents.md +83 -0
  186. package/bin/skills/llamaindex/references/data_connectors.md +108 -0
  187. package/bin/skills/llamaindex/references/query_engines.md +406 -0
  188. package/bin/skills/llava/SKILL.md +304 -0
  189. package/bin/skills/llava/references/training.md +197 -0
  190. package/bin/skills/lm-evaluation-harness/SKILL.md +490 -0
  191. package/bin/skills/lm-evaluation-harness/references/api-evaluation.md +490 -0
  192. package/bin/skills/lm-evaluation-harness/references/benchmark-guide.md +488 -0
  193. package/bin/skills/lm-evaluation-harness/references/custom-tasks.md +602 -0
  194. package/bin/skills/lm-evaluation-harness/references/distributed-eval.md +519 -0
  195. package/bin/skills/long-context/SKILL.md +536 -0
  196. package/bin/skills/long-context/references/extension_methods.md +468 -0
  197. package/bin/skills/long-context/references/fine_tuning.md +611 -0
  198. package/bin/skills/long-context/references/rope.md +402 -0
  199. package/bin/skills/mamba/SKILL.md +260 -0
  200. package/bin/skills/mamba/references/architecture-details.md +206 -0
  201. package/bin/skills/mamba/references/benchmarks.md +255 -0
  202. package/bin/skills/mamba/references/training-guide.md +388 -0
  203. package/bin/skills/megatron-core/SKILL.md +366 -0
  204. package/bin/skills/megatron-core/references/benchmarks.md +249 -0
  205. package/bin/skills/megatron-core/references/parallelism-guide.md +404 -0
  206. package/bin/skills/megatron-core/references/production-examples.md +473 -0
  207. package/bin/skills/megatron-core/references/training-recipes.md +547 -0
  208. package/bin/skills/miles/SKILL.md +315 -0
  209. package/bin/skills/miles/references/api-reference.md +141 -0
  210. package/bin/skills/miles/references/troubleshooting.md +352 -0
  211. package/bin/skills/mlflow/SKILL.md +704 -0
  212. package/bin/skills/mlflow/references/deployment.md +744 -0
  213. package/bin/skills/mlflow/references/model-registry.md +770 -0
  214. package/bin/skills/mlflow/references/tracking.md +680 -0
  215. package/bin/skills/modal/SKILL.md +341 -0
  216. package/bin/skills/modal/references/advanced-usage.md +503 -0
  217. package/bin/skills/modal/references/troubleshooting.md +494 -0
  218. package/bin/skills/model-merging/SKILL.md +539 -0
  219. package/bin/skills/model-merging/references/evaluation.md +462 -0
  220. package/bin/skills/model-merging/references/examples.md +428 -0
  221. package/bin/skills/model-merging/references/methods.md +352 -0
  222. package/bin/skills/model-pruning/SKILL.md +495 -0
  223. package/bin/skills/model-pruning/references/wanda.md +347 -0
  224. package/bin/skills/moe-training/SKILL.md +526 -0
  225. package/bin/skills/moe-training/references/architectures.md +432 -0
  226. package/bin/skills/moe-training/references/inference.md +348 -0
  227. package/bin/skills/moe-training/references/training.md +425 -0
  228. package/bin/skills/nanogpt/SKILL.md +290 -0
  229. package/bin/skills/nanogpt/references/architecture.md +382 -0
  230. package/bin/skills/nanogpt/references/data.md +476 -0
  231. package/bin/skills/nanogpt/references/training.md +564 -0
  232. package/bin/skills/nemo-curator/SKILL.md +383 -0
  233. package/bin/skills/nemo-curator/references/deduplication.md +87 -0
  234. package/bin/skills/nemo-curator/references/filtering.md +102 -0
  235. package/bin/skills/nemo-evaluator/SKILL.md +494 -0
  236. package/bin/skills/nemo-evaluator/references/adapter-system.md +340 -0
  237. package/bin/skills/nemo-evaluator/references/configuration.md +447 -0
  238. package/bin/skills/nemo-evaluator/references/custom-benchmarks.md +315 -0
  239. package/bin/skills/nemo-evaluator/references/execution-backends.md +361 -0
  240. package/bin/skills/nemo-guardrails/SKILL.md +297 -0
  241. package/bin/skills/nnsight/SKILL.md +436 -0
  242. package/bin/skills/nnsight/references/README.md +78 -0
  243. package/bin/skills/nnsight/references/api.md +344 -0
  244. package/bin/skills/nnsight/references/tutorials.md +300 -0
  245. package/bin/skills/openrlhf/SKILL.md +249 -0
  246. package/bin/skills/openrlhf/references/algorithm-comparison.md +404 -0
  247. package/bin/skills/openrlhf/references/custom-rewards.md +530 -0
  248. package/bin/skills/openrlhf/references/hybrid-engine.md +287 -0
  249. package/bin/skills/openrlhf/references/multi-node-training.md +454 -0
  250. package/bin/skills/outlines/SKILL.md +652 -0
  251. package/bin/skills/outlines/references/backends.md +615 -0
  252. package/bin/skills/outlines/references/examples.md +773 -0
  253. package/bin/skills/outlines/references/json_generation.md +652 -0
  254. package/bin/skills/peft/SKILL.md +431 -0
  255. package/bin/skills/peft/references/advanced-usage.md +514 -0
  256. package/bin/skills/peft/references/troubleshooting.md +480 -0
  257. package/bin/skills/phoenix/SKILL.md +475 -0
  258. package/bin/skills/phoenix/references/advanced-usage.md +619 -0
  259. package/bin/skills/phoenix/references/troubleshooting.md +538 -0
  260. package/bin/skills/pinecone/SKILL.md +358 -0
  261. package/bin/skills/pinecone/references/deployment.md +181 -0
  262. package/bin/skills/pytorch-fsdp/SKILL.md +126 -0
  263. package/bin/skills/pytorch-fsdp/references/index.md +7 -0
  264. package/bin/skills/pytorch-fsdp/references/other.md +4249 -0
  265. package/bin/skills/pytorch-lightning/SKILL.md +346 -0
  266. package/bin/skills/pytorch-lightning/references/callbacks.md +436 -0
  267. package/bin/skills/pytorch-lightning/references/distributed.md +490 -0
  268. package/bin/skills/pytorch-lightning/references/hyperparameter-tuning.md +556 -0
  269. package/bin/skills/pyvene/SKILL.md +473 -0
  270. package/bin/skills/pyvene/references/README.md +73 -0
  271. package/bin/skills/pyvene/references/api.md +383 -0
  272. package/bin/skills/pyvene/references/tutorials.md +376 -0
  273. package/bin/skills/qdrant/SKILL.md +493 -0
  274. package/bin/skills/qdrant/references/advanced-usage.md +648 -0
  275. package/bin/skills/qdrant/references/troubleshooting.md +631 -0
  276. package/bin/skills/ray-data/SKILL.md +326 -0
  277. package/bin/skills/ray-data/references/integration.md +82 -0
  278. package/bin/skills/ray-data/references/transformations.md +83 -0
  279. package/bin/skills/ray-train/SKILL.md +406 -0
  280. package/bin/skills/ray-train/references/multi-node.md +628 -0
  281. package/bin/skills/rwkv/SKILL.md +260 -0
  282. package/bin/skills/rwkv/references/architecture-details.md +344 -0
  283. package/bin/skills/rwkv/references/rwkv7.md +386 -0
  284. package/bin/skills/rwkv/references/state-management.md +369 -0
  285. package/bin/skills/saelens/SKILL.md +386 -0
  286. package/bin/skills/saelens/references/README.md +70 -0
  287. package/bin/skills/saelens/references/api.md +333 -0
  288. package/bin/skills/saelens/references/tutorials.md +318 -0
  289. package/bin/skills/segment-anything/SKILL.md +500 -0
  290. package/bin/skills/segment-anything/references/advanced-usage.md +589 -0
  291. package/bin/skills/segment-anything/references/troubleshooting.md +484 -0
  292. package/bin/skills/sentence-transformers/SKILL.md +255 -0
  293. package/bin/skills/sentence-transformers/references/models.md +123 -0
  294. package/bin/skills/sentencepiece/SKILL.md +235 -0
  295. package/bin/skills/sentencepiece/references/algorithms.md +200 -0
  296. package/bin/skills/sentencepiece/references/training.md +304 -0
  297. package/bin/skills/sglang/SKILL.md +442 -0
  298. package/bin/skills/sglang/references/deployment.md +490 -0
  299. package/bin/skills/sglang/references/radix-attention.md +413 -0
  300. package/bin/skills/sglang/references/structured-generation.md +541 -0
  301. package/bin/skills/simpo/SKILL.md +219 -0
  302. package/bin/skills/simpo/references/datasets.md +478 -0
  303. package/bin/skills/simpo/references/hyperparameters.md +452 -0
  304. package/bin/skills/simpo/references/loss-functions.md +350 -0
  305. package/bin/skills/skypilot/SKILL.md +509 -0
  306. package/bin/skills/skypilot/references/advanced-usage.md +491 -0
  307. package/bin/skills/skypilot/references/troubleshooting.md +570 -0
  308. package/bin/skills/slime/SKILL.md +464 -0
  309. package/bin/skills/slime/references/api-reference.md +392 -0
  310. package/bin/skills/slime/references/troubleshooting.md +386 -0
  311. package/bin/skills/speculative-decoding/SKILL.md +467 -0
  312. package/bin/skills/speculative-decoding/references/lookahead.md +309 -0
  313. package/bin/skills/speculative-decoding/references/medusa.md +350 -0
  314. package/bin/skills/stable-diffusion/SKILL.md +519 -0
  315. package/bin/skills/stable-diffusion/references/advanced-usage.md +716 -0
  316. package/bin/skills/stable-diffusion/references/troubleshooting.md +555 -0
  317. package/bin/skills/tensorboard/SKILL.md +629 -0
  318. package/bin/skills/tensorboard/references/integrations.md +638 -0
  319. package/bin/skills/tensorboard/references/profiling.md +545 -0
  320. package/bin/skills/tensorboard/references/visualization.md +620 -0
  321. package/bin/skills/tensorrt-llm/SKILL.md +187 -0
  322. package/bin/skills/tensorrt-llm/references/multi-gpu.md +298 -0
  323. package/bin/skills/tensorrt-llm/references/optimization.md +242 -0
  324. package/bin/skills/tensorrt-llm/references/serving.md +470 -0
  325. package/bin/skills/tinker/SKILL.md +362 -0
  326. package/bin/skills/tinker/references/api-reference.md +168 -0
  327. package/bin/skills/tinker/references/getting-started.md +157 -0
  328. package/bin/skills/tinker/references/loss-functions.md +163 -0
  329. package/bin/skills/tinker/references/models-and-lora.md +139 -0
  330. package/bin/skills/tinker/references/recipes.md +280 -0
  331. package/bin/skills/tinker/references/reinforcement-learning.md +212 -0
  332. package/bin/skills/tinker/references/rendering.md +243 -0
  333. package/bin/skills/tinker/references/supervised-learning.md +232 -0
  334. package/bin/skills/tinker-training-cost/SKILL.md +187 -0
  335. package/bin/skills/tinker-training-cost/scripts/calculate_cost.py +123 -0
  336. package/bin/skills/torchforge/SKILL.md +433 -0
  337. package/bin/skills/torchforge/references/api-reference.md +327 -0
  338. package/bin/skills/torchforge/references/troubleshooting.md +409 -0
  339. package/bin/skills/torchtitan/SKILL.md +358 -0
  340. package/bin/skills/torchtitan/references/checkpoint.md +181 -0
  341. package/bin/skills/torchtitan/references/custom-models.md +258 -0
  342. package/bin/skills/torchtitan/references/float8.md +133 -0
  343. package/bin/skills/torchtitan/references/fsdp.md +126 -0
  344. package/bin/skills/transformer-lens/SKILL.md +346 -0
  345. package/bin/skills/transformer-lens/references/README.md +54 -0
  346. package/bin/skills/transformer-lens/references/api.md +362 -0
  347. package/bin/skills/transformer-lens/references/tutorials.md +339 -0
  348. package/bin/skills/trl-fine-tuning/SKILL.md +455 -0
  349. package/bin/skills/trl-fine-tuning/references/dpo-variants.md +227 -0
  350. package/bin/skills/trl-fine-tuning/references/online-rl.md +82 -0
  351. package/bin/skills/trl-fine-tuning/references/reward-modeling.md +122 -0
  352. package/bin/skills/trl-fine-tuning/references/sft-training.md +168 -0
  353. package/bin/skills/unsloth/SKILL.md +80 -0
  354. package/bin/skills/unsloth/references/index.md +7 -0
  355. package/bin/skills/unsloth/references/llms-full.md +16799 -0
  356. package/bin/skills/unsloth/references/llms-txt.md +12044 -0
  357. package/bin/skills/unsloth/references/llms.md +82 -0
  358. package/bin/skills/verl/SKILL.md +391 -0
  359. package/bin/skills/verl/references/api-reference.md +301 -0
  360. package/bin/skills/verl/references/troubleshooting.md +391 -0
  361. package/bin/skills/vllm/SKILL.md +364 -0
  362. package/bin/skills/vllm/references/optimization.md +226 -0
  363. package/bin/skills/vllm/references/quantization.md +284 -0
  364. package/bin/skills/vllm/references/server-deployment.md +255 -0
  365. package/bin/skills/vllm/references/troubleshooting.md +447 -0
  366. package/bin/skills/weights-and-biases/SKILL.md +590 -0
  367. package/bin/skills/weights-and-biases/references/artifacts.md +584 -0
  368. package/bin/skills/weights-and-biases/references/integrations.md +700 -0
  369. package/bin/skills/weights-and-biases/references/sweeps.md +847 -0
  370. package/bin/skills/whisper/SKILL.md +317 -0
  371. package/bin/skills/whisper/references/languages.md +189 -0
  372. package/bin/synsc +0 -0
  373. package/package.json +10 -0
@@ -0,0 +1,716 @@
1
+ # Stable Diffusion Advanced Usage Guide
2
+
3
+ ## Custom Pipelines
4
+
5
+ ### Building from components
6
+
7
+ ```python
8
+ from diffusers import (
9
+ UNet2DConditionModel,
10
+ AutoencoderKL,
11
+ DDPMScheduler,
12
+ StableDiffusionPipeline
13
+ )
14
+ from transformers import CLIPTextModel, CLIPTokenizer
15
+ import torch
16
+
17
+ # Load components individually
18
+ unet = UNet2DConditionModel.from_pretrained(
19
+ "stable-diffusion-v1-5/stable-diffusion-v1-5",
20
+ subfolder="unet"
21
+ )
22
+ vae = AutoencoderKL.from_pretrained(
23
+ "stable-diffusion-v1-5/stable-diffusion-v1-5",
24
+ subfolder="vae"
25
+ )
26
+ text_encoder = CLIPTextModel.from_pretrained(
27
+ "stable-diffusion-v1-5/stable-diffusion-v1-5",
28
+ subfolder="text_encoder"
29
+ )
30
+ tokenizer = CLIPTokenizer.from_pretrained(
31
+ "stable-diffusion-v1-5/stable-diffusion-v1-5",
32
+ subfolder="tokenizer"
33
+ )
34
+ scheduler = DDPMScheduler.from_pretrained(
35
+ "stable-diffusion-v1-5/stable-diffusion-v1-5",
36
+ subfolder="scheduler"
37
+ )
38
+
39
+ # Assemble pipeline
40
+ pipe = StableDiffusionPipeline(
41
+ unet=unet,
42
+ vae=vae,
43
+ text_encoder=text_encoder,
44
+ tokenizer=tokenizer,
45
+ scheduler=scheduler,
46
+ safety_checker=None,
47
+ feature_extractor=None,
48
+ requires_safety_checker=False
49
+ )
50
+ ```
51
+
52
+ ### Custom denoising loop
53
+
54
+ ```python
55
+ from diffusers import DDIMScheduler, AutoencoderKL, UNet2DConditionModel
56
+ from transformers import CLIPTextModel, CLIPTokenizer
57
+ import torch
58
+
59
+ def custom_generate(
60
+ prompt: str,
61
+ num_steps: int = 50,
62
+ guidance_scale: float = 7.5,
63
+ height: int = 512,
64
+ width: int = 512
65
+ ):
66
+ # Load components
67
+ tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-large-patch14")
68
+ text_encoder = CLIPTextModel.from_pretrained("openai/clip-vit-large-patch14")
69
+ unet = UNet2DConditionModel.from_pretrained("sd-model", subfolder="unet")
70
+ vae = AutoencoderKL.from_pretrained("sd-model", subfolder="vae")
71
+ scheduler = DDIMScheduler.from_pretrained("sd-model", subfolder="scheduler")
72
+
73
+ device = "cuda"
74
+ text_encoder.to(device)
75
+ unet.to(device)
76
+ vae.to(device)
77
+
78
+ # Encode prompt
79
+ text_input = tokenizer(
80
+ prompt,
81
+ padding="max_length",
82
+ max_length=77,
83
+ truncation=True,
84
+ return_tensors="pt"
85
+ )
86
+ text_embeddings = text_encoder(text_input.input_ids.to(device))[0]
87
+
88
+ # Unconditional embeddings for classifier-free guidance
89
+ uncond_input = tokenizer(
90
+ "",
91
+ padding="max_length",
92
+ max_length=77,
93
+ return_tensors="pt"
94
+ )
95
+ uncond_embeddings = text_encoder(uncond_input.input_ids.to(device))[0]
96
+
97
+ # Concatenate for batch processing
98
+ text_embeddings = torch.cat([uncond_embeddings, text_embeddings])
99
+
100
+ # Initialize latents
101
+ latents = torch.randn(
102
+ (1, 4, height // 8, width // 8),
103
+ device=device
104
+ )
105
+ latents = latents * scheduler.init_noise_sigma
106
+
107
+ # Denoising loop
108
+ scheduler.set_timesteps(num_steps)
109
+ for t in scheduler.timesteps:
110
+ latent_model_input = torch.cat([latents] * 2)
111
+ latent_model_input = scheduler.scale_model_input(latent_model_input, t)
112
+
113
+ # Predict noise
114
+ with torch.no_grad():
115
+ noise_pred = unet(
116
+ latent_model_input,
117
+ t,
118
+ encoder_hidden_states=text_embeddings
119
+ ).sample
120
+
121
+ # Classifier-free guidance
122
+ noise_pred_uncond, noise_pred_cond = noise_pred.chunk(2)
123
+ noise_pred = noise_pred_uncond + guidance_scale * (
124
+ noise_pred_cond - noise_pred_uncond
125
+ )
126
+
127
+ # Update latents
128
+ latents = scheduler.step(noise_pred, t, latents).prev_sample
129
+
130
+ # Decode latents
131
+ latents = latents / vae.config.scaling_factor
132
+ with torch.no_grad():
133
+ image = vae.decode(latents).sample
134
+
135
+ # Convert to PIL
136
+ image = (image / 2 + 0.5).clamp(0, 1)
137
+ image = image.cpu().permute(0, 2, 3, 1).numpy()
138
+ image = (image * 255).round().astype("uint8")[0]
139
+
140
+ return Image.fromarray(image)
141
+ ```
142
+
143
+ ## IP-Adapter
144
+
145
+ Use image prompts alongside text:
146
+
147
+ ```python
148
+ from diffusers import StableDiffusionPipeline
149
+ from diffusers.utils import load_image
150
+ import torch
151
+
152
+ pipe = StableDiffusionPipeline.from_pretrained(
153
+ "stable-diffusion-v1-5/stable-diffusion-v1-5",
154
+ torch_dtype=torch.float16
155
+ ).to("cuda")
156
+
157
+ # Load IP-Adapter
158
+ pipe.load_ip_adapter(
159
+ "h94/IP-Adapter",
160
+ subfolder="models",
161
+ weight_name="ip-adapter_sd15.bin"
162
+ )
163
+
164
+ # Set IP-Adapter scale
165
+ pipe.set_ip_adapter_scale(0.6)
166
+
167
+ # Load reference image
168
+ ip_image = load_image("reference_style.jpg")
169
+
170
+ # Generate with image + text prompt
171
+ image = pipe(
172
+ prompt="A portrait in a garden",
173
+ ip_adapter_image=ip_image,
174
+ num_inference_steps=50
175
+ ).images[0]
176
+ ```
177
+
178
+ ### Multiple IP-Adapter images
179
+
180
+ ```python
181
+ # Use multiple reference images
182
+ pipe.set_ip_adapter_scale([0.5, 0.7])
183
+
184
+ images = [
185
+ load_image("style_reference.jpg"),
186
+ load_image("composition_reference.jpg")
187
+ ]
188
+
189
+ result = pipe(
190
+ prompt="A landscape painting",
191
+ ip_adapter_image=images,
192
+ num_inference_steps=50
193
+ ).images[0]
194
+ ```
195
+
196
+ ## SDXL Refiner
197
+
198
+ Two-stage generation for higher quality:
199
+
200
+ ```python
201
+ from diffusers import StableDiffusionXLPipeline, StableDiffusionXLImg2ImgPipeline
202
+ import torch
203
+
204
+ # Load base model
205
+ base = StableDiffusionXLPipeline.from_pretrained(
206
+ "stabilityai/stable-diffusion-xl-base-1.0",
207
+ torch_dtype=torch.float16,
208
+ variant="fp16"
209
+ ).to("cuda")
210
+
211
+ # Load refiner
212
+ refiner = StableDiffusionXLImg2ImgPipeline.from_pretrained(
213
+ "stabilityai/stable-diffusion-xl-refiner-1.0",
214
+ torch_dtype=torch.float16,
215
+ variant="fp16"
216
+ ).to("cuda")
217
+
218
+ # Generate with base (partial denoising)
219
+ image = base(
220
+ prompt="A majestic eagle soaring over mountains",
221
+ num_inference_steps=40,
222
+ denoising_end=0.8,
223
+ output_type="latent"
224
+ ).images
225
+
226
+ # Refine with refiner
227
+ refined = refiner(
228
+ prompt="A majestic eagle soaring over mountains",
229
+ image=image,
230
+ num_inference_steps=40,
231
+ denoising_start=0.8
232
+ ).images[0]
233
+ ```
234
+
235
+ ## T2I-Adapter
236
+
237
+ Lightweight conditioning without full ControlNet:
238
+
239
+ ```python
240
+ from diffusers import StableDiffusionXLAdapterPipeline, T2IAdapter
241
+ import torch
242
+
243
+ # Load adapter
244
+ adapter = T2IAdapter.from_pretrained(
245
+ "TencentARC/t2i-adapter-canny-sdxl-1.0",
246
+ torch_dtype=torch.float16
247
+ )
248
+
249
+ pipe = StableDiffusionXLAdapterPipeline.from_pretrained(
250
+ "stabilityai/stable-diffusion-xl-base-1.0",
251
+ adapter=adapter,
252
+ torch_dtype=torch.float16
253
+ ).to("cuda")
254
+
255
+ # Get canny edges
256
+ canny_image = get_canny_image(input_image)
257
+
258
+ image = pipe(
259
+ prompt="A colorful anime character",
260
+ image=canny_image,
261
+ num_inference_steps=30,
262
+ adapter_conditioning_scale=0.8
263
+ ).images[0]
264
+ ```
265
+
266
+ ## Fine-tuning with DreamBooth
267
+
268
+ Train on custom subjects:
269
+
270
+ ```python
271
+ from diffusers import StableDiffusionPipeline, DDPMScheduler
272
+ from diffusers.optimization import get_scheduler
273
+ import torch
274
+ from torch.utils.data import Dataset, DataLoader
275
+ from PIL import Image
276
+ import os
277
+
278
+ class DreamBoothDataset(Dataset):
279
+ def __init__(self, instance_images_path, instance_prompt, tokenizer, size=512):
280
+ self.instance_images_path = instance_images_path
281
+ self.instance_prompt = instance_prompt
282
+ self.tokenizer = tokenizer
283
+ self.size = size
284
+
285
+ self.instance_images = [
286
+ os.path.join(instance_images_path, f)
287
+ for f in os.listdir(instance_images_path)
288
+ if f.endswith(('.png', '.jpg', '.jpeg'))
289
+ ]
290
+
291
+ def __len__(self):
292
+ return len(self.instance_images)
293
+
294
+ def __getitem__(self, idx):
295
+ image = Image.open(self.instance_images[idx]).convert("RGB")
296
+ image = image.resize((self.size, self.size))
297
+ image = torch.tensor(np.array(image)).permute(2, 0, 1) / 127.5 - 1.0
298
+
299
+ tokens = self.tokenizer(
300
+ self.instance_prompt,
301
+ padding="max_length",
302
+ max_length=77,
303
+ truncation=True,
304
+ return_tensors="pt"
305
+ )
306
+
307
+ return {"image": image, "input_ids": tokens.input_ids.squeeze()}
308
+
309
+ def train_dreambooth(
310
+ pretrained_model: str,
311
+ instance_data_dir: str,
312
+ instance_prompt: str,
313
+ output_dir: str,
314
+ learning_rate: float = 5e-6,
315
+ max_train_steps: int = 800,
316
+ train_batch_size: int = 1
317
+ ):
318
+ # Load pipeline
319
+ pipe = StableDiffusionPipeline.from_pretrained(pretrained_model)
320
+
321
+ unet = pipe.unet
322
+ vae = pipe.vae
323
+ text_encoder = pipe.text_encoder
324
+ tokenizer = pipe.tokenizer
325
+ noise_scheduler = DDPMScheduler.from_pretrained(pretrained_model, subfolder="scheduler")
326
+
327
+ # Freeze VAE and text encoder
328
+ vae.requires_grad_(False)
329
+ text_encoder.requires_grad_(False)
330
+
331
+ # Create dataset
332
+ dataset = DreamBoothDataset(
333
+ instance_data_dir, instance_prompt, tokenizer
334
+ )
335
+ dataloader = DataLoader(dataset, batch_size=train_batch_size, shuffle=True)
336
+
337
+ # Setup optimizer
338
+ optimizer = torch.optim.AdamW(unet.parameters(), lr=learning_rate)
339
+ lr_scheduler = get_scheduler(
340
+ "constant",
341
+ optimizer=optimizer,
342
+ num_warmup_steps=0,
343
+ num_training_steps=max_train_steps
344
+ )
345
+
346
+ # Training loop
347
+ unet.train()
348
+ device = "cuda"
349
+ unet.to(device)
350
+ vae.to(device)
351
+ text_encoder.to(device)
352
+
353
+ global_step = 0
354
+ for epoch in range(max_train_steps // len(dataloader) + 1):
355
+ for batch in dataloader:
356
+ if global_step >= max_train_steps:
357
+ break
358
+
359
+ # Encode images to latents
360
+ latents = vae.encode(batch["image"].to(device)).latent_dist.sample()
361
+ latents = latents * vae.config.scaling_factor
362
+
363
+ # Sample noise
364
+ noise = torch.randn_like(latents)
365
+ timesteps = torch.randint(0, noise_scheduler.num_train_timesteps, (latents.shape[0],))
366
+ timesteps = timesteps.to(device)
367
+
368
+ # Add noise
369
+ noisy_latents = noise_scheduler.add_noise(latents, noise, timesteps)
370
+
371
+ # Get text embeddings
372
+ encoder_hidden_states = text_encoder(batch["input_ids"].to(device))[0]
373
+
374
+ # Predict noise
375
+ noise_pred = unet(noisy_latents, timesteps, encoder_hidden_states).sample
376
+
377
+ # Compute loss
378
+ loss = torch.nn.functional.mse_loss(noise_pred, noise)
379
+
380
+ # Backprop
381
+ loss.backward()
382
+ optimizer.step()
383
+ lr_scheduler.step()
384
+ optimizer.zero_grad()
385
+
386
+ global_step += 1
387
+
388
+ if global_step % 100 == 0:
389
+ print(f"Step {global_step}, Loss: {loss.item():.4f}")
390
+
391
+ # Save model
392
+ pipe.unet = unet
393
+ pipe.save_pretrained(output_dir)
394
+ ```
395
+
396
+ ## LoRA Training
397
+
398
+ Efficient fine-tuning with Low-Rank Adaptation:
399
+
400
+ ```python
401
+ from peft import LoraConfig, get_peft_model
402
+ from diffusers import StableDiffusionPipeline
403
+ import torch
404
+
405
+ def train_lora(
406
+ base_model: str,
407
+ train_dataset,
408
+ output_dir: str,
409
+ lora_rank: int = 4,
410
+ learning_rate: float = 1e-4,
411
+ max_train_steps: int = 1000
412
+ ):
413
+ pipe = StableDiffusionPipeline.from_pretrained(base_model)
414
+ unet = pipe.unet
415
+
416
+ # Configure LoRA
417
+ lora_config = LoraConfig(
418
+ r=lora_rank,
419
+ lora_alpha=lora_rank,
420
+ target_modules=["to_q", "to_v", "to_k", "to_out.0"],
421
+ lora_dropout=0.1
422
+ )
423
+
424
+ # Apply LoRA to UNet
425
+ unet = get_peft_model(unet, lora_config)
426
+ unet.print_trainable_parameters() # Shows ~0.1% trainable
427
+
428
+ # Train (similar to DreamBooth but only LoRA params)
429
+ optimizer = torch.optim.AdamW(
430
+ unet.parameters(),
431
+ lr=learning_rate
432
+ )
433
+
434
+ # ... training loop ...
435
+
436
+ # Save LoRA weights only
437
+ unet.save_pretrained(output_dir)
438
+ ```
439
+
440
+ ## Textual Inversion
441
+
442
+ Learn new concepts through embeddings:
443
+
444
+ ```python
445
+ from diffusers import StableDiffusionPipeline
446
+ import torch
447
+
448
+ # Load with textual inversion
449
+ pipe = StableDiffusionPipeline.from_pretrained(
450
+ "stable-diffusion-v1-5/stable-diffusion-v1-5",
451
+ torch_dtype=torch.float16
452
+ ).to("cuda")
453
+
454
+ # Load learned embedding
455
+ pipe.load_textual_inversion(
456
+ "sd-concepts-library/cat-toy",
457
+ token="<cat-toy>"
458
+ )
459
+
460
+ # Use in prompts
461
+ image = pipe("A photo of <cat-toy> on a beach").images[0]
462
+ ```
463
+
464
+ ## Quantization
465
+
466
+ Reduce memory with quantization:
467
+
468
+ ```python
469
+ from diffusers import BitsAndBytesConfig, StableDiffusionXLPipeline
470
+ import torch
471
+
472
+ # 8-bit quantization
473
+ quantization_config = BitsAndBytesConfig(load_in_8bit=True)
474
+
475
+ pipe = StableDiffusionXLPipeline.from_pretrained(
476
+ "stabilityai/stable-diffusion-xl-base-1.0",
477
+ quantization_config=quantization_config,
478
+ torch_dtype=torch.float16
479
+ )
480
+ ```
481
+
482
+ ### NF4 quantization (4-bit)
483
+
484
+ ```python
485
+ quantization_config = BitsAndBytesConfig(
486
+ load_in_4bit=True,
487
+ bnb_4bit_quant_type="nf4",
488
+ bnb_4bit_compute_dtype=torch.float16
489
+ )
490
+
491
+ pipe = StableDiffusionXLPipeline.from_pretrained(
492
+ "stabilityai/stable-diffusion-xl-base-1.0",
493
+ quantization_config=quantization_config
494
+ )
495
+ ```
496
+
497
+ ## Production Deployment
498
+
499
+ ### FastAPI server
500
+
501
+ ```python
502
+ from fastapi import FastAPI, HTTPException
503
+ from pydantic import BaseModel
504
+ from diffusers import DiffusionPipeline
505
+ import torch
506
+ import base64
507
+ from io import BytesIO
508
+
509
+ app = FastAPI()
510
+
511
+ # Load model at startup
512
+ pipe = DiffusionPipeline.from_pretrained(
513
+ "stable-diffusion-v1-5/stable-diffusion-v1-5",
514
+ torch_dtype=torch.float16
515
+ ).to("cuda")
516
+ pipe.enable_model_cpu_offload()
517
+
518
+ class GenerationRequest(BaseModel):
519
+ prompt: str
520
+ negative_prompt: str = ""
521
+ num_inference_steps: int = 30
522
+ guidance_scale: float = 7.5
523
+ width: int = 512
524
+ height: int = 512
525
+ seed: int = None
526
+
527
+ class GenerationResponse(BaseModel):
528
+ image_base64: str
529
+ seed: int
530
+
531
+ @app.post("/generate", response_model=GenerationResponse)
532
+ async def generate(request: GenerationRequest):
533
+ try:
534
+ generator = None
535
+ seed = request.seed or torch.randint(0, 2**32, (1,)).item()
536
+ generator = torch.Generator("cuda").manual_seed(seed)
537
+
538
+ image = pipe(
539
+ prompt=request.prompt,
540
+ negative_prompt=request.negative_prompt,
541
+ num_inference_steps=request.num_inference_steps,
542
+ guidance_scale=request.guidance_scale,
543
+ width=request.width,
544
+ height=request.height,
545
+ generator=generator
546
+ ).images[0]
547
+
548
+ # Convert to base64
549
+ buffer = BytesIO()
550
+ image.save(buffer, format="PNG")
551
+ image_base64 = base64.b64encode(buffer.getvalue()).decode()
552
+
553
+ return GenerationResponse(image_base64=image_base64, seed=seed)
554
+
555
+ except Exception as e:
556
+ raise HTTPException(status_code=500, detail=str(e))
557
+
558
+ @app.get("/health")
559
+ async def health():
560
+ return {"status": "healthy"}
561
+ ```
562
+
563
+ ### Docker deployment
564
+
565
+ ```dockerfile
566
+ FROM nvidia/cuda:12.1-runtime-ubuntu22.04
567
+
568
+ RUN apt-get update && apt-get install -y python3 python3-pip
569
+
570
+ WORKDIR /app
571
+
572
+ COPY requirements.txt .
573
+ RUN pip3 install -r requirements.txt
574
+
575
+ COPY . .
576
+
577
+ # Pre-download model
578
+ RUN python3 -c "from diffusers import DiffusionPipeline; DiffusionPipeline.from_pretrained('stable-diffusion-v1-5/stable-diffusion-v1-5')"
579
+
580
+ EXPOSE 8000
581
+ CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"]
582
+ ```
583
+
584
+ ### Kubernetes deployment
585
+
586
+ ```yaml
587
+ apiVersion: apps/v1
588
+ kind: Deployment
589
+ metadata:
590
+ name: stable-diffusion
591
+ spec:
592
+ replicas: 2
593
+ selector:
594
+ matchLabels:
595
+ app: stable-diffusion
596
+ template:
597
+ metadata:
598
+ labels:
599
+ app: stable-diffusion
600
+ spec:
601
+ containers:
602
+ - name: sd
603
+ image: your-registry/stable-diffusion:latest
604
+ ports:
605
+ - containerPort: 8000
606
+ resources:
607
+ limits:
608
+ nvidia.com/gpu: 1
609
+ memory: "16Gi"
610
+ requests:
611
+ nvidia.com/gpu: 1
612
+ memory: "8Gi"
613
+ env:
614
+ - name: TRANSFORMERS_CACHE
615
+ value: "/cache/huggingface"
616
+ volumeMounts:
617
+ - name: model-cache
618
+ mountPath: /cache
619
+ volumes:
620
+ - name: model-cache
621
+ persistentVolumeClaim:
622
+ claimName: model-cache-pvc
623
+ ---
624
+ apiVersion: v1
625
+ kind: Service
626
+ metadata:
627
+ name: stable-diffusion
628
+ spec:
629
+ selector:
630
+ app: stable-diffusion
631
+ ports:
632
+ - port: 80
633
+ targetPort: 8000
634
+ type: LoadBalancer
635
+ ```
636
+
637
+ ## Callback System
638
+
639
+ Monitor and modify generation:
640
+
641
+ ```python
642
+ from diffusers import StableDiffusionPipeline
643
+ from diffusers.callbacks import PipelineCallback
644
+ import torch
645
+
646
+ class ProgressCallback(PipelineCallback):
647
+ def __init__(self):
648
+ self.progress = []
649
+
650
+ def callback_fn(self, pipe, step_index, timestep, callback_kwargs):
651
+ self.progress.append({
652
+ "step": step_index,
653
+ "timestep": timestep.item()
654
+ })
655
+
656
+ # Optionally modify latents
657
+ latents = callback_kwargs["latents"]
658
+
659
+ return callback_kwargs
660
+
661
+ # Use callback
662
+ callback = ProgressCallback()
663
+
664
+ image = pipe(
665
+ prompt="A sunset",
666
+ callback_on_step_end=callback.callback_fn,
667
+ callback_on_step_end_tensor_inputs=["latents"]
668
+ ).images[0]
669
+
670
+ print(f"Generation completed in {len(callback.progress)} steps")
671
+ ```
672
+
673
+ ### Early stopping
674
+
675
+ ```python
676
+ def early_stop_callback(pipe, step_index, timestep, callback_kwargs):
677
+ # Stop after 20 steps
678
+ if step_index >= 20:
679
+ pipe._interrupt = True
680
+ return callback_kwargs
681
+
682
+ image = pipe(
683
+ prompt="A landscape",
684
+ num_inference_steps=50,
685
+ callback_on_step_end=early_stop_callback
686
+ ).images[0]
687
+ ```
688
+
689
+ ## Multi-GPU Inference
690
+
691
+ ### Device map auto
692
+
693
+ ```python
694
+ from diffusers import StableDiffusionXLPipeline
695
+
696
+ pipe = StableDiffusionXLPipeline.from_pretrained(
697
+ "stabilityai/stable-diffusion-xl-base-1.0",
698
+ device_map="auto", # Automatically distribute across GPUs
699
+ torch_dtype=torch.float16
700
+ )
701
+ ```
702
+
703
+ ### Manual distribution
704
+
705
+ ```python
706
+ from accelerate import infer_auto_device_map, dispatch_model
707
+
708
+ # Create device map
709
+ device_map = infer_auto_device_map(
710
+ pipe.unet,
711
+ max_memory={0: "10GiB", 1: "10GiB"}
712
+ )
713
+
714
+ # Dispatch model
715
+ pipe.unet = dispatch_model(pipe.unet, device_map=device_map)
716
+ ```