Repository navigation
Cicd combined - #95
Conversation
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
PR ReviewStrong infrastructure PR overall — the CI/CD direction looks good and the pre-commit/dev-experience improvements are valuable. What looks good
Requested changes
Nits
Overall: good direction, but I’d request the DCO fix and clearer CI/test-coverage expectations before merge. |
| # git config blame.ignoreRevsFile .git-blame-ignore-revs | ||
|
|
||
| # Apply ruff format and lint autofixes across the codebase | ||
| e1a92ceab87dc0ab6517916954a430d16b2da1b6 |
There was a problem hiding this comment.
As we squash the commits this wouldn't work for the current PR, we can either (1) squash the commits as part of the changes so that there is a single commit in this PR, (2) after we merge this PR, open a new PR only for the blame ignore with the squash commit
There was a problem hiding this comment.
@antonpibm In that case, I suggest we split this PR into two parts.
First - only the ruff formatting changes - this one needs to be ignored in git blame.
Second - after we merged the first, merge the CICD work - this should not get ignored by git blame since it is authentic development work, and not a reformat.
we can insert also the git blame ignore revs with the new sha after the first pr merge into the second pr.
Technically it is not complicated to aheieve since the reformat commit was the first commit in this branch, so I can easily split it into two.
If you agree, I will do it.
There was a problem hiding this comment.
@antonpibm - ok done. The ruff reformat changes were applied on PR 102 and this PR now contains only the CICD changes with only a few fixes to make sure all the quality checks added by the CICD pass:
src/
src/granite_switch/__init__.py — the only functional source change.
- What: __version__ = "0.1.0" → read from installed package metadata (importlib.metadata.version), with a "0.0.0+unknown" fallback when running from an uninstalled source tree.
- Why: from commit "reflect package version instead of hard coding a version" — supports the new publish.yaml release workflow so the version has a single source of truth (pyproject) instead of drifting from a hardcoded literal.
src/granite_switch/tutorials/*.py (6 files: __init__.py, chroma_loader.py, rag_display.py, utils/__init__.py, utils/hf_helpers.py, vllm_server.py)
- What: each gains a single top line # SPDX-License-Identifier: Apache-2.0. Nothing else.
- Why: the new check-headers hook/CI job requires every .py to carry the SPDX header; these tutorial files were the only ones missing it, so the gate forced them in.
tests/
tests/composer/test_adapter_loader.py
- What: assert adapters == yaml_adapters → assert sorted(...) == sorted(...), plus an explanatory comment.
- Why: filesystem scan order varies by OS/filesystem; the strict-order assertion was order-dependent and would flake on GitHub runners. Parity here means same set of adapters, not same ordering.
tests/composer/test_save_load_compose.py
- What: adds pytestmark = [pytest.mark.slow, pytest.mark.requires_model].
- Why: the module downloads a base model + RAG adapters and composes a checkpoint — far too heavy for CPU runners. The marks exclude it from CPU CI selection so it runs only on the GPU cluster.
tutorials/ — all pure hygiene, zero content change (verified)
- 8 notebooks (*.ipynb) — nbstripout normalization: source stored as line-lists, metadata/outputs stripped, cell IDs renumbered, trailing newline. I verified the actual cell source is byte-identical to upstream for all 8 — only the JSON serialization format changed.
- 2 sample_run/*.json — trailing newline added by end-of-file-fixer; content confirmed identical modulo whitespace.
- tutorials/README.md — one trailing-space removed.```
There was a problem hiding this comment.
I think this PR is ready for merging
antonpibm
left a comment
There was a problem hiding this comment.
Please see the minor comments
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Ruff loads its config from pyproject.toml, so a malformed pyproject.toml makes ruff abort with a parser error instead of the clean check-toml message. Running check-toml/check-yaml first (with fail_fast) ensures syntax errors are reported by the dedicated validator, consistently between local commits and CI's --all-files run. Signed-off-by: aviv ron <rona@il.ibm.com>
check-added-large-files only inspects staged additions, so on CI's clean checkout (nothing staged) it was a no-op. --enforce-all makes it check all files under pre-commit run --all-files. uv.lock (~2.3 MB) is excluded as an intentionally large lockfile. Signed-off-by: aviv ron <rona@il.ibm.com>
check-merge-conflict returns early unless a merge is in progress, so on CI's clean checkout it was a no-op. --assume-in-merge makes it always scan, letting pre-commit run --all-files catch committed conflict markers. Signed-off-by: aviv ron <rona@il.ibm.com>
…hooks Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
uv lock resolves fine on macOS; only installing the vLLM/CUDA wheels fails. --frozen is for not mutating the lock, not because a re-resolve would fail. Also note the uv-lock pre-commit hook runs locally. Signed-off-by: aviv ron <rona@il.ibm.com>
CI's coverage run executes only tests/unit/, which exercises just the pure-Python config module. Measuring the whole granite_switch package diluted the reported coverage to ~1%, because the hf/vllm/composer/ tutorials subpackages are GPU/model-only and unreachable in CI. Add [tool.coverage.run] omit rules for those subpackages so the CI coverage number reflects the code the unit suite is actually responsible for (now ~96%). Full-project coverage continues to be measured on the GPU cluster. Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
Signed-off-by: aviv ron <rona@il.ibm.com>
….0 MVP - Shorten CLAUDE.md pre-commit section to a brief blurb pointing at the CI/CD reference doc - Rename docs/CICD_PLAN.md -> docs/CICD.md as the living reference; retitle and fix the reference in pyproject.toml - Change CHANGELOG 0.1.0 from Pre-release to MVP Signed-off-by: aviv ron <rona@il.ibm.com>
Fold the DCO / Signed-off-by requirement into GIT_WORKFLOW.md so the sign-off steps live alongside the branching and commit guidance, with a pointer to CICD.md for the full hook and CI setup. Signed-off-by: aviv ron <rona@il.ibm.com>
The rebase's notebook auto-merge left two tutorial notebooks in a state that didn't match the nbstripout hook output. Run the hook to normalize source formatting so pre-commit / CI passes. Signed-off-by: aviv ron <rona@il.ibm.com>
|
Thank you @aviv1ron1! |
#130) * Default ASR to Granite Speech 5.0 TurboCTC, and raise transformers to 5.16 Re-applies the TurboCTC work onto public main by hand, rather than by cherry-picking the six commits it was developed as (09c52c2..9f1e5e8 on the staging branch). Public main has since absorbed #95, #104, #116 and #121, so several of the files had moved underneath the original patches. What changes, in five parts: * DEFAULT_ASR_MODEL_ID becomes ibm-granite/granite-speech-5.0-470m-turboctc, a 470M English conformer CTC encoder, replacing distil-whisper/distil-small.en. Being CTC it has no generate(), so decode kwargs (language/task) are dropped rather than forwarded, and transcripts are lowercase and unpunctuated. * ASR defaults retuned for a CTC backend: asr_self_chunks False and asr_chunk_length_s 120.0, since the encoder has no internal chunking and the HF pipeline's own CTC chunking mis-trims every seam (it rescales stride by inputs_to_logits_ratio, which this checkpoint does not publish). asr_device defaults to cuda and asr_dtype resolves to bfloat16 there. * transformers pinned >=5.5.1,<5.17.0 in the core package and >=5.16.0 on the audio extra, which is where granite_speech5_ctc landed. Only the audio path needs 5.16, so the requirement sits on the extra. * ATTENTION_LAYER_TYPES accepts both "attention" and "full_attention". transformers 5.16 renamed the value and rewrites it inside PreTrainedConfig.__init__, so comparing against the bare string silently dropped the attention LoRA target groups and left adapters with MLP targets only. * IsHybrid is no longer declared. It requires mamba-state hooks this model neither implements nor needs -- the composer normalizes every layer to attention, so a composed checkpoint has zero mamba layers. vLLM's escape hatch for exactly this shape compares the literal "attention", so the 5.16 rename flipped is_hybrid true and engine init began failing for the mamba dtype hook. Two places where main had moved and the original patch could not be taken as-is. Both are in compose_granite_switch.py's argparse help, and both would have been regressions if cherry-picked: * main established that --enable-audio is the only flag that switches audio on ("Requires --enable-audio; ignored without it"), replacing the older "Implies --enable-audio". The re-applied text keeps main's rule and carries only the TurboCTC facts across. * docs/AUDIO.md was hand-merged rather than overwritten, so main's confirmation from the Granite authors that <|unused_N|> ids are reserved survives alongside the new TurboCTC sections. uv.lock regenerated rather than patched: transformers 5.8.1 -> 5.16.1. Known limitation, carried over and unresolved: vLLM <=0.25 keys a layer-type table on the old "attention" spelling in granitemoehybrid.py, so in a venv built from this branch, serving a *stock* Granite 4.0 hybrid checkpoint raises KeyError: 'full_attention'. Composed Granite Switch checkpoints are unaffected -- they declare GraniteSwitchForCausalLM, which builds its own layers and never consults that table. vLLM fixed it in 0.26.0. Verified: ruff check and format clean; tests/unit/test_asr.py, test_config.py and test_config_edge_cases.py pass 90/90 (2 skipped for lack of a local vLLM). Signed-off-by: aviv ron <rona@il.ibm.com> * fix(tests): stop _patched_pipeline leaking its mock onto transformers.pipeline Closes #121. _patched_pipeline patched transformers.pipelines.pipeline before transformers.pipeline. mock.patch.__enter__ records the current value so it can restore it, and transformers is a lazy module: resolving transformers.pipeline when it is not yet cached on the top-level module goes through transformers.pipelines. With the submodule patched first, the second patch read back the mock, recorded it as "the original", and faithfully restored it on exit. The mock then stayed installed for the rest of the process, and load() resolves `from transformers import pipeline` at call time, so every later real transcription picked it up. One of the mocks in this file raises the "does not recognize this architecture" ValueError, which _unsupported_architecture_error converts into ImportError: transformers 5.16.0 cannot load the ASR model 'ibm-granite/granite-speech-5.0-470m-turboctc': its architecture requires transformers>=5.16 -- naming the installed version as too old for itself, from a GPU test that had nothing to do with the unit test that leaked. That false trail is the reason this is worth more than a one-line diff of explanation. Swapping the two patches is the whole fix: transformers.pipeline is now read while transformers.pipelines is still real, so both record and restore the real function. Why it went unnoticed: the leak only occurs when transformers.pipeline is not already cached on the top-level module, which depends on what else ran first. tests/unit/test_asr.py alone restores correctly; the full tests/unit/ directory leaks. CI always runs the full suite, so CI always leaked. TestPatchedPipelineRestores guards both attributes, and forces the lazy-resolve precondition with transformers.__dict__.pop("pipeline", None) rather than relying on collection order. Verified to fail on the old ordering (assert <Mock> is not <Mock>) and pass on the new one, so it is a real guard rather than a tautology. Verified on transformers 5.16.1 and 5.8.1: full tests/unit/ is 287 passed / 1448 skipped on both, and a probe asserting transformers.pipeline is the real function after the session passes on both. ruff check and format clean. Note this fixes the misleading diagnosis, not the GPU-tier failures it was masking: the leaked vLLM engine that starves later GPU tests is a separate teardown defect (#123) and is deliberately left for its own PR. Signed-off-by: aviv ron <rona@il.ibm.com> * fix(vllm): alias full_attention so vLLM <=0.25 can load a 5.16-written config Closes #122. transformers 5.16 renamed the layer type "attention" to "full_attention" and rewrites the value inside PreTrainedConfig.__init__, so it is now the only spelling a written config can carry -- writing the old one back does not help. vLLM <=0.25 keys its Granite-hybrid layer table on the old name: # vllm/model_executor/models/granitemoehybrid.py:319 ALL_DECODER_LAYER_TYPES = {"attention": ..., "mamba": ...} layer_class = ALL_DECODER_LAYER_TYPES[config.layer_types[layer_idx]] KeyError: 'full_attention' register() now aliases the new name onto the same layer class. Reproduced on both 0.19.1 and 0.20.2; upstream fixed it in 0.26.0 by adding the key themselves, and setdefault makes this a no-op there, so the block can be deleted on a version bump without touching anything else. Two things this repairs, which is why it is not only a test fix: * The vLLM equivalence tier -- 14 failures plus 19 nested. Those tests build their upstream reference with transformers, save_pretrained it, and hand the directory to vllm.LLM; the saved config now says full_attention and its architectures field routes to vLLM's stale class, so the *control group* never starts. GraniteSwitchForCausalLM was never affected: it builds layers through a closure and does not consult that table. * Serving a stock Granite 4.0 hybrid checkpoint. In a venv built from this branch -- transformers>=5.16 comes from our own audio extra, vLLM is pinned <=0.25 -- `vllm serve ibm-granite/granite-4.0-micro` crashed. Composed Granite Switch checkpoints did not; the published 4.2-30b carries layer_types: ["full_attention", ...] and serves correctly. Why it lives in register() and not a test fixture: the lookup runs inside vLLM's *spawned* engine-core process, so nothing patched in the parent survives. vLLM loads its plugins in that process during init (v1/engine/core.py calls load_general_plugins()), reading the vllm.general_plugins entry point we already declare. It is the only hook we own that executes there. Aliasing adds a name, not behaviour: both keys resolve to the identical class object, so the decoder layer built is the one that was built before the rename. The broad except is deliberate -- if a future vLLM moves the module or the dict, skipping silently costs us this KeyError again, whereas raising would take down every engine start. A larger alternative was considered and rejected as too big for this change: retargeting the whole equivalence tier off granitemoehybrid onto the families we actually ship. That gap is real -- granite (4.1/4.2/30b) has no equivalence coverage in any tier and granitemoe has HF-only -- but it is separate work. tests/vllm/test_plugin_registration.py asserts both keys are present and resolve to the same object, and that register() stays re-entrant as its docstring promises. It runs in-process rather than through the usual subprocess wrapper because register() creates no engine and so opens no CUDA context; it skips cleanly where vLLM is absent. The assertions hold on 0.26+ too, so the test does not need editing when the alias becomes redundant. Verified: ruff check and format clean over 210 files; tests/unit/ is 286 passed / 1448 skipped on transformers 5.16.1, unchanged. The alias itself only demonstrates on GPU -- the proof is the 14 equivalence failures going green. Not addressed here: #123, the leaked vLLM engine that starves later GPU tests (8 failures + 8 errors), which is its own PR; and #127's tokenizer-fetch flake. Also untouched is the second stale comparison, is_hybrid in vllm/config/model.py, still broken in 0.28.0 -- we sidestep it by not declaring IsHybrid. Signed-off-by: aviv ron <rona@il.ibm.com> * docs+tests(audio): fold in the MoE-audio documentation and its coverage Absorbs feature/moe-audio-support so it does not need a PR of its own: that branch carried no functional code, only documentation plus the tests that back it. Taken from staging/feature/moe-audio-support @ 8bf0bb3. What came across: * docs/AUDIO.md -- the audio cascade over a pure sparse MoE base. Hand-merged, not overwritten: this file had already diverged here (63+/25- from the TurboCTC edits, which touch the same sections). Verified afterwards that both sides survive -- the TurboCTC default, the transformers>=5.16 requirement and the 120s chunker window on one side, the granitemoe material on the other. * tests/composer/test_audio_marker_output_row.py -- the marker/reserved-row copy is now parametrized over MLP topology as well as embedding tying, taking it from 2 cases to 4 (untied/tied x dense/sparse-MoE). The fixup only ever touches embedding rows, so both topologies must behave identically; the sparse arm is what would notice if a shared-MLP-shaped assumption crept into the model construction it runs against. * tests/composer/test_granitemoe_audio_compose.py -- new, 9 tests over 4 classes: audio does not resurrect the shared MLP, does not widen the adapter surface and leaves no zero-width parameter; the control LUT goes stale on the marker and refresh fixes it idempotently and passes the validator; the marker output row; and survival across save/load. Deliberately NOT taken: a 5-line comment block in src/granite_switch/composer/tokenizer_setup.py noting that the <|unused_N|> convention also holds on granitemoe bases. True, but prose, and keeping src/ out of this commit makes the "no functional change" claim checkable rather than asserted -- `git show --stat` shows no src/ path at all. Verified: the two test files give 32 passed here; ruff check and format clean over 211 files. One thing a reviewer should not misread. The composer tier on this base reports pre-existing failures that predate this commit and are unrelated to it: TestGraniteMoeSR fails 6 of 8 even in isolation, in 0.37s, with "ValueError: not enough values to unpack (expected 5, got 3)". Public main is 15 commits behind staging and is missing #119, which changed composer return signatures and updated test_granitemoe_compose_e2e.py to match; the two are out of step here. It has gone unnoticed because the public repo's automatic CI runs only tests/unit/, so tests/composer/ is unchecked on every PR. #119 is expected to reach public main shortly, which resolves it. The test file imported above is based on #116, before that refactor, so it matches the signatures this base has. Signed-off-by: aviv ron <rona@il.ibm.com> * test(audio): drop the SingleSwitch arm from the MoE-audio compose fixture #131 removed SingleSwitch. test_granitemoe_audio_compose.py arrived from feature/moe-audio-support, which branched before that, so it still parametrized its fixture over ["single", "multi"] and asserted the switch class was SingleSwitch on the single arm -- 9 errors after the merge, every one a [single] case, while all 23 [multi] cases passed. Now SWITCH_TYPES = ["multi"] and the assertion is unconditional, which is what every other switch-parametrized file already does post-#131: test_control_lut_refresh.py:34, tests/hf/test_multi_switch.py:49, tests/vllm/test_multi_switch.py:52, tests/shared/gap_equivalence.py:15. So this converges on the established shape rather than inventing one. Nothing about the audio path changed -- the coverage that was single/multi parametrized is engine-independent (the marker's embedding and output rows, the control-LUT refresh, save/load survival), so dropping the removed engine loses no assertion. 23 passed. The wider audio tier is 128 passed / 53 skipped with one error that is this machine having no GPU ("Torch not compiled with CUDA enabled"), not a merge regression. Signed-off-by: aviv ron <rona@il.ibm.com> * Revert the transformers 5.16 adaptation; leave it to the version-bump PR This branch should carry only the net TurboCTC change. The 5.16 work done here belongs with the version bump instead (issue #84, origin/issue-84-support-0.28), so that branch can be merged in cleanly rather than conflicting with a parallel half-done version of the same adaptation. Reverted to main exactly: pyproject.toml both transformers pins (core ceiling raise, and audio extra >=5.16) uv.lock back to main's resolution vllm/__init__.py the full_attention alias vllm/granite_switch_model.py IsHybrid declared again tests/unit/test_config_edge_cases.py literal layer_types assertions tests/shared/granite4_equivalence.py layer_types back to "attention" tests/vllm/test_plugin_registration.py deleted (it only tested the alias) Two files mixed both concerns and were edited rather than reverted: * config.py loses ATTENTION_LAYER_TYPES and goes back to comparing the bare string. Its TurboCTC content (the asr_* defaults and docstrings) stays. * docs/AUDIO.md claimed the audio extra *requires* transformers>=5.16, which is no longer true. Reworded rather than deleted, because the requirement is real even while unpinned: the default model needs >=5.16, that is not pinned yet, #84 tracks it, and until then the cascade runs only with an --asr-model the installed transformers supports. Kept deliberately: * The _unsupported_architecture_error guard in asr.py. It is TurboCTC's own error handling, not part of the bump, and it is what makes this branch coherent unpinned -- an install below 5.16 gets an actionable ImportError naming the fix instead of transformers' generic "unrecognized architecture". * The _patched_pipeline mock-leak fix. Pre-existing bug on main, but it is what stops the new TurboCTC GPU tests reporting a false "transformers 5.16 too old" error, which would make the next GPU run unreadable. * The MoE-audio documentation and tests. No 5.16 dependency; they pass on these pins. Done as a forward revert rather than a history rewrite: no force-push, PR #130 keeps its review history, and `git diff main..HEAD` is what determines the merge result either way. Two things the version-bump PR still needs, which this revert removes from here and which its current state does not cover: * ATTENTION_LAYER_TYPES accepting both spellings. Required on any transformers >=5.16 regardless of vLLM version -- comparing against the bare string silently drops the attention LoRA target groups, leaving adapters with MLP targets only. * Dropping IsHybrid. vLLM's is_hybrid escape hatch still compares the literal "attention" in 0.28.0, so moving to 0.28 does not fix it; a composed checkpoint still fails engine init asking for a mamba dtype hook. Only the full_attention alias is genuinely obsolete under 0.28 -- upstream added that key in 0.26.0 -- so that one is gone for good. Note the bump PR currently pins transformers <5.16, which still excludes the version the default ASR model needs. As it stands, merging this branch after it would leave TurboCTC unable to load. Verified: ruff check and format clean over 200 files; tests/unit/ is 235 passed / 1448 skipped on the restored pins. Signed-off-by: aviv ron <rona@il.ibm.com> --------- Signed-off-by: aviv ron <rona@il.ibm.com>
No description provided.