|
| 1 | +# SGLang Diffusion server image generation example |
| 2 | +# |
| 3 | +# Two launch modes are available: |
| 4 | +# |
| 5 | +# launch_mode: managed (recommended) |
| 6 | +# MMIRAGE automatically starts a SGLang server on each worker node, |
| 7 | +# waits until it is ready, runs the pipeline, and shuts it down afterwards. |
| 8 | +# No manual server management is needed. |
| 9 | +# |
| 10 | +# launch_mode: external |
| 11 | +# You are responsible for starting the SGLang server before the pipeline |
| 12 | +# runs. Use this if you want to reuse a long-running server or need |
| 13 | +# fine-grained control over server startup. |
| 14 | +# |
| 15 | +# MMIRAGE handles all dataset sharding, prompt rendering, filename rendering, |
| 16 | +# and result saving. The SGLang server is only responsible for generating |
| 17 | +# image pixels. |
| 18 | + |
| 19 | +processors: |
| 20 | + - type: image_gen |
| 21 | + backend: sglang |
| 22 | + sglang: |
| 23 | + launch_mode: managed # MMIRAGE starts/stops the server automatically |
| 24 | + model_path: stable-diffusion-v1-5/stable-diffusion-v1-5 |
| 25 | + port: 30010 |
| 26 | + num_gpus: 4 # passed as --tp to sglang.launch_server |
| 27 | + # dtype: float16 # optional: --dtype flag |
| 28 | + startup_timeout_seconds: 180 # seconds to wait for the server to become ready |
| 29 | + # extra_server_args: # any additional --flags for sglang.launch_server |
| 30 | + # - "--mem-fraction-static" |
| 31 | + # - "0.9" |
| 32 | + api_key: EMPTY # unauthenticated local server |
| 33 | + timeout_seconds: 900 |
| 34 | + default_sampling_params: |
| 35 | + num_inference_steps: 30 |
| 36 | + guidance_scale: 4.0 |
| 37 | + parallel_inference: true |
| 38 | + parallel_chunk_size: 4 # concurrent requests per chunk (sequential per sample inside the backend) |
| 39 | + output_dir: /users/qchapp/meditron/MIRAGE/tests/output/image_gen/generated_images |
| 40 | + file_format: png |
| 41 | + |
| 42 | +loading_params: |
| 43 | + state_dir: /users/qchapp/meditron/MIRAGE/tests/output/image_gen/_pipeline_state |
| 44 | + datasets: |
| 45 | + - path: /users/qchapp/meditron/MIRAGE/tests/mock_data_image_gen/data.jsonl |
| 46 | + type: JSONL |
| 47 | + output_dir: /users/qchapp/meditron/MIRAGE/tests/output/image_gen |
| 48 | + num_shards: 4 # each Slurm task starts its own server on localhost |
| 49 | + shard_id: ${SLURM_ARRAY_TASK_ID} |
| 50 | + batch_size: 64 |
| 51 | + |
| 52 | +processing_params: |
| 53 | + inputs: |
| 54 | + - name: text |
| 55 | + key: caption |
| 56 | + |
| 57 | + outputs: |
| 58 | + - name: generated_image |
| 59 | + type: image_gen |
| 60 | + output_mode: path |
| 61 | + filename_template: "img_{{ __shard_id }}_{{ __sample_index }}_{{ __source_hash }}" |
| 62 | + width: 1024 |
| 63 | + height: 1024 |
| 64 | + seed: 42 # shard-aware: effective seed = 42 + shard_id * 1_000_000_000 + sample_index |
| 65 | + prompt: | |
| 66 | + A photorealistic image of: {{ text }} |
| 67 | +
|
| 68 | + remove_columns: false |
| 69 | + output_schema: |
| 70 | + caption: "{{ text }}" |
| 71 | + image: "{{ generated_image }}" |
| 72 | + |
| 73 | +execution_params: |
| 74 | + # Execution mode: "local" or "slurm" |
| 75 | + # - local: Run directly on this machine |
| 76 | + # - slurm: Submit jobs to SLURM cluster |
| 77 | + mode: slurm |
| 78 | + |
| 79 | + # Whether the canonical `run` command should automatically retry failed shards. |
| 80 | + # - false: submit one run only |
| 81 | + # - true: submit, wait, and keep retrying failed shards until success or retry budget exhaustion |
| 82 | + retry: false |
| 83 | + |
| 84 | + # Maximum number of times to retry a failed shard (default: 3) |
| 85 | + max_retries: 3 |
| 86 | + |
| 87 | + # ========================================================================== |
| 88 | + # SLURM CONFIGURATION (only used when mode: slurm) |
| 89 | + # ========================================================================== |
| 90 | + |
| 91 | + # HPC account/partition to charge jobs to (REQUIRED for SLURM mode) |
| 92 | + account: a127 |
| 93 | + |
| 94 | + # SLURM job name (default: "mmirage-sharded") |
| 95 | + job_name: mmirage-sharded |
| 96 | + |
| 97 | + # Optional SLURM reservation name (leave blank or omit to not use) |
| 98 | + # reservation: "sai-a127" |
| 99 | + |
| 100 | + # Number of nodes (default: 1) |
| 101 | + nodes: 1 |
| 102 | + |
| 103 | + # Number of tasks per node (default: 1) |
| 104 | + ntasks_per_node: 1 |
| 105 | + |
| 106 | + # Number of GPUs per node (default: 4) |
| 107 | + gpus: 4 |
| 108 | + |
| 109 | + # Number of CPUs per task (default: 288) |
| 110 | + cpus_per_task: 288 |
| 111 | + |
| 112 | + # Job time limit in HH:MM:SS format (default: "11:59:59") |
| 113 | + time_limit: "11:59:59" |
| 114 | + |
| 115 | + # ========================================================================== |
| 116 | + # PATH CONFIGURATION |
| 117 | + # ========================================================================== |
| 118 | + # These support environment variables ($VAR or ${VAR}) and home directory (~) |
| 119 | + |
| 120 | + # Project root directory (used as base for relative paths) |
| 121 | + # If not set, uses current working directory |
| 122 | + # project_root: "/path/to/project" |
| 123 | + |
| 124 | + # Directory for SLURM output and error files (default: ~/reports) |
| 125 | + report_dir: "/users/${USER}/reports" |
| 126 | + |
| 127 | + # HuggingFace cache directory (default: ~/hf) |
| 128 | + hf_home: "/capstor/store/cscs/swissai/a127/homes/${USER}/hf" |
| 129 | + |
| 130 | + # EDF environment file path for cluster-specific setup |
| 131 | + edf_env: "/users/${USER}/.edf/sglang.toml" |
| 132 | + |
| 133 | + # ========================================================================== |
| 134 | + # JOB MONITORING (for "submit" and retry orchestration) |
| 135 | + # ========================================================================== |
| 136 | + |
| 137 | + # Seconds to wait between checking job status (default: 30) |
| 138 | + poll_interval_seconds: 30 |
| 139 | + |
| 140 | + # Seconds to wait after job completes before checking results (default: 60) |
| 141 | + # This allows filesystem to settle on distributed systems |
| 142 | + settle_time_seconds: 60 |
0 commit comments