feat: add local Qwen3-Omni API and fine-tune regression - #318
Conversation
* swap Qwen3-Omni dataset generation to load Hugging Face checkpoints locally and wire up tests/ docs * ensure AGENTS.md/CLAUDE.md stay untracked * add a lightweight GPT-2 fine-tuning test that asserts weights actually change
5c816ba to
0c28182
Compare
| self.tokenizer = AutoTokenizer.from_pretrained( | ||
| model_name_or_path, trust_remote_code=True, **tokenizer_kwargs | ||
| ) | ||
| self.model = AutoModelForCausalLM.from_pretrained( |
There was a problem hiding this comment.
It doesn't look correct. I don't think AutoModelForCausalLM is supported for this model. Just try AutoModelForMultimodalLM
There was a problem hiding this comment.
I've made the suggested changes.
d091dfa to
5fde77e
Compare
chore: apply autoflake/isort fixes style: apply black formatting
5fde77e to
cdd5de9
Compare
# Conflicts: # README.md # examples/README.md # tests/xturing/models/test_gpt2_model.py
`AutoModelForMultimodalLM` was added in transformers 5.0.0. Importing it at module scope made `xturing.model_apis` unimportable on every 4.x release, and that package is pulled in by `xturing.datasets.instruction_dataset`, so the documented `from xturing.datasets import InstructionDataset` quickstart raised ImportError. Guard the import the way ClaudeTextGenerationAPI guards `anthropic`, but catch ImportError rather than ModuleNotFoundError: transformers is installed, only the symbol is absent. Construction now raises an actionable error naming the required version. Tests drop `raising=False` so a missing or renamed symbol fails loudly, and cover both the graceful import and the error path.
Review findingsRe-reviewed against current The rebase is a non-issue. Merge base is Blocking1. The API is unreachable on a supported install. Also worth double-checking that 2. 3. The "fine-tune regression" in the title never runs. Two independent gates: The bigger miss is the 6 Qwen tests — they're mocked, CPU-only, fast, dependency-light, and would be a genuinely cheap CI addition. #343 adds a 4. Pad tokens aren't masked in the PEFT example. Non-blocking
Verified fine
|
* test(model_apis): make anthropic error construction version-independent The helper passed response=/body= to every SDK error class, but anthropic's signatures diverge (APIError takes request, RateLimitError takes response), so the suite only worked against one SDK release. It failed outright on anthropic 1.2.0 with 'APIError.__init__() got an unexpected keyword argument response'. This went unnoticed because tests/xturing/model_apis/ has never run in CI. Subclass the SDK error with a permissive __init__ instead: the instance is still caught by 'except error_cls' without depending on the signature. * ci: add model-api-tests job covering tests/xturing/model_apis/ lightweight-tests installs only pytest/fastapi/uvicorn/httpx and runs two files, so tests/xturing/model_apis/ has never executed in CI. The suite had silently rotted: test_claude_api.py fails on current anthropic releases, and a transformers-5-only import in the Qwen3-Omni wrapper reached four green checks without being caught. Add a separate job rather than widening lightweight-tests, so the existing required check keeps its current runtime and scope. These wrappers are pure Python -- no model weights are downloaded. torch is installed from the CPU index because xturing.model_apis imports it transitively and the default wheel pulls a large CUDA stack this job never uses. Verified locally against a clean venv (pytest + CPU torch + anthropic/cohere/ openai): 13 passed on main, and the Qwen3-Omni wrapper's 6 tests pass on the #318 branch in the same environment. --------- Co-authored-by: Glenn Ko <glennko@users.noreply.github.com>
Parking this — and a correction in your favourResearched the Correction:
|
| declared | v5.x requires |
|---|---|
bitsandbytes==0.41.1 (exact pin) |
>= 0.46.1 |
accelerate==0.22.0 (exact pin) |
>= 1.1.0 |
torch >= 1.9.0 |
>= 2.5 |
requires-python = ">=3.7" |
>= 3.10 |
Plus a long tail that a LoRA library walks straight into: Trainer(tokenizer=) removed in favour of processing_class= (no **kwargs, so it's an immediate TypeError), TrainingArguments.warmup_ratio removed, safe_serialization=False removed, default dtype changed from fp32 to "auto", transformers.tokenization_utils moved (you import from it in 4 files — 3 collators plus llama_utils/llama.py), and use_auth_token → token (2 sites in quant_utils/). MoE experts were also refactored off nn.ModuleList, which broke PEFT adapters on MoE models — and Qwen3-Omni is MoE, so that's directly relevant here. PEFT floor for v5 is >= 0.19.1.
Why it's parked
This isn't a "fix four review comments" PR. Landing Qwen3-Omni means a transformers 5.x migration across the whole library — a dependency-floor bump that drops Python 3.7–3.9, plus quantization, Trainer, and tokenizer-import changes. That's its own epic, and it should not ride in on a feature PR.
The other three findings from my earlier review still stand and are worth fixing whenever this resumes — finish_reason hardcoded to "stop" at qwen.py:129 is the one with real consequences, since it silently feeds truncated generations into the self-instruct dataset.
#358 corrects the README note that #320 added, so main no longer points people at a 5.x upgrade that would break their INT8/INT4 install.
#320 added an install note describing Qwen3-Omni's transformers>=5.0.0 requirement, but that feature is not merged (#318 is still open) and pyproject.toml pins transformers>=4.36.0. The note documented the requirements of something the package does not ship, and read as an invitation to upgrade. Verified against the transformers v5.16.1 source tree: load_in_8bit and load_in_4bit were hard-removed from from_pretrained in v5.0.0 (PR huggingface/transformers#41287), not deprecated. xturing passes them as bare kwargs in 7 places across engines/causal.py, llama_engine.py and gptj_engine.py, so a 5.x upgrade breaks the INT8/INT4 engines with a bare TypeError. Invert the note: state the supported floor, warn against 5.x, and point at #318 for Qwen3-Omni rather than describing it as available. Co-authored-by: Glenn Ko <glennko@users.noreply.github.com>
Summary
Checklist
Additional Information