Skip to content

Commit c3e42da

Browse files
committed
phi4 config and style fixes
1 parent dab36d2 commit c3e42da

File tree

14 files changed

+90
-39
lines changed

14 files changed

+90
-39
lines changed

docs/source/api_ref_models.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,26 @@ To download the Qwen2 1.5B model, for example:
299299
qwen2.lora_qwen2_7b
300300
qwen2.qwen2_tokenizer
301301

302+
phi-4
303+
-----
304+
305+
Models from the `Phi-4 family <https://arxiv.org/abs/2412.08905>`_.
306+
307+
To download the Phi-4 instruct model:
308+
309+
.. code-block:: bash
310+
311+
tune download microsoft/phi-4 --hf-token <HF_TOKEN>
312+
313+
.. autosummary::
314+
:toctree: generated/
315+
:nosignatures:
316+
317+
phi3.phi4_14b
318+
phi3.lora_phi4_14b
319+
phi3.qlora_phi4_14b
320+
phi3.phi4_tokenizer
321+
302322
phi-3
303323
-----
304324

recipes/configs/phi4/evaluation.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,21 @@ checkpointer:
1414
_component_: torchtune.training.FullModelHFCheckpointer
1515
checkpoint_dir: /tmp/phi-4
1616
checkpoint_files: [
17-
model-00001-of-00002.safetensors,
18-
model-00002-of-00002.safetensors
17+
model-00001-of-00006.safetensors,
18+
model-00002-of-00006.safetensors,
19+
model-00003-of-00006.safetensors,
20+
model-00004-of-00006.safetensors,
21+
model-00005-of-00006.safetensors,
22+
model-00006-of-00006.safetensors,
1923
]
2024
recipe_checkpoint: null
2125
output_dir: ${output_dir}
22-
model_type: PHI3_MINI
26+
model_type: PHI4
2327
resume_from_checkpoint: False
2428

2529
# Tokenizer
2630
tokenizer:
27-
_component_: torchtune.models.phi4.phi4_14b_tokenizer
31+
_component_: torchtune.models.phi4.phi4_tokenizer
2832
vocab_path: /tmp/phi-4/vocab.json
2933
merges_path: /tmp/phi-4/merges.txt
3034
max_seq_len: null

recipes/configs/phi4/full.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ model:
2525

2626
# Tokenizer
2727
tokenizer:
28-
_component_: torchtune.models.phi4.phi4_14b_tokenizer
28+
_component_: torchtune.models.phi4.phi4_tokenizer
2929
vocab_path: /tmp/phi-4/vocab.json
3030
merges_path: /tmp/phi-4/merges.txt
3131
max_seq_len: null
@@ -44,7 +44,7 @@ checkpointer:
4444
]
4545
recipe_checkpoint: null
4646
output_dir: ${output_dir}
47-
model_type: PHI3_MINI
47+
model_type: PHI4
4848
resume_from_checkpoint: False
4949

5050
# Dataset

recipes/configs/phi4/full_low_memory.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ model:
2727

2828
# Tokenizer
2929
tokenizer:
30-
_component_: torchtune.models.phi4.phi4_14b_tokenizer
30+
_component_: torchtune.models.phi4.phi4_tokenizer
3131
vocab_path: /tmp/phi-4/vocab.json
3232
merges_path: /tmp/phi-4/merges.txt
3333
max_seq_len: null
@@ -46,7 +46,7 @@ checkpointer:
4646
]
4747
recipe_checkpoint: null
4848
output_dir: ${output_dir}
49-
model_type: PHI3_MINI
49+
model_type: PHI4
5050
resume_from_checkpoint: False
5151

5252
# Dataset

recipes/configs/phi4/lora.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ model:
3131

3232
# Tokenizer
3333
tokenizer:
34-
_component_: torchtune.models.phi4.phi4_14b_tokenizer
34+
_component_: torchtune.models.phi4.phi4_tokenizer
3535
vocab_path: /tmp/phi-4/vocab.json
3636
merges_path: /tmp/phi-4/merges.txt
3737
max_seq_len: null
@@ -50,7 +50,7 @@ checkpointer:
5050
]
5151
recipe_checkpoint: null
5252
output_dir: ${output_dir}
53-
model_type: PHI3_MINI
53+
model_type: PHI4
5454
resume_from_checkpoint: False
5555
save_adapter_weights_only: False
5656

recipes/configs/phi4/lora_single_device.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ model:
2929

3030
# Tokenizer
3131
tokenizer:
32-
_component_: torchtune.models.phi4.phi4_14b_tokenizer
32+
_component_: torchtune.models.phi4.phi4_tokenizer
3333
vocab_path: /tmp/phi-4/vocab.json
3434
merges_path: /tmp/phi-4/merges.txt
3535
max_seq_len: null
@@ -48,7 +48,7 @@ checkpointer:
4848
]
4949
recipe_checkpoint: null
5050
output_dir: ${output_dir}
51-
model_type: PHI3_MINI
51+
model_type: PHI4
5252
resume_from_checkpoint: False
5353
save_adapter_weights_only: False
5454

recipes/configs/phi4/qlora_single_device.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ model:
2929

3030
# Tokenizer
3131
tokenizer:
32-
_component_: torchtune.models.phi4.phi4_14b_tokenizer
32+
_component_: torchtune.models.phi4.phi4_tokenizer
3333
vocab_path: /tmp/phi-4/vocab.json
3434
merges_path: /tmp/phi-4/merges.txt
3535
max_seq_len: null
@@ -48,7 +48,7 @@ checkpointer:
4848
]
4949
recipe_checkpoint: null
5050
output_dir: ${output_dir}
51-
model_type: PHI3_MINI
51+
model_type: PHI4
5252
resume_from_checkpoint: False
5353
save_adapter_weights_only: False
5454

tests/torchtune/models/phi4/test_phi4_tokenizer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
from tests.common import ASSETS
1212
from torchtune.data import Message
13-
from torchtune.models.phi4 import phi4_14b_tokenizer
13+
from torchtune.models.phi4 import phi4_tokenizer
1414

1515

16-
class TestPhi4MiniTokenizer:
16+
class TestPhi4Tokenizer:
1717
@pytest.fixture
1818
def tokenizer(self):
1919
# GPT2BaseTokenizer
20-
return phi4_14b_tokenizer(
20+
return phi4_tokenizer(
2121
vocab_path=(ASSETS / "vocab.json"),
2222
merges_path=(ASSETS / "merges.txt"),
2323
)

torchtune/_recipe_registry.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,10 @@ class Recipe:
522522
name="gemma/evaluation",
523523
file_path="gemma/evaluation.yaml",
524524
),
525+
Config(
526+
name="phi4/evaluation",
527+
file_path="phi4/evaluation.yaml",
528+
),
525529
Config(
526530
name="phi3/evaluation",
527531
file_path="phi3/evaluation.yaml",

torchtune/models/phi4/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
from ._model_builders import lora_phi4_14b, phi4_14b, phi4_14b_tokenizer # noqa
7+
from ._model_builders import lora_phi4_14b, phi4_14b, phi4_tokenizer # noqa
88

99
__all__ = [
1010
"phi4_14b",
11-
"phi4_14b_tokenizer",
11+
"phi4_tokenizer",
1212
"lora_phi4_14b",
1313
]

0 commit comments

Comments
 (0)