@wildshard/sdk 0.0.0 → 0.2.3
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.
- package/GUIDE.md +790 -0
- package/README.md +14 -4
- package/bin/wildshard.mjs +38 -0
- package/lint/declaration-config.d.mts +2 -0
- package/lint/declaration-config.mjs +19 -0
- package/lint/engine-plugin.d.mts +2 -0
- package/lint/engine-plugin.mjs +40 -0
- package/lint/host-callbacks.d.mts +6 -0
- package/lint/host-callbacks.mjs +123 -0
- package/lint/host-files.d.mts +1 -0
- package/lint/host-files.mjs +7 -0
- package/lint/layer-exports.d.mts +2 -0
- package/lint/layer-exports.mjs +21 -0
- package/lint/legacy-line-basis.json +995 -0
- package/lint/nine-tiling-baseline.json +35 -0
- package/lint/ratchet.json +11 -0
- package/lint/runtime-files.d.mts +12 -0
- package/lint/runtime-files.json +16 -0
- package/lint/runtime-files.mjs +69 -0
- package/lint/runtime-performance.d.mts +6 -0
- package/lint/runtime-performance.mjs +184 -0
- package/lint/sdk-plugin.d.mts +4 -0
- package/lint/sdk-plugin.mjs +134 -0
- package/lint/shardfile-boundaries.d.mts +10 -0
- package/lint/shardfile-boundaries.mjs +122 -0
- package/lint/tile-bake-debt.json +556 -0
- package/package.json +371 -4
- package/scripts/agent-parity.mjs +1524 -0
- package/scripts/agent-sync.mjs +518 -0
- package/scripts/apfs-clone.mjs +67 -0
- package/scripts/assert-store-layout.mjs +23 -0
- package/scripts/astc6-phone-cap.d.mts +3 -0
- package/scripts/astc6-phone-cap.mjs +137 -0
- package/scripts/audit-assets.d.mts +10 -0
- package/scripts/audit-assets.mjs +151 -0
- package/scripts/bake/coatFiles.d.mts +6 -0
- package/scripts/bake/coatFiles.mjs +37 -0
- package/scripts/bake/environment.d.mts +2 -0
- package/scripts/bake/environment.mjs +58 -0
- package/scripts/bake/far-proxies.mjs +45 -0
- package/scripts/bake/keyed-sky.d.mts +4 -0
- package/scripts/bake/keyed-sky.mjs +34 -0
- package/scripts/bake/movers.mjs +56 -0
- package/scripts/bake/nativeWorld.d.mts +6 -0
- package/scripts/bake/nativeWorld.mjs +43 -0
- package/scripts/bake/navmeshGround.ts +22 -0
- package/scripts/bake/near-placeholder.mjs +331 -0
- package/scripts/bake/placeholderShards.mjs +41 -0
- package/scripts/bake/skins.mjs +15 -0
- package/scripts/bake/template-skins.mjs +33 -0
- package/scripts/bake/viewmodelBytes.ts +26 -0
- package/scripts/bake/viewmodelPage.ts +11 -0
- package/scripts/bake/worldHost.d.mts +35 -0
- package/scripts/bake/worldHost.mjs +110 -0
- package/scripts/bake-astc6.cache.json +80 -0
- package/scripts/bake-astc6.far-reach.cache.json +23 -0
- package/scripts/bake-astc6.list.json +111 -0
- package/scripts/bake-astc6.mjs +279 -0
- package/scripts/bake-astc6.nalati-grasslands.cache.json +42 -0
- package/scripts/bake-catalogue.mjs +44 -0
- package/scripts/bake-check.mjs +54 -0
- package/scripts/bake-chunk.mjs +124 -0
- package/scripts/bake-cloud-field.mjs +24 -0
- package/scripts/bake-coats.mjs +110 -0
- package/scripts/bake-data-maps.d.mts +24 -0
- package/scripts/bake-data-maps.mjs +72 -0
- package/scripts/bake-entry-programs.mjs +117 -0
- package/scripts/bake-geometry.mjs +106 -0
- package/scripts/bake-hybrid-tiles.mjs +28 -0
- package/scripts/bake-ktx2.cache.json +276 -0
- package/scripts/bake-ktx2.list.json +365 -0
- package/scripts/bake-ktx2.mjs +477 -0
- package/scripts/bake-map-glb.mjs +127 -0
- package/scripts/bake-map-rest.d.mts +7 -0
- package/scripts/bake-map-rest.mjs +50 -0
- package/scripts/bake-maps.mjs +200 -0
- package/scripts/bake-navmesh.mjs +259 -0
- package/scripts/bake-packs.mjs +129 -0
- package/scripts/bake-pickups.mjs +102 -0
- package/scripts/bake-query-terrain.mjs +64 -0
- package/scripts/bake-recurve-pool.mjs +16 -0
- package/scripts/bake-section-schemas.d.mts +3 -0
- package/scripts/bake-template-shardfile.mjs +32 -0
- package/scripts/bake-textures.mjs +80 -0
- package/scripts/bake-viewmodel-sets.json +45 -0
- package/scripts/bake-viewmodel-sets.mjs +137 -0
- package/scripts/bake-voxel-ao.mjs +119 -0
- package/scripts/bake-water-ripples.mjs +25 -0
- package/scripts/blender/README.md +129 -0
- package/scripts/blender/build.sh +166 -0
- package/scripts/blender/lib/export-scene.mjs +129 -0
- package/scripts/blender/lib/glb-digest.mjs +188 -0
- package/scripts/blender/lib/glb.py +68 -0
- package/scripts/blender/lib/save_blend.py +17 -0
- package/scripts/blender/lib/world_fixture.py +55 -0
- package/scripts/blender/targets.json +591 -0
- package/scripts/build-sdk.mjs +95 -0
- package/scripts/build-shardfiles.d.mts +7 -0
- package/scripts/build-shardfiles.mjs +206 -0
- package/scripts/capture-hero.mjs +137 -0
- package/scripts/check-lift-review.mjs +23 -0
- package/scripts/chromium-keychain-check.mjs +139 -0
- package/scripts/chromium-keychain.d.mts +1 -0
- package/scripts/chromium-keychain.mjs +5 -0
- package/scripts/compile-script.d.mts +3 -0
- package/scripts/compile-script.mjs +8 -0
- package/scripts/creature-color.mjs +255 -0
- package/scripts/decide/calibrate.py +127 -0
- package/scripts/decide/calibration/2026-10-03/labels-s1.tsv +281 -0
- package/scripts/decide/calibration/2026-10-03/labels-s2.tsv +97 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3.tsv +48 -0
- package/scripts/decide/calibration/2026-10-03/labels-s3b.tsv +26 -0
- package/scripts/decide/calibration/2026-10-03/res-capture-status-v1.jsonl +376 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-strings.jsonl +48 -0
- package/scripts/decide/calibration/2026-10-03/res-text-garbled-v1.jsonl +73 -0
- package/scripts/decide/decide.py +262 -0
- package/scripts/decide/decide.sh +50 -0
- package/scripts/decide/layer-purity-pilot.mjs +41 -0
- package/scripts/decide/sets/capture-status.json +46 -0
- package/scripts/decide/sets/layer-purity.json +28 -0
- package/scripts/decide/sets/text-garbled.json +17 -0
- package/scripts/decide/test_decide.py +37 -0
- package/scripts/docs.mjs +15 -0
- package/scripts/entry-reads/crawl.ts +152 -0
- package/scripts/entry-reads/tsconfig.json +25 -0
- package/scripts/gen-format-schema.d.mts +2 -0
- package/scripts/gen-format-schema.mjs +21 -0
- package/scripts/gen-host-catalogue.d.mts +14 -0
- package/scripts/gen-host-catalogue.mjs +108 -0
- package/scripts/gen-shard-layout-doc.d.mts +4 -0
- package/scripts/gen-shard-layout-doc.mjs +55 -0
- package/scripts/gen-shards.d.mts +17 -0
- package/scripts/gen-shards.mjs +311 -0
- package/scripts/goldens/capture-inputs.d.mts +4 -0
- package/scripts/goldens/capture-inputs.mjs +34 -0
- package/scripts/goldens/colour_shift.py +27 -0
- package/scripts/goldens/native-residency.d.mts +10 -0
- package/scripts/goldens/native-residency.mjs +104 -0
- package/scripts/goldens/plot-inputs.d.mts +12 -0
- package/scripts/goldens/plot-inputs.mjs +46 -0
- package/scripts/gpu-texmem.mjs +98 -0
- package/scripts/horizon-matte/config.py +24 -0
- package/scripts/horizon-matte/encode.py +91 -0
- package/scripts/horizon-matte/key.py +141 -0
- package/scripts/horizon-matte/mkjobs.py +33 -0
- package/scripts/horizon-matte/mkjobs_day2.py +11 -0
- package/scripts/horizon-matte/overlap.py +80 -0
- package/scripts/horizon-matte/run_codex.py +57 -0
- package/scripts/horizon-matte/stitch.py +133 -0
- package/scripts/img2mesh/CC0.md +105 -0
- package/scripts/img2mesh/README.md +209 -0
- package/scripts/img2mesh/ab_board.py +102 -0
- package/scripts/img2mesh/birds/birds.json +255 -0
- package/scripts/img2mesh/birds/birds_atlas.py +150 -0
- package/scripts/img2mesh/birds/birds_fix_preview.mjs +103 -0
- package/scripts/img2mesh/birds/birds_fix_render.py +75 -0
- package/scripts/img2mesh/birds/birds_pack.py +110 -0
- package/scripts/img2mesh/birds/birds_phone_b.py +112 -0
- package/scripts/img2mesh/birds/birds_post.py +550 -0
- package/scripts/img2mesh/birds/birds_render.py +125 -0
- package/scripts/img2mesh/birds/birds_sheet.py +33 -0
- package/scripts/img2mesh/birds/birds_view.py +60 -0
- package/scripts/img2mesh/board.py +100 -0
- package/scripts/img2mesh/build_cc0.sh +52 -0
- package/scripts/img2mesh/build_driftwood.sh +12 -0
- package/scripts/img2mesh/build_faces.sh +53 -0
- package/scripts/img2mesh/build_props.py +81 -0
- package/scripts/img2mesh/cc0_export.py +186 -0
- package/scripts/img2mesh/driftwood_post.py +571 -0
- package/scripts/img2mesh/e304_faces.sh +67 -0
- package/scripts/img2mesh/face_remaster.py +911 -0
- package/scripts/img2mesh/face_views.py +95 -0
- package/scripts/img2mesh/faces-e304.json +9 -0
- package/scripts/img2mesh/faces.json +30 -0
- package/scripts/img2mesh/head_cut.py +100 -0
- package/scripts/img2mesh/hi3d_paint.py +94 -0
- package/scripts/img2mesh/hi3d_refine.py +161 -0
- package/scripts/img2mesh/hunyuan_cpu_rasterizer.sh +42 -0
- package/scripts/img2mesh/pine_hollow_phone.sh +13 -0
- package/scripts/img2mesh/props/coral-arch.json +32 -0
- package/scripts/img2mesh/props/ember-furnace.json +30 -0
- package/scripts/img2mesh/props/night-market-gate.json +10 -0
- package/scripts/img2mesh/render_still.py +86 -0
- package/scripts/img2mesh/rig_strip.mjs +46 -0
- package/scripts/img2mesh/rig_transfer.mjs +104 -0
- package/scripts/img2mesh/split_sheet.py +48 -0
- package/scripts/img2mesh/trellis_batch.py +110 -0
- package/scripts/img2mesh/versus_board.py +114 -0
- package/scripts/import-bundle.d.mts +2 -0
- package/scripts/import-bundle.mjs +20 -0
- package/scripts/ktx2-ab-board.py +133 -0
- package/scripts/ktx2-ab.mjs +111 -0
- package/scripts/ktx2-settings.mjs +18 -0
- package/scripts/land.d.mts +14 -0
- package/scripts/land.mjs +809 -0
- package/scripts/lint-dispatch.mjs +14 -0
- package/scripts/map-bake-frames.d.mts +4 -0
- package/scripts/map-bake-frames.mjs +23 -0
- package/scripts/map-geometry.d.mts +9 -0
- package/scripts/map-geometry.mjs +29 -0
- package/scripts/map-world.mjs +162 -0
- package/scripts/mockup-local.sh +46 -0
- package/scripts/music/export-midi.mjs +68 -0
- package/scripts/music/gen/analyze.py +308 -0
- package/scripts/music/gen/audio_jobs.py +46 -0
- package/scripts/music/gen/briefs.json +51 -0
- package/scripts/music/gen/build_page.py +334 -0
- package/scripts/music/gen/folk.json +3187 -0
- package/scripts/music/gen/gen_ace_step.py +156 -0
- package/scripts/music/gen/gen_heartmula.py +187 -0
- package/scripts/music/gen/gen_minimax.py +143 -0
- package/scripts/music/gen/gen_sao.py +122 -0
- package/scripts/music/gen/gen_sao_small.py +104 -0
- package/scripts/music/gen/gen_sfx.py +98 -0
- package/scripts/music/gen/gen_sfx_ezaudio.py +112 -0
- package/scripts/music/gen/gen_sfx_moss.py +112 -0
- package/scripts/music/gen/models.json +61 -0
- package/scripts/music/gen/nalati-jobs.json +104 -0
- package/scripts/music/gen/nalati-score-build.json +119 -0
- package/scripts/music/gen/nalati-score.json +3448 -0
- package/scripts/music/gen/ob7-fit-decisions.json +38 -0
- package/scripts/music/gen/ob7-score-jobs.json +152 -0
- package/scripts/music/gen/ob7-sfx-jobs.json +897 -0
- package/scripts/music/gen/ob7_build.py +469 -0
- package/scripts/music/gen/ob7_generate.py +67 -0
- package/scripts/music/gen/ob7_run.sh +42 -0
- package/scripts/music/gen/orchestral.json +3187 -0
- package/scripts/music/gen/own_score.py +486 -0
- package/scripts/music/gen/ph-jobs.json +27 -0
- package/scripts/music/gen/ph_page.py +222 -0
- package/scripts/music/gen/piano.json +3175 -0
- package/scripts/music/gen/rank_v3.py +248 -0
- package/scripts/music/gen/sfx-best.json +2486 -0
- package/scripts/music/gen/sfx-ezaudio.json +4082 -0
- package/scripts/music/gen/sfx-jobs.json +57 -0
- package/scripts/music/gen/sfx-minimax-jobs.json +16 -0
- package/scripts/music/gen/sfx-minimax.json +289 -0
- package/scripts/music/gen/sfx-moss.json +4082 -0
- package/scripts/music/gen/sfx-nalati-b3-jobs.json +17 -0
- package/scripts/music/gen/sfx-nalati-jobs.json +338 -0
- package/scripts/music/gen/sfx-nalati.json +11202 -0
- package/scripts/music/gen/sfx-nd-jobs.json +57 -0
- package/scripts/music/gen/sfx-nd-moss.json +2097 -0
- package/scripts/music/gen/sfx-nd-sa3-medium.json +2097 -0
- package/scripts/music/gen/sfx-nd-summary.json +38 -0
- package/scripts/music/gen/sfx-peaks.json +7 -0
- package/scripts/music/gen/sfx-ph-jobs.json +169 -0
- package/scripts/music/gen/sfx-ph-moss.json +6564 -0
- package/scripts/music/gen/sfx-ph-sa3-medium.json +7239 -0
- package/scripts/music/gen/sfx-ph-summary.json +63 -0
- package/scripts/music/gen/sfx-sa3-medium.json +4082 -0
- package/scripts/music/gen/sfx-sa3.json +4082 -0
- package/scripts/music/gen/sfx-summary.json +107 -0
- package/scripts/music/gen/sfx_build.py +332 -0
- package/scripts/music/gen/sfx_merge.py +255 -0
- package/scripts/music/gen/sfx_minimax.py +61 -0
- package/scripts/music/gen/sfx_nalati.py +331 -0
- package/scripts/music/gen/sfx_sprite.py +424 -0
- package/scripts/music/gen/stems.py +539 -0
- package/scripts/music/gen/test_loop_meter.py +29 -0
- package/scripts/music/gen/test_ob7_provenance.py +77 -0
- package/scripts/music/gen/v3-folk-build.json +148 -0
- package/scripts/music/gen/v3-folk.json +1818 -0
- package/scripts/music/gen/v3-jobs.json +145 -0
- package/scripts/music/gen/v3-orchestral-build.json +148 -0
- package/scripts/music/gen/v3-orchestral.json +1813 -0
- package/scripts/music/gen/v3-ph-folk-build.json +94 -0
- package/scripts/music/gen/v3-ph-folk.json +1806 -0
- package/scripts/music/gen/v3-ph-orchestral-build.json +94 -0
- package/scripts/music/gen/v3-ph-orchestral.json +1824 -0
- package/scripts/music/gen/v3-ph-piano-build.json +94 -0
- package/scripts/music/gen/v3-ph-piano.json +1818 -0
- package/scripts/music/gen/v3-piano-build.json +148 -0
- package/scripts/music/gen/v3-piano.json +1813 -0
- package/scripts/music/wildshard-theme.mid +0 -0
- package/scripts/music/wildshard-trailer30.mid +0 -0
- package/scripts/named-blob-output.d.mts +8 -0
- package/scripts/named-blob-output.mjs +48 -0
- package/scripts/pack-all.mjs +15 -0
- package/scripts/pid-lock.d.mts +1 -0
- package/scripts/pid-lock.mjs +63 -0
- package/scripts/practice/bake_dummy.py +53 -0
- package/scripts/practice/build_dummies.sh +43 -0
- package/scripts/practice/dummy_parts.py +568 -0
- package/scripts/practice/dummy_rig_gate.py +139 -0
- package/scripts/practice/gate_sheet.py +36 -0
- package/scripts/practice/generate_dummy_unimate.py +132 -0
- package/scripts/practice/pack_dummy.mjs +59 -0
- package/scripts/practice/repair_dummy_weights.mjs +68 -0
- package/scripts/practice/rig_dummy.py +828 -0
- package/scripts/practice/verify_unimate_skin.mjs +356 -0
- package/scripts/preparation-seed.mjs +15 -0
- package/scripts/prepare-basis-tool.mjs +6 -0
- package/scripts/prepare-product.d.mts +14 -0
- package/scripts/prepare-product.mjs +101 -0
- package/scripts/product-build-tools.d.mts +3 -0
- package/scripts/product-build-tools.json +3 -0
- package/scripts/product-build-tools.mjs +31 -0
- package/scripts/publish-public.mjs +7 -0
- package/scripts/push-tables.d.mts +1 -0
- package/scripts/push-tables.mjs +28 -0
- package/scripts/record-shard-mounts.mjs +133 -0
- package/scripts/sdk-externals.d.mts +2 -0
- package/scripts/sdk-externals.mjs +2 -0
- package/scripts/section-inventory.ts +209 -0
- package/scripts/select-candidate.mjs +15 -0
- package/scripts/shard-build-pool.d.mts +4 -0
- package/scripts/shard-build-pool.mjs +53 -0
- package/scripts/shard-line-baseline.json +17 -0
- package/scripts/shard-milestones.d.mts +15 -0
- package/scripts/shard-milestones.mjs +105 -0
- package/scripts/shard-output-report.d.mts +9 -0
- package/scripts/shard-output-report.mjs +85 -0
- package/scripts/shard-platform-cli.mjs +93 -0
- package/scripts/shard-progress.mjs +212 -0
- package/scripts/shard-timelapse.py +102 -0
- package/scripts/shardfile-cold-boot.mjs +79 -0
- package/scripts/shardfile-vite.d.mts +4 -0
- package/scripts/shardfile-vite.mjs +20 -0
- package/scripts/simplify-models.mjs +24 -0
- package/scripts/site-facts.mjs +88 -0
- package/scripts/test-template-gate.mjs +44 -0
- package/scripts/test_golden_compare.py +68 -0
- package/scripts/tex-tiers.cache.json +181 -0
- package/scripts/tex-tiers.mjs +240 -0
- package/scripts/texmem-probe.mjs +184 -0
- package/scripts/unused-assets.mjs +173 -0
- package/scripts/vite-tmp.d.mts +23 -0
- package/scripts/vite-tmp.mjs +157 -0
- package/scripts/wave-line-baselines.json +32 -0
- package/scripts/wildshard.d.mts +4 -0
- package/scripts/wildshard.mjs +105 -0
- package/scripts/witness-checkpoints.d.mts +10 -0
- package/scripts/witness-checkpoints.mjs +84 -0
- package/scripts/witness-generation.d.mts +10 -0
- package/scripts/witness-generation.mjs +45 -0
- package/scripts/witness-manifests.d.mts +8 -0
- package/scripts/witness-manifests.mjs +157 -0
- package/scripts/worktree-ignore.d.mts +4 -0
- package/scripts/worktree-ignore.mjs +36 -0
- package/scripts/worktree-reap.mjs +214 -0
- package/scripts/worktree.mjs +396 -0
- package/scripts/worldclaw/capture-front.sh +28 -0
- package/scripts/worldclaw/design-template.md +62 -0
- package/scripts/worldclaw/spec-map.py +92 -0
- package/scripts/worldclaw/spec.ts +96 -0
- package/skills/wildshard/SKILL.md +50 -0
- package/skills/wildshard-goldens/SKILL.md +54 -0
- package/skills/wildshard-mockup-to-model/SKILL.md +56 -0
- package/skills/wildshard-upgrade/SKILL.md +46 -0
- package/src/.oxfmtrc.json +50 -0
- package/src/.oxlintrc.json +173 -0
- package/src/cli/account/account.ts +199 -0
- package/src/cli/account/command.ts +193 -0
- package/src/cli/account/key.ts +154 -0
- package/src/cli/args.ts +97 -0
- package/src/cli/audio/audio.ts +24 -0
- package/src/cli/bin.mjs +8 -0
- package/src/cli/delete/delete.ts +258 -0
- package/src/cli/help.ts +196 -0
- package/src/cli/hero/adopt.ts +103 -0
- package/src/cli/hero/hero.ts +112 -0
- package/src/cli/hero/stamp.ts +298 -0
- package/src/cli/main.ts +292 -0
- package/src/cli/report.ts +16 -0
- package/src/cli/shardfile/command.ts +50 -0
- package/src/cli/shardfile/shardfile.ts +192 -0
- package/src/cli/upload/api.ts +246 -0
- package/src/cli/upload/compress.ts +55 -0
- package/src/cli/upload/hero.ts +62 -0
- package/src/cli/upload/placement.ts +115 -0
- package/src/cli/upload/provenance.ts +192 -0
- package/src/cli/upload/signature.ts +30 -0
- package/src/cli/upload/upload.ts +269 -0
- package/src/cli/upload/validate.ts +74 -0
- package/src/cli/upload/wire.ts +147 -0
- package/src/cli/version.ts +63 -0
- package/src/commons/bake/portableMath.ts +187 -0
- package/src/commons/catalogue.ts +10 -0
- package/src/commons/courseProgram.ts +32 -0
- package/src/commons/practiceCourse.ts +16 -0
- package/src/commons/scripts/abi.as +14 -0
- package/src/commons/scripts/bridge.as +14 -0
- package/src/commons/scripts/course.as +63 -0
- package/src/scripts/ask-new.sh +29 -0
- package/src/scripts/asks.mjs +141 -0
- package/src/scripts/herdr-prompt.sh +34 -0
- package/src/scripts/herdr-question-open.sh +67 -0
- package/src/scripts/md-wrap.mjs +229 -0
- package/src/server/app.ts +19 -0
- package/src/server/serve.ts +49 -0
- package/src/sharddev/admission.ts +7 -0
- package/src/sharddev/arenaView.ts +15 -0
- package/src/sharddev/as/groupBankV2.ts +36 -0
- package/src/sharddev/as/groupStepV2.ts +13 -0
- package/src/sharddev/as/ws.ts +30 -0
- package/src/sharddev/as/wsV2.ts +180 -0
- package/src/sharddev/assemblyscriptCompiler.d.mts +5 -0
- package/src/sharddev/assemblyscriptCompiler.mjs +14 -0
- package/src/sharddev/assetHandle.ts +84 -0
- package/src/sharddev/assetOwner.ts +70 -0
- package/src/sharddev/assetScope.ts +30 -0
- package/src/sharddev/assets.ts +21 -0
- package/src/sharddev/audio.ts +9 -0
- package/src/sharddev/audioEncode.ts +211 -0
- package/src/sharddev/author.ts +3 -0
- package/src/sharddev/authorError.ts +28 -0
- package/src/sharddev/authorManifest.ts +39 -0
- package/src/sharddev/bake/annulus.ts +19 -0
- package/src/sharddev/bake/assemblyscriptMemo.ts +76 -0
- package/src/sharddev/bake/assemblyscriptMemoPort.ts +4 -0
- package/src/sharddev/bake/authoredWorld.ts +201 -0
- package/src/sharddev/bake/basisEncoder.ts +95 -0
- package/src/sharddev/bake/basisGlb.ts +85 -0
- package/src/sharddev/bake/basisTool.ts +74 -0
- package/src/sharddev/bake/basisToolInputs.ts +476 -0
- package/src/sharddev/bake/byteCodec.ts +33 -0
- package/src/sharddev/bake/canvasAtlas.ts +406 -0
- package/src/sharddev/bake/coarseCopy.ts +59 -0
- package/src/sharddev/bake/colliders.ts +87 -0
- package/src/sharddev/bake/compactGlb.ts +224 -0
- package/src/sharddev/bake/compileScript.ts +119 -0
- package/src/sharddev/bake/compileScriptV2.ts +75 -0
- package/src/sharddev/bake/contactRows.ts +84 -0
- package/src/sharddev/bake/creaturePlacement.ts +117 -0
- package/src/sharddev/bake/export.ts +67 -0
- package/src/sharddev/bake/facetedGeometry.ts +379 -0
- package/src/sharddev/bake/farImpostor.ts +120 -0
- package/src/sharddev/bake/forest.ts +100 -0
- package/src/sharddev/bake/format-hook.mjs +2 -0
- package/src/sharddev/bake/generatorGlb.ts +23 -0
- package/src/sharddev/bake/geometryBounds.ts +77 -0
- package/src/sharddev/bake/geometryError.ts +48 -0
- package/src/sharddev/bake/glb.ts +355 -0
- package/src/sharddev/bake/glbCompression.ts +143 -0
- package/src/sharddev/bake/gltfSource.ts +59 -0
- package/src/sharddev/bake/groundMap.ts +142 -0
- package/src/sharddev/bake/image.ts +20 -0
- package/src/sharddev/bake/isleMap.ts +64 -0
- package/src/sharddev/bake/json.mjs +84 -0
- package/src/sharddev/bake/keyedSky.ts +47 -0
- package/src/sharddev/bake/keyedSkyMemo.ts +39 -0
- package/src/sharddev/bake/kinds.ts +137 -0
- package/src/sharddev/bake/lightSources.ts +31 -0
- package/src/sharddev/bake/mapAssembly.ts +84 -0
- package/src/sharddev/bake/mapRaster.ts +173 -0
- package/src/sharddev/bake/mapRest.ts +57 -0
- package/src/sharddev/bake/mapScenes.ts +234 -0
- package/src/sharddev/bake/materialGraph.ts +32 -0
- package/src/sharddev/bake/meadow.ts +27 -0
- package/src/sharddev/bake/meshoptChoiceMemo.ts +34 -0
- package/src/sharddev/bake/nativeInteractionFacts.ts +5 -0
- package/src/sharddev/bake/nativeLattice.ts +178 -0
- package/src/sharddev/bake/nativeRaster.ts +106 -0
- package/src/sharddev/bake/nativeTerrainField.ts +11 -0
- package/src/sharddev/bake/navigation-json.mjs +38 -0
- package/src/sharddev/bake/navigation.ts +113 -0
- package/src/sharddev/bake/navigationAsset.ts +18 -0
- package/src/sharddev/bake/nearPlaceholder.ts +206 -0
- package/src/sharddev/bake/normalizeRig.ts +80 -0
- package/src/sharddev/bake/phoneAstc.ts +93 -0
- package/src/sharddev/bake/placeholders.ts +581 -0
- package/src/sharddev/bake/placement.ts +80 -0
- package/src/sharddev/bake/portableBytes.ts +18 -0
- package/src/sharddev/bake/portableBytesMemo.ts +50 -0
- package/src/sharddev/bake/practiceCourse.ts +49 -0
- package/src/sharddev/bake/primitives.ts +96 -0
- package/src/sharddev/bake/props.ts +443 -0
- package/src/sharddev/bake/questPlacement.ts +98 -0
- package/src/sharddev/bake/rawTexture.ts +26 -0
- package/src/sharddev/bake/riderArms.ts +97 -0
- package/src/sharddev/bake/rig.ts +95 -0
- package/src/sharddev/bake/riggedHullRecipes.ts +40 -0
- package/src/sharddev/bake/signPlacements.ts +25 -0
- package/src/sharddev/bake/simplifier.ts +52 -0
- package/src/sharddev/bake/skinned.ts +312 -0
- package/src/sharddev/bake/slabChunks.ts +149 -0
- package/src/sharddev/bake/slabs.ts +263 -0
- package/src/sharddev/bake/source-loader.mjs +55 -0
- package/src/sharddev/bake/sourceMetadata.ts +54 -0
- package/src/sharddev/bake/species.ts +368 -0
- package/src/sharddev/bake/specimenCatalogue.ts +47 -0
- package/src/sharddev/bake/splatGround.ts +141 -0
- package/src/sharddev/bake/staticMaterials.ts +171 -0
- package/src/sharddev/bake/terrain.ts +195 -0
- package/src/sharddev/bake/texture.ts +33 -0
- package/src/sharddev/bake/textureWasm.ts +81 -0
- package/src/sharddev/bake/tileEncoder.ts +11 -0
- package/src/sharddev/bake/tileGrid.ts +62 -0
- package/src/sharddev/bake/v2Finite.ts +160 -0
- package/src/sharddev/bake/v2Fuel.ts +71 -0
- package/src/sharddev/bake/wholePartition.ts +74 -0
- package/src/sharddev/bake/wholePieceJoin.ts +147 -0
- package/src/sharddev/bake/world.ts +173 -0
- package/src/sharddev/bake/worldCollision.ts +128 -0
- package/src/sharddev/bake/worldGeometry.ts +237 -0
- package/src/sharddev/bake/worldGlb.ts +123 -0
- package/src/sharddev/bake/worldImage.ts +12 -0
- package/src/sharddev/bake/worldLod.ts +128 -0
- package/src/sharddev/bake/worldRows.ts +102 -0
- package/src/sharddev/bake/worldTextureMemo.ts +63 -0
- package/src/sharddev/bake/zstdBytesMemo.ts +52 -0
- package/src/sharddev/bake.ts +193 -0
- package/src/sharddev/bakePublication.ts +31 -0
- package/src/sharddev/behaviourSource.ts +94 -0
- package/src/sharddev/bin/wildshard.mjs +7 -0
- package/src/sharddev/blobBytes.ts +65 -0
- package/src/sharddev/blobs.ts +138 -0
- package/src/sharddev/bootInventory.ts +129 -0
- package/src/sharddev/bossProfiles.ts +18 -0
- package/src/sharddev/buildBehaviour.ts +77 -0
- package/src/sharddev/buildCacheMetrics.ts +17 -0
- package/src/sharddev/buildDecisionScripts.ts +122 -0
- package/src/sharddev/check.ts +117 -0
- package/src/sharddev/checkProject.ts +126 -0
- package/src/sharddev/cli.ts +191 -0
- package/src/sharddev/clientChannels.ts +169 -0
- package/src/sharddev/clientScripts.ts +10 -0
- package/src/sharddev/commons.ts +77 -0
- package/src/sharddev/commonsCosts.ts +11 -0
- package/src/sharddev/compileMovers.ts +11 -0
- package/src/sharddev/configBoundary.ts +6 -0
- package/src/sharddev/cookInput.ts +40 -0
- package/src/sharddev/crowds.ts +6 -0
- package/src/sharddev/decisionBindingMap.ts +11 -0
- package/src/sharddev/decisionScriptBindings.ts +117 -0
- package/src/sharddev/decisionScripts.ts +28 -0
- package/src/sharddev/decisionSource.ts +51 -0
- package/src/sharddev/dev.ts +113 -0
- package/src/sharddev/director.ts +26 -0
- package/src/sharddev/directorAbi.ts +77 -0
- package/src/sharddev/discoveryDocument.ts +97 -0
- package/src/sharddev/draft.ts +11 -0
- package/src/sharddev/eliteEntryRows.ts +29 -0
- package/src/sharddev/entries.ts +76 -0
- package/src/sharddev/entryReads.ts +73 -0
- package/src/sharddev/executeBundle.ts +55 -0
- package/src/sharddev/finds.ts +5 -0
- package/src/sharddev/formatJsonSchema.ts +3 -0
- package/src/sharddev/generationCache.ts +257 -0
- package/src/sharddev/generationRecipe.ts +94 -0
- package/src/sharddev/handwritten.ts +110 -0
- package/src/sharddev/immutable.ts +14 -0
- package/src/sharddev/interactions.ts +38 -0
- package/src/sharddev/kit/bakedGeometry.ts +16 -0
- package/src/sharddev/kit/geometryPack.ts +110 -0
- package/src/sharddev/ledger.ts +13 -0
- package/src/sharddev/looks/tileField.ts +67 -0
- package/src/sharddev/materialGraphFiles.ts +57 -0
- package/src/sharddev/materials.ts +574 -0
- package/src/sharddev/measure.ts +18 -0
- package/src/sharddev/modes.ts +115 -0
- package/src/sharddev/moverPrograms.ts +213 -0
- package/src/sharddev/movers.ts +75 -0
- package/src/sharddev/nativePopulationRows.ts +46 -0
- package/src/sharddev/newProject.ts +247 -0
- package/src/sharddev/noise.ts +54 -0
- package/src/sharddev/outputProduct.ts +188 -0
- package/src/sharddev/outputRuntime.ts +66 -0
- package/src/sharddev/performancePolicy.ts +18 -0
- package/src/sharddev/phasedBoss.ts +34 -0
- package/src/sharddev/physics.ts +194 -0
- package/src/sharddev/platformSections.ts +42 -0
- package/src/sharddev/plumbing.ts +8 -0
- package/src/sharddev/productOutput.ts +128 -0
- package/src/sharddev/project.ts +337 -0
- package/src/sharddev/projectCompilerIdentity.ts +94 -0
- package/src/sharddev/projectDecisions.ts +66 -0
- package/src/sharddev/projectEntryProof.ts +32 -0
- package/src/sharddev/projectGeneration.ts +219 -0
- package/src/sharddev/projectInputFiles.ts +47 -0
- package/src/sharddev/projectManifest.ts +108 -0
- package/src/sharddev/projectMap.ts +35 -0
- package/src/sharddev/projectOutput.ts +242 -0
- package/src/sharddev/projectPolicy.ts +17 -0
- package/src/sharddev/projectSections.ts +27 -0
- package/src/sharddev/questGraph.ts +25 -0
- package/src/sharddev/quests.ts +65 -0
- package/src/sharddev/random.ts +61 -0
- package/src/sharddev/refusals.ts +234 -0
- package/src/sharddev/reportCard.ts +13 -0
- package/src/sharddev/returnProjectionV2.ts +81 -0
- package/src/sharddev/rows.ts +192 -0
- package/src/sharddev/runtimeImports.ts +38 -0
- package/src/sharddev/runtimeMirrors.ts +39 -0
- package/src/sharddev/runtimePerformance.ts +38 -0
- package/src/sharddev/scene.ts +321 -0
- package/src/sharddev/sceneAnimation.ts +54 -0
- package/src/sharddev/sceneAudio.ts +64 -0
- package/src/sharddev/sceneDeclarations.ts +100 -0
- package/src/sharddev/sceneGraph.ts +139 -0
- package/src/sharddev/sceneTransform.ts +12 -0
- package/src/sharddev/schemaValidation.ts +61 -0
- package/src/sharddev/sections.ts +47 -0
- package/src/sharddev/shardSource.ts +59 -0
- package/src/sharddev/sourceReader.ts +26 -0
- package/src/sharddev/spawns.ts +38 -0
- package/src/sharddev/species/clips.ts +24 -0
- package/src/sharddev/species.ts +29 -0
- package/src/sharddev/speciesBrains.ts +19 -0
- package/src/sharddev/synth.ts +66 -0
- package/src/sharddev/test/compileDualScriptV2.ts +71 -0
- package/src/sharddev/test/compileSimV2.ts +21 -0
- package/src/sharddev/test/diskScriptScenario.ts +86 -0
- package/src/sharddev/test/scriptScenario.ts +249 -0
- package/src/sharddev/test/scriptSource.ts +12 -0
- package/src/sharddev/version.ts +4 -0
- package/src/sharddev/weapons/bowProfile.ts +20 -0
- package/src/sharddev/weapons/firearmRows.ts +11 -0
- package/src/sharddev/weapons/meleeProfile.ts +71 -0
- package/src/sharddev/weapons/thrownProfile.ts +10 -0
- package/src/sharddev/worldScenes.ts +308 -0
- package/src/sharddev/worldSource.ts +82 -0
- package/src/shards/_template/README.md +78 -0
- package/src/shards/_template/assets/2bf489fdb15f1734ddb4c4f32d500ec6da85c765ec7a4eb28dc6781160e7ec8c +0 -0
- package/src/shards/_template/assets/97ec4d8f75f5fa6239ee919444d6dc19fd35896bb305930c1f050ac6e0e0e6a6 +1 -0
- package/src/shards/_template/assets/a6a587a31327f936b1b04c05ade818c73fc8964260918662db43539465e27586 +0 -0
- package/src/shards/_template/assets/b4fbde0422e125b498c3dc8b9a5cc2516c8598f09e9d0e5f6b639b32f98179e6 +0 -0
- package/src/shards/_template/assets/bfa4dfc9c18979f904557ee8deab0058b8a399be10266f5fb1578b403f482fd4 +1 -0
- package/src/shards/_template/assets/ef3b7ff4fd22715771cb7d68a3977a903c5e7c3dc293542687d04b3ef3ace2cb +0 -0
- package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
- package/src/shards/_template/assets/fef98ebb7fce6f66b26e78ac699e5c90f9bdcfaf8cabeb2b58125347eea8b4ab +0 -0
- package/src/shards/_template/behaviour/boss.as +39 -0
- package/src/shards/_template/behaviour/door.as +32 -0
- package/src/shards/_template/behaviour/hooks.json +129 -0
- package/src/shards/_template/behaviour/idle.as +75 -0
- package/src/shards/_template/behaviour/items.as +22 -0
- package/src/shards/_template/card/landscape.jpg +0 -0
- package/src/shards/_template/card/portrait.jpg +0 -0
- package/src/shards/_template/card/thumb.jpg +0 -0
- package/src/shards/_template/data/audio.json +45 -0
- package/src/shards/_template/data/bossDecision.json +83 -0
- package/src/shards/_template/data/budgets.json +70 -0
- package/src/shards/_template/data/card.json +281 -0
- package/src/shards/_template/data/clientScripts.json +987 -0
- package/src/shards/_template/data/creatures.json +65 -0
- package/src/shards/_template/data/director.json +39 -0
- package/src/shards/_template/data/encounters.json +96 -0
- package/src/shards/_template/data/items.json +172 -0
- package/src/shards/_template/data/layout.json +66 -0
- package/src/shards/_template/data/ledger.json +32 -0
- package/src/shards/_template/data/look.json +521 -0
- package/src/shards/_template/data/map.json +64 -0
- package/src/shards/_template/data/moves.json +16 -0
- package/src/shards/_template/data/placeholder.json +8 -0
- package/src/shards/_template/data/plumbing.json +32 -0
- package/src/shards/_template/data/quests.json +223 -0
- package/src/shards/_template/data/rows.json +423 -0
- package/src/shards/_template/data/skins.json +66 -0
- package/src/shards/_template/data/spawn.json +6 -0
- package/src/shards/_template/data/targets.json +150 -0
- package/src/shards/_template/data/text.json +12 -0
- package/src/shards/_template/data/ui.json +33 -0
- package/src/shards/_template/data/water.json +13 -0
- package/src/shards/_template/generators/behaviour.ts +34 -0
- package/src/shards/_template/generators/boss.ts +29 -0
- package/src/shards/_template/generators/buildOptions.ts +2 -0
- package/src/shards/_template/generators/cell.ts +224 -0
- package/src/shards/_template/generators/districts.ts +215 -0
- package/src/shards/_template/generators/farLook.ts +15 -0
- package/src/shards/_template/generators/generate.ts +27 -0
- package/src/shards/_template/generators/ground.ts +15 -0
- package/src/shards/_template/generators/kit.ts +69 -0
- package/src/shards/_template/generators/landscape.ts +59 -0
- package/src/shards/_template/generators/landscapeNoise.ts +62 -0
- package/src/shards/_template/generators/mapInputs.ts +10 -0
- package/src/shards/_template/generators/product.ts +100 -0
- package/src/shards/_template/generators/productOutput.ts +18 -0
- package/src/shards/_template/generators/props.ts +9 -0
- package/src/shards/_template/generators/templatePropsSource.ts +58 -0
- package/src/shards/_template/generators/terrain.ts +17 -0
- package/src/shards/_template/generators/world.ts +630 -0
- package/src/shards/_template/hero.json +10 -0
- package/src/shards/_template/look/entry-reads.json +20 -0
- package/src/shards/_template/manifest.json +281 -0
- package/src/shards/_template/shard.config.ts +10 -0
- package/src/shared/health.ts +10 -0
- package/src/tools/build-web.ts +59 -0
- package/src/tsconfig.json +30 -0
- package/src/web/app.tsx +53 -0
- package/src/web/index.html +12 -0
- package/src/web/main.tsx +10 -0
- package/src/web/tsconfig.json +13 -0
- package/tsconfig.author.json +23 -0
- package/tsconfig.commons.json +21 -0
- package/tsconfig.json +47 -0
- package/tsconfig.sharddev.json +20 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"""ACE-Step 1.5 bake-off generator (project/archive/2026-09-23-music.md checkpoint 2).
|
|
2
|
+
|
|
3
|
+
Runs inside the ACE-Step checkout's venv, outside this repo:
|
|
4
|
+
|
|
5
|
+
cd ~/ml/music/ace-step-1.5
|
|
6
|
+
HF_HUB_OFFLINE=1 /usr/bin/time -l uv run python \
|
|
7
|
+
<repo>/scripts/music/gen/gen_ace_step.py --dit acestep-v15-xl-sft --lm acestep-5Hz-lm-4B \
|
|
8
|
+
--styles piano,orchestral,folk --seeds 101,102,103 --out <scratch>/bakeoff-raw
|
|
9
|
+
|
|
10
|
+
Writes <out>/<style>/<tag>-<seed>.wav plus a .json sidecar (prompt, seed, model, settings, time).
|
|
11
|
+
Weights: ~/ml/music/ace-step-1.5/checkpoints/* are symlinks into ~/projects/weights/manual/ACE-Step/.
|
|
12
|
+
Apple Silicon: DiT runs on MLX (use_mlx_dit), the 5Hz LM on the mlx backend.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import argparse
|
|
18
|
+
import json
|
|
19
|
+
import os
|
|
20
|
+
import shutil
|
|
21
|
+
import subprocess
|
|
22
|
+
import sys
|
|
23
|
+
import time
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
|
|
26
|
+
HERE = Path(__file__).resolve().parent
|
|
27
|
+
ACE_ROOT = Path(os.environ.get("ACE_ROOT", Path.home() / "ml/music/ace-step-1.5"))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def git_rev(path: Path) -> str:
|
|
31
|
+
try:
|
|
32
|
+
return subprocess.check_output(["git", "-C", str(path), "rev-parse", "HEAD"], text=True).strip()
|
|
33
|
+
except Exception:
|
|
34
|
+
return "unknown"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def peak_mem_gb() -> float | None:
|
|
38
|
+
try:
|
|
39
|
+
import mlx.core as mx
|
|
40
|
+
|
|
41
|
+
fn = getattr(mx, "get_peak_memory", None) or mx.metal.get_peak_memory
|
|
42
|
+
return round(fn() / 1e9, 2)
|
|
43
|
+
except Exception:
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def main() -> None:
|
|
48
|
+
ap = argparse.ArgumentParser()
|
|
49
|
+
ap.add_argument("--dit", default="acestep-v15-xl-sft")
|
|
50
|
+
ap.add_argument("--lm", default="acestep-5Hz-lm-4B", help="'none' disables LM thinking")
|
|
51
|
+
ap.add_argument("--styles", default="piano,orchestral,folk")
|
|
52
|
+
ap.add_argument("--seeds", default="101")
|
|
53
|
+
ap.add_argument("--duration", type=float, default=None)
|
|
54
|
+
ap.add_argument("--steps", type=int, default=None)
|
|
55
|
+
ap.add_argument("--guidance", type=float, default=None)
|
|
56
|
+
ap.add_argument("--shift", type=float, default=3.0)
|
|
57
|
+
ap.add_argument("--tag", default=None, help="file-name prefix (default: derived from dit+lm)")
|
|
58
|
+
ap.add_argument("--out", required=True)
|
|
59
|
+
args = ap.parse_args()
|
|
60
|
+
|
|
61
|
+
os.chdir(ACE_ROOT)
|
|
62
|
+
sys.path.insert(0, str(ACE_ROOT))
|
|
63
|
+
from acestep.handler import AceStepHandler
|
|
64
|
+
from acestep.inference import GenerationConfig, GenerationParams, generate_music
|
|
65
|
+
from acestep.llm_inference import LLMHandler
|
|
66
|
+
|
|
67
|
+
briefs = json.loads((HERE / "briefs.json").read_text())
|
|
68
|
+
shared = briefs["shared"]
|
|
69
|
+
turbo = "turbo" in args.dit
|
|
70
|
+
steps = args.steps or (8 if turbo else 50)
|
|
71
|
+
guidance = args.guidance if args.guidance is not None else (1.0 if turbo else 7.0)
|
|
72
|
+
use_lm = args.lm != "none"
|
|
73
|
+
short = {"acestep-v15-": "", "acestep-5Hz-lm-": "lm"}
|
|
74
|
+
tag = args.tag or "ace-" + args.dit.replace("acestep-v15-", "") + ("-" + args.lm.replace("acestep-5Hz-lm-", "lm") if use_lm else "-nolm")
|
|
75
|
+
del short
|
|
76
|
+
|
|
77
|
+
t0 = time.time()
|
|
78
|
+
dit = AceStepHandler()
|
|
79
|
+
msg, ok = dit.initialize_service(project_root=str(ACE_ROOT), config_path=args.dit, device="auto", use_mlx_dit=True)
|
|
80
|
+
if not ok:
|
|
81
|
+
raise SystemExit(f"DiT init failed: {msg}")
|
|
82
|
+
llm = LLMHandler()
|
|
83
|
+
if use_lm:
|
|
84
|
+
msg, ok = llm.initialize(checkpoint_dir=str(ACE_ROOT / "checkpoints"), lm_model_path=args.lm, backend="mlx", device="auto")
|
|
85
|
+
if not ok:
|
|
86
|
+
raise SystemExit(f"LM init failed: {msg}")
|
|
87
|
+
load_s = round(time.time() - t0, 1)
|
|
88
|
+
print(f"[gen_ace_step] loaded {args.dit} + {args.lm} in {load_s}s", flush=True)
|
|
89
|
+
|
|
90
|
+
out_root = Path(args.out)
|
|
91
|
+
tmp = out_root / "_tmp_ace"
|
|
92
|
+
for style in args.styles.split(","):
|
|
93
|
+
s = briefs["styles"][style]
|
|
94
|
+
dur = args.duration or shared["duration_s"]
|
|
95
|
+
for seed in [int(x) for x in args.seeds.split(",")]:
|
|
96
|
+
dest = out_root / style / f"{tag}-{seed}.wav"
|
|
97
|
+
if dest.exists():
|
|
98
|
+
print(f"[gen_ace_step] have {dest}", flush=True)
|
|
99
|
+
continue
|
|
100
|
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
101
|
+
params = GenerationParams(
|
|
102
|
+
task_type="text2music",
|
|
103
|
+
caption=s["ace_caption"],
|
|
104
|
+
lyrics="[Instrumental]",
|
|
105
|
+
instrumental=True,
|
|
106
|
+
bpm=s["bpm"],
|
|
107
|
+
keyscale=s["key"],
|
|
108
|
+
timesignature="4",
|
|
109
|
+
duration=dur,
|
|
110
|
+
inference_steps=steps,
|
|
111
|
+
guidance_scale=guidance,
|
|
112
|
+
shift=args.shift,
|
|
113
|
+
seed=seed,
|
|
114
|
+
thinking=use_lm,
|
|
115
|
+
)
|
|
116
|
+
cfg = GenerationConfig(batch_size=1, use_random_seed=False, seeds=[seed], audio_format="wav")
|
|
117
|
+
t1 = time.time()
|
|
118
|
+
res = generate_music(dit, llm, params, cfg, save_dir=str(tmp))
|
|
119
|
+
dt = round(time.time() - t1, 1)
|
|
120
|
+
if not res.success or not res.audios:
|
|
121
|
+
print(f"[gen_ace_step] FAIL {style} {seed}: {res.error}", flush=True)
|
|
122
|
+
continue
|
|
123
|
+
a = res.audios[0]
|
|
124
|
+
shutil.move(a["path"], dest)
|
|
125
|
+
p = a.get("params", {}) or {}
|
|
126
|
+
meta = res.extra_outputs.get("lm_metadata") or {}
|
|
127
|
+
side = {
|
|
128
|
+
"model": "ACE-Step 1.5",
|
|
129
|
+
"variant": args.dit,
|
|
130
|
+
"lm": args.lm,
|
|
131
|
+
"code_commit": git_rev(ACE_ROOT),
|
|
132
|
+
"backend": "MLX (DiT + 5Hz LM)",
|
|
133
|
+
"style": style,
|
|
134
|
+
"seed": seed,
|
|
135
|
+
"prompt": s["ace_caption"],
|
|
136
|
+
"lyrics": "[Instrumental]",
|
|
137
|
+
"bpm": s["bpm"],
|
|
138
|
+
"key": s["key"],
|
|
139
|
+
"timesig": "4/4",
|
|
140
|
+
"duration_s": dur,
|
|
141
|
+
"steps": steps,
|
|
142
|
+
"guidance": guidance,
|
|
143
|
+
"shift": args.shift,
|
|
144
|
+
"gen_time_s": dt,
|
|
145
|
+
"model_load_s": load_s,
|
|
146
|
+
"mlx_peak_gb": peak_mem_gb(),
|
|
147
|
+
"lm_metadata": {k: v for k, v in meta.items() if isinstance(v, (str, int, float))} if isinstance(meta, dict) else None,
|
|
148
|
+
"resolved": {k: p.get(k) for k in ("bpm", "keyscale", "timesignature", "duration", "cot_caption") if k in p},
|
|
149
|
+
}
|
|
150
|
+
dest.with_suffix(".json").write_text(json.dumps(side, indent=2))
|
|
151
|
+
print(f"[gen_ace_step] {style} seed={seed} {dt}s -> {dest}", flush=True)
|
|
152
|
+
shutil.rmtree(tmp, ignore_errors=True)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
if __name__ == "__main__":
|
|
156
|
+
main()
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""HeartMuLa (RL-oss-3B-20260123 + HeartCodec-oss-20260123) bake-off generator, MLX port.
|
|
2
|
+
|
|
3
|
+
Runs in the heartlib-mlx checkout's venv, outside this repo:
|
|
4
|
+
|
|
5
|
+
cd ~/ml/music/heartlib-mlx
|
|
6
|
+
/usr/bin/time -l uv run python <repo>/scripts/music/gen/gen_heartmula.py \
|
|
7
|
+
--styles piano,orchestral,folk --seeds 101,102 --out <scratch>/bakeoff-raw
|
|
8
|
+
|
|
9
|
+
Same sampling loop as heartlib-mlx's generate.py (CFG batch of 2, top-k, 12.5 Hz frames), plus:
|
|
10
|
+
* a seed (mx.random.seed) so takes are reproducible;
|
|
11
|
+
* STEREO output. heartlib-mlx's HeartCodec.detokenize() averages the codec's two decoded
|
|
12
|
+
streams into mono; upstream HeartCodec returns them as the L/R channels, so this script
|
|
13
|
+
re-implements the tail of detokenize() and keeps both.
|
|
14
|
+
Weights: ckpt/ are symlinks into ~/projects/weights/manual/HeartMuLa/; ckpt-mlx/ is the MLX
|
|
15
|
+
conversion, kept in ~/projects/weights/store/heartlib-mlx/.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import argparse
|
|
21
|
+
import gc
|
|
22
|
+
import json
|
|
23
|
+
import os
|
|
24
|
+
import subprocess
|
|
25
|
+
import time
|
|
26
|
+
from pathlib import Path
|
|
27
|
+
|
|
28
|
+
HERE = Path(__file__).resolve().parent
|
|
29
|
+
HM_ROOT = Path(os.environ.get("HM_ROOT", Path.home() / "ml/music/heartlib-mlx"))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def git_rev(path: Path) -> str:
|
|
33
|
+
try:
|
|
34
|
+
return subprocess.check_output(["git", "-C", str(path), "rev-parse", "HEAD"], text=True).strip()
|
|
35
|
+
except Exception:
|
|
36
|
+
return "unknown"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def detokenize_stereo(codec, codes, duration: float, num_steps: int = 10, guidance_scale: float = 1.25):
|
|
40
|
+
import mlx.core as mx
|
|
41
|
+
|
|
42
|
+
frame_rate = codec.config.frame_rate
|
|
43
|
+
target = int(duration * frame_rate)
|
|
44
|
+
if codes.shape[1] < target:
|
|
45
|
+
pad = mx.zeros((codes.shape[0], target - codes.shape[1], codes.shape[2]), dtype=codes.dtype)
|
|
46
|
+
codes = mx.concatenate([codes, pad], axis=1)
|
|
47
|
+
codes = codes[:, :target, :]
|
|
48
|
+
lat = codec.flow_matching(codes=codes, num_steps=num_steps, guidance_scale=guidance_scale)
|
|
49
|
+
b, t, f = lat.shape
|
|
50
|
+
lat = lat.reshape(b, t, 2, f // 2).transpose(0, 2, 1, 3).reshape(b * 2, t, f // 2)
|
|
51
|
+
audio = codec.scalar_model.decode(lat) # (b*2, samples, 1)
|
|
52
|
+
audio = audio.reshape(b, 2, audio.shape[1])[:, :, : int(duration * codec.config.sample_rate)]
|
|
53
|
+
return audio[0] # (2, samples)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def main() -> None:
|
|
57
|
+
ap = argparse.ArgumentParser()
|
|
58
|
+
ap.add_argument("--styles", default="piano,orchestral,folk")
|
|
59
|
+
ap.add_argument("--seeds", default="101")
|
|
60
|
+
ap.add_argument("--duration", type=float, default=None)
|
|
61
|
+
ap.add_argument("--cfg-scale", type=float, default=1.5)
|
|
62
|
+
ap.add_argument("--temperature", type=float, default=1.0)
|
|
63
|
+
ap.add_argument("--topk", type=int, default=50)
|
|
64
|
+
ap.add_argument("--ckpt", default=str(HM_ROOT / "ckpt-mlx"))
|
|
65
|
+
ap.add_argument("--variant", default="HeartMuLa-RL-oss-3B-20260123")
|
|
66
|
+
ap.add_argument("--tag", default="heartmula-rl3b")
|
|
67
|
+
ap.add_argument("--tags-key", default="heartmula_tags", help="which briefs.json tag string to send")
|
|
68
|
+
ap.add_argument("--lyrics", default="", help='structure-only lyrics, e.g. "[intro]\\n[instrumental]\\n[outro]"')
|
|
69
|
+
ap.add_argument("--out", required=True)
|
|
70
|
+
args = ap.parse_args()
|
|
71
|
+
|
|
72
|
+
import mlx.core as mx
|
|
73
|
+
import numpy as np
|
|
74
|
+
import soundfile as sf
|
|
75
|
+
from tokenizers import Tokenizer
|
|
76
|
+
|
|
77
|
+
from heartlib_mlx.heartcodec import HeartCodec
|
|
78
|
+
from heartlib_mlx.heartmula import HeartMuLa
|
|
79
|
+
|
|
80
|
+
briefs = json.loads((HERE / "briefs.json").read_text())
|
|
81
|
+
t0 = time.time()
|
|
82
|
+
model = HeartMuLa.from_pretrained(f"{args.ckpt}/heartmula")
|
|
83
|
+
codec = HeartCodec.from_pretrained(f"{args.ckpt}/heartcodec")
|
|
84
|
+
model.set_dtype(mx.bfloat16)
|
|
85
|
+
tok = Tokenizer.from_file(str(HM_ROOT / "ckpt" / "tokenizer.json"))
|
|
86
|
+
load_s = round(time.time() - t0, 1)
|
|
87
|
+
print(f"[gen_heartmula] loaded in {load_s}s", flush=True)
|
|
88
|
+
|
|
89
|
+
bos, eos, audio_eos, ncb = 128000, 128001, 8193, 8
|
|
90
|
+
par = ncb + 1
|
|
91
|
+
fr = 12.5
|
|
92
|
+
for style in args.styles.split(","):
|
|
93
|
+
s = briefs["styles"][style]
|
|
94
|
+
dur = args.duration or briefs["shared"]["duration_s"]
|
|
95
|
+
for seed in [int(x) for x in args.seeds.split(",")]:
|
|
96
|
+
dest = Path(args.out) / style / f"{args.tag}-{seed}.wav"
|
|
97
|
+
if dest.exists():
|
|
98
|
+
print(f"[gen_heartmula] have {dest}", flush=True)
|
|
99
|
+
continue
|
|
100
|
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
101
|
+
mx.random.seed(seed)
|
|
102
|
+
mx.reset_peak_memory()
|
|
103
|
+
t1 = time.time()
|
|
104
|
+
ids = tok.encode(f"<tag>{s[args.tags_key]}</tag>".lower()).ids
|
|
105
|
+
if ids[0] != bos:
|
|
106
|
+
ids = [bos] + ids
|
|
107
|
+
if ids[-1] != eos:
|
|
108
|
+
ids = ids + [eos]
|
|
109
|
+
lyr = args.lyrics.replace("\\n", "\n")
|
|
110
|
+
lids = []
|
|
111
|
+
if lyr:
|
|
112
|
+
lids = tok.encode(lyr.lower()).ids
|
|
113
|
+
if lids[0] != bos:
|
|
114
|
+
lids = [bos] + lids
|
|
115
|
+
if lids[-1] != eos:
|
|
116
|
+
lids = lids + [eos]
|
|
117
|
+
plen = len(ids) + 1 + len(lids)
|
|
118
|
+
pt = np.zeros((plen, par), dtype=np.int64)
|
|
119
|
+
pt[: len(ids), -1] = ids
|
|
120
|
+
if lids:
|
|
121
|
+
pt[len(ids) + 1:, -1] = lids
|
|
122
|
+
pm = np.zeros((plen, par), dtype=np.float32)
|
|
123
|
+
pm[:, -1] = 1.0
|
|
124
|
+
tokens = mx.concatenate([mx.array(pt)[None]] * 2, axis=0)
|
|
125
|
+
mask = mx.concatenate([mx.array(pm)[None]] * 2, axis=0)
|
|
126
|
+
pos = mx.broadcast_to(mx.arange(plen)[None, :], (2, plen))
|
|
127
|
+
model.setup_caches(2)
|
|
128
|
+
cur = model.generate_frame(
|
|
129
|
+
tokens=tokens, tokens_mask=mask, input_pos=pos, temperature=args.temperature, topk=args.topk,
|
|
130
|
+
cfg_scale=args.cfg_scale, continuous_segments=mx.zeros((2, model.config.muq_dim)), starts=[len(ids), len(ids)],
|
|
131
|
+
)
|
|
132
|
+
mx.eval(cur)
|
|
133
|
+
frames = [cur[0:1]]
|
|
134
|
+
nmax = int(dur * fr)
|
|
135
|
+
eos_at = None
|
|
136
|
+
for i in range(nmax - 1):
|
|
137
|
+
padded = mx.concatenate([cur[:, None, :], mx.zeros((2, 1, 1), dtype=mx.int32)], axis=-1)
|
|
138
|
+
pmask = mx.concatenate([mx.ones((2, 1, ncb)), mx.zeros((2, 1, 1))], axis=-1)
|
|
139
|
+
cur = model.generate_frame(
|
|
140
|
+
tokens=padded, tokens_mask=pmask, input_pos=pos[:, -1:] + i + 1,
|
|
141
|
+
temperature=args.temperature, topk=args.topk, cfg_scale=args.cfg_scale,
|
|
142
|
+
)
|
|
143
|
+
mx.eval(cur)
|
|
144
|
+
if (i + 1) % 25 == 0:
|
|
145
|
+
mx.clear_cache()
|
|
146
|
+
gc.collect()
|
|
147
|
+
if mx.any(cur[0] >= audio_eos).item():
|
|
148
|
+
eos_at = i + 1
|
|
149
|
+
break
|
|
150
|
+
frames.append(cur[0:1])
|
|
151
|
+
gen_s = time.time() - t1
|
|
152
|
+
codes = mx.concatenate(frames, axis=0)[None]
|
|
153
|
+
got = len(frames) / fr
|
|
154
|
+
audio = detokenize_stereo(codec, codes, duration=got)
|
|
155
|
+
mx.eval(audio)
|
|
156
|
+
wav = np.array(audio.astype(mx.float32)).T # (samples, 2)
|
|
157
|
+
sf.write(str(dest), wav, codec.config.sample_rate)
|
|
158
|
+
dt = round(time.time() - t1, 1)
|
|
159
|
+
side = {
|
|
160
|
+
"model": "HeartMuLa",
|
|
161
|
+
"variant": args.variant,
|
|
162
|
+
"codec": "HeartCodec-oss-20260123",
|
|
163
|
+
"code_commit": "heartlib-mlx " + git_rev(HM_ROOT),
|
|
164
|
+
"backend": "MLX (heartlib-mlx port, bf16 LM, fp32 codec)",
|
|
165
|
+
"style": style,
|
|
166
|
+
"seed": seed,
|
|
167
|
+
"prompt": s[args.tags_key],
|
|
168
|
+
"lyrics": lyr,
|
|
169
|
+
"duration_s": round(got, 2),
|
|
170
|
+
"requested_s": dur,
|
|
171
|
+
"early_eos_frame": eos_at,
|
|
172
|
+
"cfg_scale": args.cfg_scale,
|
|
173
|
+
"temperature": args.temperature,
|
|
174
|
+
"topk": args.topk,
|
|
175
|
+
"gen_time_s": dt,
|
|
176
|
+
"lm_time_s": round(gen_s, 1),
|
|
177
|
+
"model_load_s": load_s,
|
|
178
|
+
"mlx_peak_gb": round(mx.get_peak_memory() / 1e9, 2),
|
|
179
|
+
"note": "no BPM/key conditioning in HeartMuLa - tags only",
|
|
180
|
+
}
|
|
181
|
+
dest.with_suffix(".json").write_text(json.dumps(side, indent=2))
|
|
182
|
+
print(f"[gen_heartmula] {style} seed={seed} {dt}s ({got:.1f}s audio) -> {dest}", flush=True)
|
|
183
|
+
model.reset_caches()
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
if __name__ == "__main__":
|
|
187
|
+
main()
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""MiniMax Music 3 bake-off generator (diffusers ModularPipeline on PyTorch MPS).
|
|
2
|
+
|
|
3
|
+
Runs in its own venv (diffusers 0.40.0 carries the pipeline), outside this repo:
|
|
4
|
+
|
|
5
|
+
~/ml/music/minimax-music3/.venv/bin/python <repo>/scripts/music/gen/gen_minimax.py \
|
|
6
|
+
--styles piano --seeds 101,102 --out <scratch>/bakeoff-raw
|
|
7
|
+
|
|
8
|
+
The model card says "Inference requires CUDA"; that means "only tested on CUDA". Porting notes:
|
|
9
|
+
* weights load from ~/projects/weights/manual/MiniMaxAI/MiniMax-Music3 through a symlink view whose
|
|
10
|
+
modular_model_index.json points every component at the local dir (the published one names the
|
|
11
|
+
hub repo, so from_pretrained on the plain dir would reach for the network);
|
|
12
|
+
* everything runs on "mps" in bf16 (the 8B Qwen3 global LM alone is ~16 GB in bf16);
|
|
13
|
+
* the generator is a CPU torch.Generator - the pipeline samples top-k tokens on the generator's device,
|
|
14
|
+
which also keeps seeds device-independent.
|
|
15
|
+
Licence: MiniMax-Music3 Community License - commercial use allowed, "MiniMax-Music3" must be displayed in the
|
|
16
|
+
product UI, written authorisation needed above USD 20M yearly revenue.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import argparse
|
|
22
|
+
import json
|
|
23
|
+
import os
|
|
24
|
+
import time
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
|
|
27
|
+
HERE = Path(__file__).resolve().parent
|
|
28
|
+
SRC = Path(os.environ.get("MINIMAX_WEIGHTS", Path.home() / "projects/weights/manual/MiniMaxAI/MiniMax-Music3"))
|
|
29
|
+
VIEW = Path(os.environ.get("MINIMAX_VIEW", Path.home() / "ml/music/minimax-music3/model-view"))
|
|
30
|
+
LYRICS = "[Intro]\n[Instrumental]\n[Solo]\n[Instrumental]\n[Outro]"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def build_view() -> Path:
|
|
34
|
+
"""Zero-byte view of the weight store with a local-path modular_model_index.json."""
|
|
35
|
+
VIEW.mkdir(parents=True, exist_ok=True)
|
|
36
|
+
for p in SRC.rglob("*"):
|
|
37
|
+
if p.is_dir() or p.name == "modular_model_index.json" or "qwen_7B" in p.parts:
|
|
38
|
+
continue
|
|
39
|
+
dst = VIEW / p.relative_to(SRC)
|
|
40
|
+
dst.parent.mkdir(parents=True, exist_ok=True)
|
|
41
|
+
if not dst.is_symlink():
|
|
42
|
+
dst.symlink_to(p)
|
|
43
|
+
idx = json.loads((SRC / "modular_model_index.json").read_text())
|
|
44
|
+
for k, v in idx.items():
|
|
45
|
+
if isinstance(v, list) and len(v) == 3 and isinstance(v[2], dict) and "pretrained_model_name_or_path" in v[2]:
|
|
46
|
+
v[2]["pretrained_model_name_or_path"] = str(VIEW)
|
|
47
|
+
(VIEW / "modular_model_index.json").write_text(json.dumps(idx, indent=2))
|
|
48
|
+
return VIEW
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def main() -> None:
|
|
52
|
+
ap = argparse.ArgumentParser()
|
|
53
|
+
ap.add_argument("--styles", default="piano,orchestral,folk")
|
|
54
|
+
ap.add_argument("--seeds", default="101")
|
|
55
|
+
ap.add_argument("--duration", type=float, default=None)
|
|
56
|
+
ap.add_argument("--steps", type=int, default=30)
|
|
57
|
+
ap.add_argument("--tag", default="minimax3")
|
|
58
|
+
ap.add_argument("--out", required=True)
|
|
59
|
+
ap.add_argument("--jobs", default=None, help="v3 jobs file (v3-jobs.json); renders --keys instead of --styles")
|
|
60
|
+
ap.add_argument("--keys", default="", help="comma-separated job keys, e.g. piano/pine,piano/island")
|
|
61
|
+
args = ap.parse_args()
|
|
62
|
+
|
|
63
|
+
os.environ.setdefault("HF_HUB_OFFLINE", "1")
|
|
64
|
+
import soundfile as sf
|
|
65
|
+
import torch
|
|
66
|
+
from diffusers import ModularPipeline
|
|
67
|
+
|
|
68
|
+
dev = "mps" if torch.backends.mps.is_available() else "cpu"
|
|
69
|
+
view = build_view()
|
|
70
|
+
t0 = time.time()
|
|
71
|
+
pipe = ModularPipeline.from_pretrained(str(view))
|
|
72
|
+
pipe.load_components(dtype=torch.bfloat16)
|
|
73
|
+
if os.environ.get("MINIMAX_OFFLOAD"):
|
|
74
|
+
# memory cap (the user: "don't hammer the machine's memory"): the 8B global LM (~16 GB bf16) streams from
|
|
75
|
+
# disk one leaf module at a time (diffusers group offloading); everything else sits on the device
|
|
76
|
+
from diffusers.hooks import apply_group_offloading
|
|
77
|
+
|
|
78
|
+
off = Path(os.environ.get("MINIMAX_OFFLOAD_DIR", Path.home() / "ml/music/minimax-music3/offload"))
|
|
79
|
+
off.mkdir(parents=True, exist_ok=True)
|
|
80
|
+
for name in pipe.components:
|
|
81
|
+
comp = getattr(pipe, name, None)
|
|
82
|
+
if isinstance(comp, torch.nn.Module) and name != "language_model":
|
|
83
|
+
comp.to(dev)
|
|
84
|
+
apply_group_offloading(pipe.language_model, onload_device=torch.device(dev), offload_device=torch.device("cpu"),
|
|
85
|
+
offload_type="leaf_level", offload_to_disk_path=str(off)) # leaf: the AR loop calls embed_tokens / lm_head directly
|
|
86
|
+
else:
|
|
87
|
+
pipe.to(dev)
|
|
88
|
+
load_s = round(time.time() - t0, 1)
|
|
89
|
+
print(f"[gen_minimax] loaded on {dev} in {load_s}s", flush=True)
|
|
90
|
+
briefs = json.loads((HERE / "briefs.json").read_text())
|
|
91
|
+
import diffusers
|
|
92
|
+
|
|
93
|
+
# one work list for both modes: (folder, style, slot, prompt, lyrics, duration)
|
|
94
|
+
work = []
|
|
95
|
+
if args.jobs:
|
|
96
|
+
jf = json.loads((HERE / args.jobs).read_text() if not Path(args.jobs).is_absolute() else Path(args.jobs).read_text())
|
|
97
|
+
for key in [k for k in args.keys.split(",") if k]:
|
|
98
|
+
j = jf["jobs"][key]
|
|
99
|
+
work.append((key.replace("/", "-"), j["style"], j["slot"], j["prompt"], jf["lyrics"][j["lyrics"]],
|
|
100
|
+
args.duration or j["duration"]))
|
|
101
|
+
else:
|
|
102
|
+
for style in args.styles.split(","):
|
|
103
|
+
s = briefs["styles"][style]
|
|
104
|
+
work.append((style, style, None, s["minimax_prompt"], LYRICS, args.duration or briefs["shared"]["duration_s"]))
|
|
105
|
+
|
|
106
|
+
for folder, style, slot, prompt, lyrics, dur in work:
|
|
107
|
+
for seed in [int(x) for x in args.seeds.split(",")]:
|
|
108
|
+
dest = Path(args.out) / folder / f"{args.tag}-{seed}.wav"
|
|
109
|
+
if dest.exists():
|
|
110
|
+
print(f"[gen_minimax] have {dest}", flush=True)
|
|
111
|
+
continue
|
|
112
|
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
113
|
+
t1 = time.time()
|
|
114
|
+
audio = pipe(prompt=prompt, lyrics=lyrics, audio_duration=dur, num_inference_steps=args.steps,
|
|
115
|
+
generator=torch.Generator("cpu").manual_seed(seed), output="audios")[0]
|
|
116
|
+
import numpy as np
|
|
117
|
+
|
|
118
|
+
wav = np.asarray(audio.float().cpu().numpy() if hasattr(audio, "cpu") else audio, dtype=np.float32)
|
|
119
|
+
wav = wav.T if wav.ndim == 2 and wav.shape[0] in (1, 2) else wav
|
|
120
|
+
sf.write(str(dest), wav, pipe.sampling_rate)
|
|
121
|
+
dt = round(time.time() - t1, 1)
|
|
122
|
+
side = {
|
|
123
|
+
"model": "MiniMax Music 3",
|
|
124
|
+
"variant": "MiniMaxAI/MiniMax-Music3 (8B global LM + 0.6B local LM + 2.4B flow-matching DiT)",
|
|
125
|
+
"code_commit": f"diffusers {diffusers.__version__}, torch {torch.__version__}",
|
|
126
|
+
"backend": f"PyTorch {dev} bf16",
|
|
127
|
+
"style": style,
|
|
128
|
+
"slot": slot,
|
|
129
|
+
"seed": seed,
|
|
130
|
+
"prompt": prompt,
|
|
131
|
+
"lyrics": lyrics,
|
|
132
|
+
"duration_s": dur,
|
|
133
|
+
"steps": args.steps,
|
|
134
|
+
"gen_time_s": dt,
|
|
135
|
+
"model_load_s": load_s,
|
|
136
|
+
"mps_driver_gb": round(torch.mps.driver_allocated_memory() / 1e9, 2) if dev == "mps" else None,
|
|
137
|
+
}
|
|
138
|
+
dest.with_suffix(".json").write_text(json.dumps(side, indent=2))
|
|
139
|
+
print(f"[gen_minimax] {folder} seed={seed} {dt}s -> {dest}", flush=True)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
if __name__ == "__main__":
|
|
143
|
+
main()
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""Stable Audio Open 1.0 bake-off generator (diffusers StableAudioPipeline on PyTorch MPS).
|
|
2
|
+
|
|
3
|
+
Runs in its own venv, outside this repo:
|
|
4
|
+
|
|
5
|
+
~/ml/music/stable-audio-open/.venv/bin/python <repo>/scripts/music/gen/gen_sao.py \
|
|
6
|
+
--styles piano,orchestral,folk --seeds 101,102 --out <scratch>/bakeoff-raw
|
|
7
|
+
|
|
8
|
+
SAO 1.0 is capped at 47.55 s per generation (its training window), so these takes are 47 s, not 75 s.
|
|
9
|
+
Weights: ~/projects/weights/manual/AEmotionStudio/stable-audio-open-models, an ungated mirror of
|
|
10
|
+
stabilityai/stable-audio-open-1.0 (the official repo is gated behind an HF login + licence click).
|
|
11
|
+
Licence: Stability AI Community License (free below USD 1M annual revenue).
|
|
12
|
+
No MLX port exists for SAO, so this is the MPS path.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import argparse
|
|
18
|
+
import json
|
|
19
|
+
import os
|
|
20
|
+
import time
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
HERE = Path(__file__).resolve().parent
|
|
24
|
+
SAO = Path(os.environ.get("SAO_WEIGHTS", Path.home() / "projects/weights/manual/AEmotionStudio/stable-audio-open-models"))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def patch_brownian_noise_for_mps() -> None:
|
|
28
|
+
"""SAO's CosineDPMSolverMultistepScheduler draws SDE noise from a torchsde BrownianInterval over
|
|
29
|
+
[sigma_min, sigma_max] = [0.3, 500]. On the LAST step sigma = float32(0.3) = 0.30000001 and sigma_next = 0,
|
|
30
|
+
below the tree's t0: torchsde's interval search then recurses until `RecursionError: maximum recursion
|
|
31
|
+
depth exceeded` (brownian_interval._split). Seen first on MPS, reproduced on CPU with the scheduler alone.
|
|
32
|
+
Fix: build the tree on the CPU in float64 with plain-float times, clamp times into [sigma_min, sigma_max],
|
|
33
|
+
and return zero noise for an interval narrower than 1e-5 (the tree's tol is 1e-6). Noise comes back float32.
|
|
34
|
+
"""
|
|
35
|
+
import torch
|
|
36
|
+
from diffusers.schedulers import scheduling_cosine_dpmsolver_multistep as cos
|
|
37
|
+
from diffusers.schedulers.scheduling_dpmsolver_sde import BatchedBrownianTree
|
|
38
|
+
|
|
39
|
+
class CpuBrownianTreeNoiseSampler:
|
|
40
|
+
def __init__(self, x, sigma_min, sigma_max, seed=None, transform=lambda v: v):
|
|
41
|
+
self.lo, self.hi = float(sigma_min), float(sigma_max)
|
|
42
|
+
self.shape = x.shape
|
|
43
|
+
self.tree = BatchedBrownianTree(x.detach().to("cpu", torch.float64), self.lo, self.hi, seed)
|
|
44
|
+
|
|
45
|
+
def __call__(self, sigma, sigma_next):
|
|
46
|
+
t0 = min(max(float(sigma), self.lo), self.hi)
|
|
47
|
+
t1 = min(max(float(sigma_next), self.lo), self.hi)
|
|
48
|
+
if abs(t1 - t0) < 1e-5: # below torchsde tol=1e-6 the interval search never ends
|
|
49
|
+
return torch.zeros(self.shape)
|
|
50
|
+
return (self.tree(t0, t1) / abs(t1 - t0) ** 0.5).float()
|
|
51
|
+
|
|
52
|
+
cos.BrownianTreeNoiseSampler = CpuBrownianTreeNoiseSampler
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def main() -> None:
|
|
56
|
+
ap = argparse.ArgumentParser()
|
|
57
|
+
ap.add_argument("--styles", default="piano,orchestral,folk")
|
|
58
|
+
ap.add_argument("--seeds", default="101")
|
|
59
|
+
ap.add_argument("--seconds", type=float, default=47.0)
|
|
60
|
+
ap.add_argument("--steps", type=int, default=100)
|
|
61
|
+
ap.add_argument("--cfg", type=float, default=7.0)
|
|
62
|
+
ap.add_argument("--dtype", default="float32", choices=["float32", "float16"])
|
|
63
|
+
ap.add_argument("--tag", default="sao1.0")
|
|
64
|
+
ap.add_argument("--out", required=True)
|
|
65
|
+
args = ap.parse_args()
|
|
66
|
+
|
|
67
|
+
import soundfile as sf
|
|
68
|
+
import torch
|
|
69
|
+
from diffusers import StableAudioPipeline
|
|
70
|
+
|
|
71
|
+
dev = "mps" if torch.backends.mps.is_available() else "cpu"
|
|
72
|
+
dtype = torch.float16 if args.dtype == "float16" else torch.float32
|
|
73
|
+
if dev == "mps":
|
|
74
|
+
patch_brownian_noise_for_mps()
|
|
75
|
+
briefs = json.loads((HERE / "briefs.json").read_text())
|
|
76
|
+
t0 = time.time()
|
|
77
|
+
pipe = StableAudioPipeline.from_pretrained(str(SAO), torch_dtype=dtype).to(dev)
|
|
78
|
+
load_s = round(time.time() - t0, 1)
|
|
79
|
+
print(f"[gen_sao] loaded on {dev} in {load_s}s", flush=True)
|
|
80
|
+
sr = pipe.vae.sampling_rate
|
|
81
|
+
|
|
82
|
+
for style in args.styles.split(","):
|
|
83
|
+
s = briefs["styles"][style]
|
|
84
|
+
for seed in [int(x) for x in args.seeds.split(",")]:
|
|
85
|
+
dest = Path(args.out) / style / f"{args.tag}-{seed}.wav"
|
|
86
|
+
if dest.exists():
|
|
87
|
+
print(f"[gen_sao] have {dest}", flush=True)
|
|
88
|
+
continue
|
|
89
|
+
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
90
|
+
if dev == "mps":
|
|
91
|
+
torch.mps.reset_peak_memory_stats() if hasattr(torch.mps, "reset_peak_memory_stats") else None
|
|
92
|
+
t1 = time.time()
|
|
93
|
+
g = torch.Generator("cpu").manual_seed(seed)
|
|
94
|
+
audio = pipe(
|
|
95
|
+
s["sao_prompt"], negative_prompt=s["sao_negative"], num_inference_steps=args.steps,
|
|
96
|
+
guidance_scale=args.cfg, audio_end_in_s=args.seconds, num_waveforms_per_prompt=1, generator=g,
|
|
97
|
+
).audios[0]
|
|
98
|
+
wav = audio.float().cpu().numpy().T
|
|
99
|
+
sf.write(str(dest), wav, sr)
|
|
100
|
+
dt = round(time.time() - t1, 1)
|
|
101
|
+
side = {
|
|
102
|
+
"model": "Stable Audio Open",
|
|
103
|
+
"variant": "stable-audio-open-1.0 (mirror AEmotionStudio/stable-audio-open-models)",
|
|
104
|
+
"code_commit": "diffusers " + __import__("diffusers").__version__ + ", torch " + torch.__version__,
|
|
105
|
+
"backend": f"PyTorch {dev} ({args.dtype})",
|
|
106
|
+
"style": style,
|
|
107
|
+
"seed": seed,
|
|
108
|
+
"prompt": s["sao_prompt"],
|
|
109
|
+
"negative_prompt": s["sao_negative"],
|
|
110
|
+
"duration_s": args.seconds,
|
|
111
|
+
"steps": args.steps,
|
|
112
|
+
"cfg": args.cfg,
|
|
113
|
+
"gen_time_s": dt,
|
|
114
|
+
"model_load_s": load_s,
|
|
115
|
+
"mps_driver_gb": round(torch.mps.driver_allocated_memory() / 1e9, 2) if dev == "mps" else None,
|
|
116
|
+
}
|
|
117
|
+
dest.with_suffix(".json").write_text(json.dumps(side, indent=2))
|
|
118
|
+
print(f"[gen_sao] {style} seed={seed} {dt}s -> {dest}", flush=True)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
if __name__ == "__main__":
|
|
122
|
+
main()
|