Skip to content

fix: resolve lego task instruction mismatch causing noise output#925

Merged
ChuxiJ merged 2 commits intomainfrom
fix/lego-instruction-mismatch
Mar 21, 2026
Merged

fix: resolve lego task instruction mismatch causing noise output#925
ChuxiJ merged 2 commits intomainfrom
fix/lego-instruction-mismatch

Conversation

@ChuxiJ
Copy link
Contributor

@ChuxiJ ChuxiJ commented Mar 21, 2026

Summary

  • Fix _resolve_instruction() to fall back to task-specific instruction when the instruction field is empty/blank, not just when it exactly matches DEFAULT_DIT_INSTRUCTION.
  • Register "instruction" in PARAM_ALIASES for explicit form-data parsing.

Root Cause

The lego task was generating noise because the DiT model received the wrong instruction text during inference. The model was trained with "Generate the {TRACK_NAME} track based on the audio context:" but inference was using "Fill the audio semantic mask based on the given conditions:" (the default text2music instruction).

_resolve_instruction() only substituted the task-specific instruction when req.instruction == DEFAULT_DIT_INSTRUCTION. If the instruction field arrived as an empty string from the client form data, it would not match the default and would pass through unchanged — resulting in the wrong instruction reaching the model.

Verification

Before fix: Peak=0.0045 (noise)
After fix: Peak=1.0000 (normal audio signal)

Test plan

  • Existing job_generation_setup_test.py tests pass (4/4)
  • Server restart and manual lego task request confirms correct instruction in logs
  • DAW client lego generation (from silence + from context) produces audible music instead of noise

Made with Cursor

Summary by CodeRabbit

  • New Features

    • Instruction parameter is now supported in API requests.
  • Bug Fixes

    • Improved instruction resolution to handle missing or empty instruction values by falling back to task-specific defaults.

The lego task was generating noise because _resolve_instruction() only
fell back to the task-specific instruction when the request instruction
exactly matched DEFAULT_DIT_INSTRUCTION. When the instruction field
arrived as empty/blank (e.g. lost in form parsing), it would not match
the default and the wrong instruction was passed to the DiT model.

The model was trained with "Generate the {TRACK_NAME} track based on
the audio context:" but received "Fill the audio semantic mask based
on the given conditions:", causing it to produce garbage output.

Changes:
- Widen _resolve_instruction() to also trigger on empty/blank
  instruction values, not just exact default matches.
- Register "instruction" in PARAM_ALIASES for explicit form parsing.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 21, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Added an "instruction" parameter alias to the request parameter parser, enabling direct retrieval of instruction values from requests. Updated instruction resolution logic to handle missing or blank instructions alongside exact default instruction matches, broadening fallback behavior when task types are present.

Changes

Cohort / File(s) Summary
Parameter Alias Mapping
acestep/api/http/release_task_param_parser.py
Added "instruction": ["instruction"] entry to PARAM_ALIASES to enable canonical request parameter alias lookup for instruction values.
Instruction Resolution Logic
acestep/api/job_generation_setup.py
Modified _resolve_instruction to replace instructions when missing, blank (after stripping), or exactly matching default_dit_instruction, requiring req.task_type to exist in task_instructions. Previously only replaced on exact default match.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A whispered instruction, now properly named,
Parameter alias—no longer unnamed,
When blanks and defaults align just right,
The task instructions shine ever so bright!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: fixing instruction mismatch in lego task that was causing noise output, which is the core issue addressed across both modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/lego-instruction-mismatch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can enable review details to help with troubleshooting, context usage and more.

Enable the reviews.review_details setting to include review details such as the model used, the time taken for each step and more in the review comments.

@ChuxiJ ChuxiJ merged commit 1dceeb0 into main Mar 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant