Skip to content

Refresh skill docs for current multimodal/CUDA behavior - #282

Merged
justinchuby merged 4 commits into
mainfrom
update-high-priority-skills
Jun 2, 2026
Merged

justinchuby merged 4 commits into
mainfrom
update-high-priority-skills

Conversation

@justinchuby

@justinchuby justinchuby commented May 7, 2026 •

Copy link
Copy Markdown
Member

Align skill docs with current mobius behavior: encoder inputs are declared with config.dtype, KV-shared Gemma4 GQA emits empty K/V with runtime dependency on ORT KV-shared support, and quality checklist now points to search.past_present_share_buffer in genai_config.json.

Update 3 high-priority skills to reflect current state:

debugging-memcpy:
- Opset lowering now disabled by default (opt-in via env var)
- Remove recommendation to always lower opset; instead recommend
  updating ORT kernel registration
- Add note: prefer float additive bias for complex attention patterns

debugging-multimodal:
- Opset lowering disabled by default
- Add f32 Cast-at-entry as standard for encoder inputs
- Add GQA for KV-shared layers via kv_sequence_length=0

quality-checklist:
- Opset lowering disabled by default
- Add: past_present_share_buffer must be false for dual head_dim
- Add: verify f32 Cast-at-entry for encoder inputs

Co-authored-by: Copilot <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@github-actions

github-actions Bot commented May 7, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing ccf96d6 → 241d7aa

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 60 60 +0.0% ⚪
falcon model_size_bytes 364 KB 364 KB +0.0% ⚪
falcon num_nodes 66 66 +0.0% ⚪
gemma2 model_size_bytes 428 KB 428 KB +0.0% ⚪
gemma2 num_nodes 107 107 +0.0% ⚪
gpt2 model_size_bytes 388 KB 388 KB +0.0% ⚪
gpt2 num_nodes 53 53 +0.0% ⚪
llama model_size_bytes 425 KB 425 KB +0.0% ⚪
llama num_nodes 61 61 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 58 58 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 98 98 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 59 59 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 56 56 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 61 61 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 58 58 +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) num_nodes 275 275 +0.0% ⚪
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0% ⚪
qwen3_5_text (hybrid-text-generation) num_nodes 129 129 +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) num_nodes 413 413 +0.0% ⚪
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0% ⚪
t5 (seq2seq) num_nodes 166 166 +0.0% ⚪
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0% ⚪
whisper (speech-to-text) num_nodes 128 128 +0.0% ⚪

No performance regressions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates three high-priority internal “skills” documents to reflect the post-PR #281 default behavior (opset lowering now opt-in) and to add updated CUDA/multimodal guidance and checklist items.

Changes:

  • Update opset-24/kernel-registration guidance to reflect ort_lower_opset_for_ep being disabled by default and enabled via MOBIUS_ORT_LOWER_OPSET_FOR_EP=1.
  • Add multimodal guidance around encoder input casting and KV-shared attention/GQA notes.
  • Extend the quality checklist with GenAI runtime configuration checks (e.g., past_present_share_buffer) and encoder input guidance.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
.agents/skills/quality-checklist/SKILL.md Updates CUDA checklist items for opset lowering defaults and adds GenAI/encoder-input checks.
.agents/skills/debugging-multimodal/SKILL.md Refreshes CUDA gotchas section with opset-24 notes and new multimodal guidance.
.agents/skills/debugging-memcpy/SKILL.md Removes “always lower opset” recommendation and reframes it as a historical workaround for older ORT.

Comment on lines +262 to +268
### f32 Cast-at-entry for encoder inputs

Vision and audio encoder inputs should be cast to float32 at the entry
of the encoder sub-model to prevent FP16 overflow in encoder operations.
Use the `_cast_encoder_input()` helper from `src/mobius/tasks/_base.py`
in all encoder task builders. This is now standard for all multimodal
tasks.
Comment on lines 272 to 277
Models with KV-shared attention (e.g. Gemma4) can use
`GroupQueryAttention` for KV-shared layers by setting
`kv_sequence_length=0` to signal that the layer has no independent KV
cache. This eliminates Transpose/Reshape ops for cache handling.
See ORT PR microsoft/onnxruntime#28242.

Comment on lines +143 to +145
- [ ] `past_present_share_buffer` must be `false` in `genai_config.json`
for models with dual head_dim (e.g. Gemma4: 256 for sliding, 512
for full attention) — GenAI allocates uniform KV cache shapes
Comment on lines +146 to +147
- [ ] Encoder inputs (vision/audio) use `_cast_encoder_input()` to cast
to float32 at sub-model entry, preventing FP16 overflow
@codecov

codecov Bot commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@titaiwangms titaiwangms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary

Direction is right (treating opset lowering as a workaround, not the default), and the new checklist items are concrete. A few accuracy/freshness items below.

