Skip to content

Commit 4eaf0da

Browse files
[CI] update the version of macos. (#454)
[Github has announced that macos-13 runners will be closed down soon.](https://github.blog/changelog/2025-09-19-github-actions-macos-13-runner-image-is-closing-down/) This PR updates the version of macos in CI. --------- Signed-off-by: Yuchuan <[email protected]>
1 parent 605049e commit 4eaf0da

File tree

4 files changed

+40
-22
lines changed

4 files changed

+40
-22
lines changed

.github/workflows/build_and_release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- {os: ubuntu-24.04-arm, arch: aarch64, build: 'cp*-manylinux*'}
2323
- {os: windows-latest, arch: AMD64, build: 'cp*'}
2424
- {os: macos-14, arch: arm64, build: 'cp*'}
25-
- {os: macos-13, arch: x86_64, build: 'cp*',}
25+
- {os: macos-15-intel, arch: x86_64, build: 'cp*',}
2626

2727
steps:
2828
- uses: astral-sh/setup-uv@v4

.github/workflows/tmate.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ jobs:
88
strategy:
99
fail-fast: false
1010
matrix:
11-
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-14, macos-13]
11+
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-14, macos-15-intel]
1212
python: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
1313
exclude:
14-
- os: macos-13
14+
- os: macos-15-intel
1515
python: '3.13'
1616
# The reason for the exclusion is that pytorch distribution
17-
# can't be found by pip on macos-13 with python 3.13.
18-
17+
# can't be found by pip on macos-15-intel with python 3.13.
1918
steps:
2019
- name: Checkout
2120
uses: actions/checkout@v4

.github/workflows/unit_test.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ jobs:
3131
strategy:
3232
fail-fast: false
3333
matrix:
34-
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-14, macos-13]
34+
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-14, macos-15-intel]
3535
python: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
3636
exclude:
37-
- os: macos-13
37+
- os: macos-15-intel
3838
python: '3.13'
3939
# The reason for the exclusion is that pytorch distribution
40-
# can't be found by pip on macos-13 with python 3.13.
41-
40+
# can't be found by pip on macos-15-intel with python 3.13.
4241
steps:
4342
- name: Checkout
4443
uses: actions/checkout@v4

tests/python/test_structural_tag_converter.py

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import sys
22
import time
3-
from typing import Any, Dict, List, Tuple
3+
from typing import Any, Dict, List, Optional, Tuple, Union
44

55
import pytest
66
from transformers import AutoTokenizer
77

88
import xgrammar as xgr
9+
from xgrammar.structural_tag import StructuralTag
910
from xgrammar.testing import _is_grammar_accept_string
1011

11-
PROFILER_ON = True
12-
tokenizer_id = "meta-llama/Llama-3.1-8B-Instruct"
13-
1412

1513
class Profiler:
1614
def __init__(self, tokenizer_id: str):
@@ -22,8 +20,13 @@ def __init__(self, tokenizer_id: str):
2220
self.tokenizer_info, max_threads=16, cache_enabled=False
2321
)
2422

25-
def profile_stag(self, structural_tag_format: Dict[str, Any], instance: str):
26-
structural_tag = {"type": "structural_tag", "format": structural_tag_format}
23+
def profile_stag(
24+
self, structural_tag_format: Union[Dict[str, Any], StructuralTag], instance: str
25+
):
26+
if isinstance(structural_tag_format, StructuralTag):
27+
structural_tag = structural_tag_format
28+
else:
29+
structural_tag = {"type": "structural_tag", "format": structural_tag_format}
2730
time_begin = time.monotonic_ns()
2831
compiled_grammar = self.compiler.compile_structural_tag(structural_tag)
2932
time_end = time.monotonic_ns()
@@ -45,8 +48,23 @@ def profile_stag(self, structural_tag_format: Dict[str, Any], instance: str):
4548
print(f"Time to generate mask: {duration / 1000} us, Character: '{char}'")
4649

4750

48-
if PROFILER_ON:
49-
profiler = Profiler(tokenizer_id)
51+
profiler: Optional[Profiler] = None
52+
PROFILER_ON = True
53+
tokenizer_id = "meta-llama/Llama-3.1-8B-Instruct"
54+
55+
56+
@pytest.fixture(autouse=True)
57+
def disable_profiler(request):
58+
global PROFILER_ON
59+
global profiler
60+
markexpr = getattr(request.config.option, "markexpr", "") or request.config.getoption(
61+
"markexpr", ""
62+
)
63+
hf_token_not_provided = "not hf_token_required" in (markexpr or "")
64+
if hf_token_not_provided:
65+
PROFILER_ON = False
66+
else:
67+
profiler = Profiler(tokenizer_id)
5068

5169

5270
def check_stag_with_grammar(structural_tag_format: Dict[str, Any], expected_grammar_ebnf: str):
@@ -56,13 +74,16 @@ def check_stag_with_grammar(structural_tag_format: Dict[str, Any], expected_gram
5674

5775

5876
def check_stag_with_instance(
59-
structural_tag_format: Dict[str, Any],
77+
structural_tag_format: Union[Dict[str, Any], StructuralTag],
6078
instance: str,
6179
is_accepted: bool = True,
6280
debug_print: bool = False,
6381
):
64-
structural_tag = {"type": "structural_tag", "format": structural_tag_format}
65-
stag_grammar = xgr.Grammar.from_structural_tag(structural_tag)
82+
if isinstance(structural_tag_format, StructuralTag):
83+
stag_grammar = xgr.Grammar.from_structural_tag(structural_tag_format)
84+
else:
85+
structural_tag = {"type": "structural_tag", "format": structural_tag_format}
86+
stag_grammar = xgr.Grammar.from_structural_tag(structural_tag)
6687
accepted = _is_grammar_accept_string(stag_grammar, instance, debug_print=debug_print)
6788
assert accepted == is_accepted
6889
if PROFILER_ON:
@@ -1955,8 +1976,7 @@ def test_from_structural_tag_with_structural_tag_instance(
19551976
stag_format: xgr.structural_tag.Format, instance: str, is_accepted: bool
19561977
):
19571978
stag = xgr.StructuralTag(format=stag_format)
1958-
grammar = xgr.Grammar.from_structural_tag(stag)
1959-
assert _is_grammar_accept_string(grammar, instance) == is_accepted
1979+
check_stag_with_instance(stag, instance, is_accepted)
19601980

19611981

19621982
if __name__ == "__main__":

0 commit comments

Comments
 (0)