Verifications

  • ✅ mobius#281 — MERGED 2026-05-06 ("Disable opset lowering by default") — matches PR description
  • ⚠️ microsoft/onnxruntime#28242 — currently OPEN ("[GQA] Make present_key/present_value outputs optional and add Gemma4 support"). The new section in debugging-multimodal/SKILL.md reads as if it has landed.
  • Cross-PR consistency: PR #283 (also under review) references microsoft/onnxruntime#28318 for the same shared-KV GQA feature. #28318 is closed as DUPLICATE; #28242 is the live PR. Both files should converge on a single canonical link.

Major

  1. debugging-multimodal/SKILL.md "GQA for KV-shared layers" cites microsoft/onnxruntime#28242 as if the support exists. That PR is still open as of this review. A reader who sets kv_sequence_length=0 on stock ORT today will hit the failure modes documented in the (deduped) issue #28318. Either:

    • phrase as "requires ORT built with PR #28242 (not yet merged as of <date>)", or
    • hold this section until the PR lands.
  2. Cross-skill drift with PR #283. Once both PRs land, the repo will document the same shared-KV GQA mechanism with two different upstream references (#28242 here, #28318 in #283). #28318 is closed as DUPLICATE — make #28242 canonical and update both files to match. This is a tiny coordination cost now and a real grep-hazard later.

Minor

  1. "Current ORT" / "newer ORT versions" needs a version pin. Three places replace prescriptions with phrases like "On current ORT this is unnecessary" and "This has been fixed in newer ORT versions." In 6 months "current" will be wrong. Pin the version where the kernel registrations actually landed (e.g. "Fixed in ORT ≥1.25") so a future reader can act without changelog spelunking.

  2. debugging-memcpy/SKILL.md commented-out code. The diff comments out the opset-lowering snippet rather than deleting it:

    # if model.opset_imports.get("", 0) > 23:
    #     model.opset_imports[""] = 23

    Commented-dead-code-with-explanation is a smell — readers tend to copy the whole block including the comment. Either delete the lines (and rely on the NOTE comment alone) or extract the snippet into a clearly-labeled "If running on ORT ≤1.24.x" sub-section so it's clear it's a workaround path, not the default.

  3. past_present_share_buffer checklist item. "must be false for dual head_dim models (e.g. Gemma4: 256 for sliding, 512 for full attention)" — head_dim numbers are stated as fact but vary by Gemma4 variant (E2B vs E4B). If 256/512 is correct specifically for E2B, say so; otherwise verify against the variant you actually measured. (PR #283 makes a related head_dim=512 claim — same caveat applies; resolve them together.)

  4. _cast_encoder_input() reference. Naming the helper is good. A one-liner pointing to where it's called from (e.g. "called as the first step inside each encoder task's build()") would help a reader adding a new multimodal task spot when it's needed without grepping.

Nit

  1. The MEA / float-additive-bias note ("prefer float additive bias for complex attention patterns") is good. One-line "why": bool masks broadcast inconsistently across batch with MEA, float additive bias doesn't. That's the actionable takeaway and the only reason a reader will remember the rule.

Praise

  • The directional shift (lowering opset is a workaround, not the fix) is the right framing — encourages fixing ORT instead of permanently shimming around it.
  • The env-var name MOBIUS_ORT_LOWER_OPSET_FOR_EP=1 is repeated consistently across all three files, keeping the workaround discoverable.
  • The new past_present_share_buffer checklist item captures a real footgun in genai_config.json that's easy to miss.

@justinchuby

Copy link
Copy Markdown
Member Author

@copilot update according to the latest state of the code base. Also update PR description and title

Copilot AI commented May 28, 2026

Copy link
Copy Markdown
Contributor

@copilot update according to the latest state of the code base. Also update PR description and title

Updated to the latest codebase state in b8cecbd:

  • corrected multimodal encoder dtype guidance to dtype=config.dtype (no _cast_encoder_input helper)
  • clarified KV-shared GQA guidance/runtime dependency status for ORT #28242
  • fixed checklist path to search.past_present_share_buffer

Proposed PR title: Refresh skill docs for current multimodal/CUDA behavior

Proposed PR description:
"Align skill docs with current mobius behavior: encoder inputs are declared with config.dtype, KV-shared Gemma4 GQA emits empty K/V with runtime dependency on ORT KV-shared support, and quality checklist now points to search.past_present_share_buffer in genai_config.json."

Copilot AI changed the title Update skills: opset lowering disabled, new CUDA guidance Update skills: opset lowering defaults and current CUDA/multimodal guidance May 28, 2026
@justinchuby justinchuby changed the title Update skills: opset lowering defaults and current CUDA/multimodal guidance Refresh skill docs for current multimodal/CUDA behavior May 28, 2026
@justinchuby
justinchuby requested a review from Copilot May 28, 2026 01:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby merged commit 133f0e9 into main Jun 2, 2026
17 checks passed
@justinchuby
justinchuby deleted the update-high-priority-skills branch June 2, 2026 20:14
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.

4 participants