Add files using upload-large-folder tool
Browse files- LTA_openwebtext_dualt/logs/lm1b_classic_dirichlet_every1k_infer_watch/infer_lta_lm1b_classic_dirichlet_len128_gbs512_4gpu_10k_save1k_20260523_step_0002000_t1p45.log +20 -0
- LTA_openwebtext_dualt/logs/lm1b_classic_dirichlet_every1k_infer_watch/infer_lta_lm1b_classic_dirichlet_len128_gbs512_4gpu_10k_save1k_20260523_step_0003000_t1p45.log +20 -0
- LTA_openwebtext_dualt/logs/lm1b_classic_dirichlet_every1k_infer_watch/infer_lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523_step_0001000_t1p45.log +56 -0
- LTA_openwebtext_dualt/logs/lm1b_classic_dirichlet_every1k_infer_watch/infer_lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523_step_0005000_t1p45.log +36 -0
- LTA_openwebtext_dualt/logs/lm1b_classic_dirichlet_every1k_infer_watch/processed_lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523_steps128_c1024_t1p45_n256.txt +21 -0
- LTA_openwebtext_dualt/logs/lta_owt_c1024_len1024_t0to1_lowk64plus_priorcenter0p2_buf1000_gbs128_4gpu_2k_watcher.nohup +37 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/array_api/__init__.py +387 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/array_api/_indexing_functions.py +20 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/array_api/linalg.py +466 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/array_api/tests/test_set_functions.py +19 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/transformers/models/gemma/configuration_gemma.py +86 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/transformers/models/mistral3/configuration_mistral3.py +108 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/transformers/models/mistral3/modeling_mistral3.py +464 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/transformers/models/vits/__init__.py +28 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/transformers/models/vits/configuration_vits.py +168 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/runs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_2x8gpu_50ep_lr3e3_ema0p9999_elfopt_not5_bottleneck16_unfixed_norm_stateprobadd_selfcond_ce_fast_20260612_030202/step_052000.pt +3 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/runs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_2x8gpu_50ep_lr3e3_ema0p9999_elfopt_not5_bottleneck16_unfixed_norm_stateprobadd_selfcond_ce_fast_20260612_030202/step_077000.pt +3 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/runs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_2x8gpu_50ep_lr3e3_ema0p9999_elfopt_not5_bottleneck16_unfixed_norm_stateprobadd_selfcond_ce_fast_20260612_030202/step_235000.pt +3 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/runs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_2x8gpu_50ep_lr3e3_ema0p9999_elfopt_not5_bottleneck16_unfixed_norm_stateprobadd_selfcond_ce_fast_20260612_030202/step_336000.pt +3 -0
- LTA_openwebtext_dualt/mini_owt_logdirichlet/runs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_2x8gpu_50ep_lr3e3_ema0p9999_elfopt_not5_bottleneck16_unfixed_norm_stateprobadd_selfcond_ce_fast_20260612_030202/step_456000.pt +3 -0
LTA_openwebtext_dualt/logs/lm1b_classic_dirichlet_every1k_infer_watch/infer_lta_lm1b_classic_dirichlet_len128_gbs512_4gpu_10k_save1k_20260523_step_0002000_t1p45.log
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[watch-classic-1k] 2026-05-23_10:21:31 infer runs/lta_lm1b_classic_dirichlet_len128_gbs512_4gpu_10k_save1k_20260523/step_0002000.pt -> docs/lta_samples/metrics_20260523/lm1b_classic_dirichlet_len128_every1k_normal_steps_state_t1p45_c1024_n256/lta_lm1b_classic_dirichlet_len128_gbs512_4gpu_10k_save1k_20260523/step_0002000
|
| 2 |
+
[ckpt] runs/lta_lm1b_classic_dirichlet_len128_gbs512_4gpu_10k_save1k_20260523/step_0002000.pt step=2000
|
| 3 |
+
[decode] steps128_c1024_t1p45 generated 16/256
|
| 4 |
+
[decode] steps128_c1024_t1p45 generated 32/256
|
| 5 |
+
[decode] steps128_c1024_t1p45 generated 48/256
|
| 6 |
+
[decode] steps128_c1024_t1p45 generated 64/256
|
| 7 |
+
[decode] steps128_c1024_t1p45 generated 80/256
|
| 8 |
+
[decode] steps128_c1024_t1p45 generated 96/256
|
| 9 |
+
[decode] steps128_c1024_t1p45 generated 112/256
|
| 10 |
+
[decode] steps128_c1024_t1p45 generated 128/256
|
| 11 |
+
[decode] steps128_c1024_t1p45 generated 144/256
|
| 12 |
+
[decode] steps128_c1024_t1p45 generated 160/256
|
| 13 |
+
[decode] steps128_c1024_t1p45 generated 176/256
|
| 14 |
+
[decode] steps128_c1024_t1p45 generated 192/256
|
| 15 |
+
[decode] steps128_c1024_t1p45 generated 208/256
|
| 16 |
+
[decode] steps128_c1024_t1p45 generated 224/256
|
| 17 |
+
[decode] steps128_c1024_t1p45 generated 240/256
|
| 18 |
+
[decode] steps128_c1024_t1p45 generated 256/256
|
| 19 |
+
[summary] {"name": "steps128_c1024_t1p45", "step": 2000, "decode_steps": 128, "concentration_max": 1024.0, "raw_genppl": 16.75755546664795, "stripped_genppl": 39.29504191698321, "sample_entropy": 1.6313778065192153, "distinct_1": 0.0010986328125, "distinct_2": 0.008889025590551181, "top_token_mass": 0.478668212890625, "raw_kept": 256, "stripped_kept": 256}
|
| 20 |
+
[watch-classic-1k] 2026-05-23_10:23:00 done step_0002000
|
LTA_openwebtext_dualt/logs/lm1b_classic_dirichlet_every1k_infer_watch/infer_lta_lm1b_classic_dirichlet_len128_gbs512_4gpu_10k_save1k_20260523_step_0003000_t1p45.log
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[watch-classic-1k] 2026-05-23_10:27:00 infer runs/lta_lm1b_classic_dirichlet_len128_gbs512_4gpu_10k_save1k_20260523/step_0003000.pt -> docs/lta_samples/metrics_20260523/lm1b_classic_dirichlet_len128_every1k_normal_steps_state_t1p45_c1024_n256/lta_lm1b_classic_dirichlet_len128_gbs512_4gpu_10k_save1k_20260523/step_0003000
|
| 2 |
+
[ckpt] runs/lta_lm1b_classic_dirichlet_len128_gbs512_4gpu_10k_save1k_20260523/step_0003000.pt step=3000
|
| 3 |
+
[decode] steps128_c1024_t1p45 generated 16/256
|
| 4 |
+
[decode] steps128_c1024_t1p45 generated 32/256
|
| 5 |
+
[decode] steps128_c1024_t1p45 generated 48/256
|
| 6 |
+
[decode] steps128_c1024_t1p45 generated 64/256
|
| 7 |
+
[decode] steps128_c1024_t1p45 generated 80/256
|
| 8 |
+
[decode] steps128_c1024_t1p45 generated 96/256
|
| 9 |
+
[decode] steps128_c1024_t1p45 generated 112/256
|
| 10 |
+
[decode] steps128_c1024_t1p45 generated 128/256
|
| 11 |
+
[decode] steps128_c1024_t1p45 generated 144/256
|
| 12 |
+
[decode] steps128_c1024_t1p45 generated 160/256
|
| 13 |
+
[decode] steps128_c1024_t1p45 generated 176/256
|
| 14 |
+
[decode] steps128_c1024_t1p45 generated 192/256
|
| 15 |
+
[decode] steps128_c1024_t1p45 generated 208/256
|
| 16 |
+
[decode] steps128_c1024_t1p45 generated 224/256
|
| 17 |
+
[decode] steps128_c1024_t1p45 generated 240/256
|
| 18 |
+
[decode] steps128_c1024_t1p45 generated 256/256
|
| 19 |
+
[summary] {"name": "steps128_c1024_t1p45", "step": 3000, "decode_steps": 128, "concentration_max": 1024.0, "raw_genppl": 36.1762381749491, "stripped_genppl": 61.39489325272191, "sample_entropy": 3.691448556067005, "distinct_1": 0.055419921875, "distinct_2": 0.26565575787401574, "top_token_mass": 0.085540771484375, "raw_kept": 256, "stripped_kept": 256}
|
| 20 |
+
[watch-classic-1k] 2026-05-23_10:28:30 done step_0003000
|
LTA_openwebtext_dualt/logs/lm1b_classic_dirichlet_every1k_infer_watch/infer_lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523_step_0001000_t1p45.log
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[watch-classic-1k] 2026-05-23_12:54:50 infer runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0001000.pt -> docs/lta_samples/metrics_20260523/lm1b_classic_dirichlet_len256_every1k_normal_steps_state_t1p45_c1024_n256/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0001000
|
| 2 |
+
[ckpt] runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0001000.pt step=1000
|
| 3 |
+
[decode] steps128_c1024_t1p45 generated 8/256
|
| 4 |
+
[decode] steps128_c1024_t1p45 generated 16/256
|
| 5 |
+
[decode] steps128_c1024_t1p45 generated 24/256
|
| 6 |
+
[decode] steps128_c1024_t1p45 generated 32/256
|
| 7 |
+
[decode] steps128_c1024_t1p45 generated 40/256
|
| 8 |
+
[decode] steps128_c1024_t1p45 generated 48/256
|
| 9 |
+
[decode] steps128_c1024_t1p45 generated 56/256
|
| 10 |
+
[decode] steps128_c1024_t1p45 generated 64/256
|
| 11 |
+
[decode] steps128_c1024_t1p45 generated 72/256
|
| 12 |
+
[decode] steps128_c1024_t1p45 generated 80/256
|
| 13 |
+
[decode] steps128_c1024_t1p45 generated 88/256
|
| 14 |
+
[decode] steps128_c1024_t1p45 generated 96/256
|
| 15 |
+
[decode] steps128_c1024_t1p45 generated 104/256
|
| 16 |
+
[decode] steps128_c1024_t1p45 generated 112/256
|
| 17 |
+
[decode] steps128_c1024_t1p45 generated 120/256
|
| 18 |
+
[decode] steps128_c1024_t1p45 generated 128/256
|
| 19 |
+
[decode] steps128_c1024_t1p45 generated 136/256
|
| 20 |
+
[decode] steps128_c1024_t1p45 generated 144/256
|
| 21 |
+
[decode] steps128_c1024_t1p45 generated 152/256
|
| 22 |
+
[decode] steps128_c1024_t1p45 generated 160/256
|
| 23 |
+
[decode] steps128_c1024_t1p45 generated 168/256
|
| 24 |
+
[decode] steps128_c1024_t1p45 generated 176/256
|
| 25 |
+
[decode] steps128_c1024_t1p45 generated 184/256
|
| 26 |
+
[decode] steps128_c1024_t1p45 generated 192/256
|
| 27 |
+
[decode] steps128_c1024_t1p45 generated 200/256
|
| 28 |
+
[decode] steps128_c1024_t1p45 generated 208/256
|
| 29 |
+
[decode] steps128_c1024_t1p45 generated 216/256
|
| 30 |
+
[decode] steps128_c1024_t1p45 generated 224/256
|
| 31 |
+
[decode] steps128_c1024_t1p45 generated 232/256
|
| 32 |
+
[decode] steps128_c1024_t1p45 generated 240/256
|
| 33 |
+
[decode] steps128_c1024_t1p45 generated 248/256
|
| 34 |
+
[decode] steps128_c1024_t1p45 generated 256/256
|
| 35 |
+
[summary] {"name": "steps128_c1024_t1p45", "step": 1000, "decode_steps": 128, "concentration_max": 1024.0, "raw_genppl": 72.35960096539374, "stripped_genppl": 129.42215967177734, "sample_entropy": 3.3070190356724845, "distinct_1": 0.05859375, "distinct_2": 0.22784926470588235, "top_token_mass": 0.1839447021484375, "raw_kept": 256, "stripped_kept": 256}
|
| 36 |
+
[watch-classic-1k] 2026-05-23_12:58:07 done step_0001000
|
| 37 |
+
[watch-classic-1k] 2026-05-23_13:51:35 infer runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0001000.pt -> docs/lta_samples/metrics_20260523/lm1b_classic_dirichlet_len256_every1k_normal_steps_state_t1p45_c1024_n256/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0001000
|
| 38 |
+
[ckpt] runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0001000.pt step=1000
|
| 39 |
+
[decode] steps128_c1024_t1p45 generated 16/256
|
| 40 |
+
[decode] steps128_c1024_t1p45 generated 32/256
|
| 41 |
+
[decode] steps128_c1024_t1p45 generated 48/256
|
| 42 |
+
[decode] steps128_c1024_t1p45 generated 64/256
|
| 43 |
+
[decode] steps128_c1024_t1p45 generated 80/256
|
| 44 |
+
[decode] steps128_c1024_t1p45 generated 96/256
|
| 45 |
+
[decode] steps128_c1024_t1p45 generated 112/256
|
| 46 |
+
[decode] steps128_c1024_t1p45 generated 128/256
|
| 47 |
+
[decode] steps128_c1024_t1p45 generated 144/256
|
| 48 |
+
[decode] steps128_c1024_t1p45 generated 160/256
|
| 49 |
+
[decode] steps128_c1024_t1p45 generated 176/256
|
| 50 |
+
[decode] steps128_c1024_t1p45 generated 192/256
|
| 51 |
+
[decode] steps128_c1024_t1p45 generated 208/256
|
| 52 |
+
[decode] steps128_c1024_t1p45 generated 224/256
|
| 53 |
+
[decode] steps128_c1024_t1p45 generated 240/256
|
| 54 |
+
[decode] steps128_c1024_t1p45 generated 256/256
|
| 55 |
+
[summary] {"name": "steps128_c1024_t1p45", "step": 1000, "decode_steps": 128, "concentration_max": 1024.0, "raw_genppl": 70.72088959141885, "stripped_genppl": 128.15198680471343, "sample_entropy": 3.3058253821922667, "distinct_1": 0.0594024658203125, "distinct_2": 0.22833946078431372, "top_token_mass": 0.183013916015625, "raw_kept": 256, "stripped_kept": 256}
|
| 56 |
+
[watch-classic-1k] 2026-05-23_13:54:26 done step_0001000
|
LTA_openwebtext_dualt/logs/lm1b_classic_dirichlet_every1k_infer_watch/infer_lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523_step_0005000_t1p45.log
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[watch-classic-1k] 2026-05-23_13:38:08 infer runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0005000.pt -> docs/lta_samples/metrics_20260523/lm1b_classic_dirichlet_len256_every1k_normal_steps_state_t1p45_c1024_n256/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0005000
|
| 2 |
+
[ckpt] runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0005000.pt step=5000
|
| 3 |
+
[decode] steps128_c1024_t1p45 generated 8/256
|
| 4 |
+
[decode] steps128_c1024_t1p45 generated 16/256
|
| 5 |
+
[decode] steps128_c1024_t1p45 generated 24/256
|
| 6 |
+
[decode] steps128_c1024_t1p45 generated 32/256
|
| 7 |
+
[decode] steps128_c1024_t1p45 generated 40/256
|
| 8 |
+
[decode] steps128_c1024_t1p45 generated 48/256
|
| 9 |
+
[decode] steps128_c1024_t1p45 generated 56/256
|
| 10 |
+
[decode] steps128_c1024_t1p45 generated 64/256
|
| 11 |
+
[decode] steps128_c1024_t1p45 generated 72/256
|
| 12 |
+
[decode] steps128_c1024_t1p45 generated 80/256
|
| 13 |
+
[decode] steps128_c1024_t1p45 generated 88/256
|
| 14 |
+
[decode] steps128_c1024_t1p45 generated 96/256
|
| 15 |
+
[decode] steps128_c1024_t1p45 generated 104/256
|
| 16 |
+
[decode] steps128_c1024_t1p45 generated 112/256
|
| 17 |
+
[decode] steps128_c1024_t1p45 generated 120/256
|
| 18 |
+
[decode] steps128_c1024_t1p45 generated 128/256
|
| 19 |
+
[decode] steps128_c1024_t1p45 generated 136/256
|
| 20 |
+
[decode] steps128_c1024_t1p45 generated 144/256
|
| 21 |
+
[decode] steps128_c1024_t1p45 generated 152/256
|
| 22 |
+
[decode] steps128_c1024_t1p45 generated 160/256
|
| 23 |
+
[decode] steps128_c1024_t1p45 generated 168/256
|
| 24 |
+
[decode] steps128_c1024_t1p45 generated 176/256
|
| 25 |
+
[decode] steps128_c1024_t1p45 generated 184/256
|
| 26 |
+
[decode] steps128_c1024_t1p45 generated 192/256
|
| 27 |
+
[decode] steps128_c1024_t1p45 generated 200/256
|
| 28 |
+
[decode] steps128_c1024_t1p45 generated 208/256
|
| 29 |
+
[decode] steps128_c1024_t1p45 generated 216/256
|
| 30 |
+
[decode] steps128_c1024_t1p45 generated 224/256
|
| 31 |
+
[decode] steps128_c1024_t1p45 generated 232/256
|
| 32 |
+
[decode] steps128_c1024_t1p45 generated 240/256
|
| 33 |
+
[decode] steps128_c1024_t1p45 generated 248/256
|
| 34 |
+
[decode] steps128_c1024_t1p45 generated 256/256
|
| 35 |
+
[summary] {"name": "steps128_c1024_t1p45", "step": 5000, "decode_steps": 128, "concentration_max": 1024.0, "raw_genppl": 23.719647927051128, "stripped_genppl": 22.788784641976328, "sample_entropy": 1.0668808291405316, "distinct_1": 0.0083770751953125, "distinct_2": 0.02971813725490196, "top_token_mass": 0.7150115966796875, "raw_kept": 256, "stripped_kept": 256}
|
| 36 |
+
[watch-classic-1k] 2026-05-23_13:41:18 done step_0005000
|
LTA_openwebtext_dualt/logs/lm1b_classic_dirichlet_every1k_infer_watch/processed_lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523_steps128_c1024_t1p45_n256.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0001000.pt
|
| 2 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0002000.pt
|
| 3 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0003000.pt
|
| 4 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0004000.pt
|
| 5 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0005000.pt
|
| 6 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0001000.pt
|
| 7 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0006000.pt
|
| 8 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0007000.pt
|
| 9 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0008000.pt
|
| 10 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0009000.pt
|
| 11 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0010000.pt
|
| 12 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0011000.pt
|
| 13 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0012000.pt
|
| 14 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0013000.pt
|
| 15 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0014000.pt
|
| 16 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0015000.pt
|
| 17 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0016000.pt
|
| 18 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0017000.pt
|
| 19 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0018000.pt
|
| 20 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0019000.pt
|
| 21 |
+
runs/lta_lm1b_classic_dirichlet_len256_gbs512_4gpu_10k_save1k_20260523/step_0020000.pt
|
LTA_openwebtext_dualt/logs/lta_owt_c1024_len1024_t0to1_lowk64plus_priorcenter0p2_buf1000_gbs128_4gpu_2k_watcher.nohup
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[watcher] start 2026-05-12T01:44:41+00:00 run_dir=runs/lta_owt_c1024_len1024_t0to1_lowk64plus_priorcenter0p2_buf1000_gbs128_4gpu_2k
|
| 2 |
+
[watcher] poll 2026-05-12T01:54:45+00:00 step=500 last=-1
|
| 3 |
+
[watcher] infer step=500 out=docs/lta_samples/metrics_20260512/owt_lowk64plus_priorcenter0p2_2k_rolling_sync_probe/step500_sync_probe_n16
|
| 4 |
+
[watcher] done step=500
|
| 5 |
+
[watcher] poll 2026-05-12T01:56:49+00:00 step=500 last=500
|
| 6 |
+
[watcher] poll 2026-05-12T01:57:53+00:00 step=500 last=500
|
| 7 |
+
[watcher] poll 2026-05-12T01:58:56+00:00 step=500 last=500
|
| 8 |
+
[watcher] poll 2026-05-12T01:59:59+00:00 step=500 last=500
|
| 9 |
+
[watcher] poll 2026-05-12T02:01:03+00:00 step=500 last=500
|
| 10 |
+
[watcher] poll 2026-05-12T02:02:06+00:00 step=500 last=500
|
| 11 |
+
[watcher] poll 2026-05-12T02:03:10+00:00 step=500 last=500
|
| 12 |
+
[watcher] poll 2026-05-12T02:04:13+00:00 step=500 last=500
|
| 13 |
+
[watcher] poll 2026-05-12T02:05:16+00:00 step=1000 last=500
|
| 14 |
+
[watcher] infer step=1000 out=docs/lta_samples/metrics_20260512/owt_lowk64plus_priorcenter0p2_2k_rolling_sync_probe/step1000_sync_probe_n16
|
| 15 |
+
[watcher] done step=1000
|
| 16 |
+
[watcher] poll 2026-05-12T02:07:20+00:00 step=1000 last=1000
|
| 17 |
+
[watcher] poll 2026-05-12T02:08:23+00:00 step=1000 last=1000
|
| 18 |
+
[watcher] poll 2026-05-12T02:09:27+00:00 step=1000 last=1000
|
| 19 |
+
[watcher] poll 2026-05-12T02:10:30+00:00 step=1000 last=1000
|
| 20 |
+
[watcher] poll 2026-05-12T02:11:34+00:00 step=1000 last=1000
|
| 21 |
+
[watcher] poll 2026-05-12T02:12:37+00:00 step=1000 last=1000
|
| 22 |
+
[watcher] poll 2026-05-12T02:13:40+00:00 step=1000 last=1000
|
| 23 |
+
[watcher] poll 2026-05-12T02:14:44+00:00 step=1000 last=1000
|
| 24 |
+
[watcher] poll 2026-05-12T02:15:47+00:00 step=1500 last=1000
|
| 25 |
+
[watcher] infer step=1500 out=docs/lta_samples/metrics_20260512/owt_lowk64plus_priorcenter0p2_2k_rolling_sync_probe/step1500_sync_probe_n16
|
| 26 |
+
[watcher] done step=1500
|
| 27 |
+
[watcher] poll 2026-05-12T02:17:51+00:00 step=1500 last=1500
|
| 28 |
+
[watcher] poll 2026-05-12T02:18:54+00:00 step=1500 last=1500
|
| 29 |
+
[watcher] poll 2026-05-12T02:19:57+00:00 step=1500 last=1500
|
| 30 |
+
[watcher] poll 2026-05-12T02:21:01+00:00 step=1500 last=1500
|
| 31 |
+
[watcher] poll 2026-05-12T02:22:04+00:00 step=1500 last=1500
|
| 32 |
+
[watcher] poll 2026-05-12T02:23:07+00:00 step=1500 last=1500
|
| 33 |
+
[watcher] poll 2026-05-12T02:24:11+00:00 step=1500 last=1500
|
| 34 |
+
[watcher] poll 2026-05-12T02:25:14+00:00 step=2000 last=1500
|
| 35 |
+
[watcher] infer step=2000 out=docs/lta_samples/metrics_20260512/owt_lowk64plus_priorcenter0p2_2k_rolling_sync_probe/step2000_sync_probe_n16
|
| 36 |
+
[watcher] done step=2000
|
| 37 |
+
[watcher] stop step=2000
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/array_api/__init__.py
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
A NumPy sub-namespace that conforms to the Python array API standard.
|
| 3 |
+
|
| 4 |
+
This submodule accompanies NEP 47, which proposes its inclusion in NumPy. It
|
| 5 |
+
is still considered experimental, and will issue a warning when imported.
|
| 6 |
+
|
| 7 |
+
This is a proof-of-concept namespace that wraps the corresponding NumPy
|
| 8 |
+
functions to give a conforming implementation of the Python array API standard
|
| 9 |
+
(https://data-apis.github.io/array-api/latest/). The standard is currently in
|
| 10 |
+
an RFC phase and comments on it are both welcome and encouraged. Comments
|
| 11 |
+
should be made either at https://github.com/data-apis/array-api or at
|
| 12 |
+
https://github.com/data-apis/consortium-feedback/discussions.
|
| 13 |
+
|
| 14 |
+
NumPy already follows the proposed spec for the most part, so this module
|
| 15 |
+
serves mostly as a thin wrapper around it. However, NumPy also implements a
|
| 16 |
+
lot of behavior that is not included in the spec, so this serves as a
|
| 17 |
+
restricted subset of the API. Only those functions that are part of the spec
|
| 18 |
+
are included in this namespace, and all functions are given with the exact
|
| 19 |
+
signature given in the spec, including the use of position-only arguments, and
|
| 20 |
+
omitting any extra keyword arguments implemented by NumPy but not part of the
|
| 21 |
+
spec. The behavior of some functions is also modified from the NumPy behavior
|
| 22 |
+
to conform to the standard. Note that the underlying array object itself is
|
| 23 |
+
wrapped in a wrapper Array() class, but is otherwise unchanged. This submodule
|
| 24 |
+
is implemented in pure Python with no C extensions.
|
| 25 |
+
|
| 26 |
+
The array API spec is designed as a "minimal API subset" and explicitly allows
|
| 27 |
+
libraries to include behaviors not specified by it. But users of this module
|
| 28 |
+
that intend to write portable code should be aware that only those behaviors
|
| 29 |
+
that are listed in the spec are guaranteed to be implemented across libraries.
|
| 30 |
+
Consequently, the NumPy implementation was chosen to be both conforming and
|
| 31 |
+
minimal, so that users can use this implementation of the array API namespace
|
| 32 |
+
and be sure that behaviors that it defines will be available in conforming
|
| 33 |
+
namespaces from other libraries.
|
| 34 |
+
|
| 35 |
+
A few notes about the current state of this submodule:
|
| 36 |
+
|
| 37 |
+
- There is a test suite that tests modules against the array API standard at
|
| 38 |
+
https://github.com/data-apis/array-api-tests. The test suite is still a work
|
| 39 |
+
in progress, but the existing tests pass on this module, with a few
|
| 40 |
+
exceptions:
|
| 41 |
+
|
| 42 |
+
- DLPack support (see https://github.com/data-apis/array-api/pull/106) is
|
| 43 |
+
not included here, as it requires a full implementation in NumPy proper
|
| 44 |
+
first.
|
| 45 |
+
|
| 46 |
+
The test suite is not yet complete, and even the tests that exist are not
|
| 47 |
+
guaranteed to give a comprehensive coverage of the spec. Therefore, when
|
| 48 |
+
reviewing and using this submodule, you should refer to the standard
|
| 49 |
+
documents themselves. There are some tests in numpy.array_api.tests, but
|
| 50 |
+
they primarily focus on things that are not tested by the official array API
|
| 51 |
+
test suite.
|
| 52 |
+
|
| 53 |
+
- There is a custom array object, numpy.array_api.Array, which is returned by
|
| 54 |
+
all functions in this module. All functions in the array API namespace
|
| 55 |
+
implicitly assume that they will only receive this object as input. The only
|
| 56 |
+
way to create instances of this object is to use one of the array creation
|
| 57 |
+
functions. It does not have a public constructor on the object itself. The
|
| 58 |
+
object is a small wrapper class around numpy.ndarray. The main purpose of it
|
| 59 |
+
is to restrict the namespace of the array object to only those dtypes and
|
| 60 |
+
only those methods that are required by the spec, as well as to limit/change
|
| 61 |
+
certain behavior that differs in the spec. In particular:
|
| 62 |
+
|
| 63 |
+
- The array API namespace does not have scalar objects, only 0-D arrays.
|
| 64 |
+
Operations on Array that would create a scalar in NumPy create a 0-D
|
| 65 |
+
array.
|
| 66 |
+
|
| 67 |
+
- Indexing: Only a subset of indices supported by NumPy are required by the
|
| 68 |
+
spec. The Array object restricts indexing to only allow those types of
|
| 69 |
+
indices that are required by the spec. See the docstring of the
|
| 70 |
+
numpy.array_api.Array._validate_indices helper function for more
|
| 71 |
+
information.
|
| 72 |
+
|
| 73 |
+
- Type promotion: Some type promotion rules are different in the spec. In
|
| 74 |
+
particular, the spec does not have any value-based casting. The spec also
|
| 75 |
+
does not require cross-kind casting, like integer -> floating-point. Only
|
| 76 |
+
those promotions that are explicitly required by the array API
|
| 77 |
+
specification are allowed in this module. See NEP 47 for more info.
|
| 78 |
+
|
| 79 |
+
- Functions do not automatically call asarray() on their input, and will not
|
| 80 |
+
work if the input type is not Array. The exception is array creation
|
| 81 |
+
functions, and Python operators on the Array object, which accept Python
|
| 82 |
+
scalars of the same type as the array dtype.
|
| 83 |
+
|
| 84 |
+
- All functions include type annotations, corresponding to those given in the
|
| 85 |
+
spec (see _typing.py for definitions of some custom types). These do not
|
| 86 |
+
currently fully pass mypy due to some limitations in mypy.
|
| 87 |
+
|
| 88 |
+
- Dtype objects are just the NumPy dtype objects, e.g., float64 =
|
| 89 |
+
np.dtype('float64'). The spec does not require any behavior on these dtype
|
| 90 |
+
objects other than that they be accessible by name and be comparable by
|
| 91 |
+
equality, but it was considered too much extra complexity to create custom
|
| 92 |
+
objects to represent dtypes.
|
| 93 |
+
|
| 94 |
+
- All places where the implementations in this submodule are known to deviate
|
| 95 |
+
from their corresponding functions in NumPy are marked with "# Note:"
|
| 96 |
+
comments.
|
| 97 |
+
|
| 98 |
+
Still TODO in this module are:
|
| 99 |
+
|
| 100 |
+
- DLPack support for numpy.ndarray is still in progress. See
|
| 101 |
+
https://github.com/numpy/numpy/pull/19083.
|
| 102 |
+
|
| 103 |
+
- The copy=False keyword argument to asarray() is not yet implemented. This
|
| 104 |
+
requires support in numpy.asarray() first.
|
| 105 |
+
|
| 106 |
+
- Some functions are not yet fully tested in the array API test suite, and may
|
| 107 |
+
require updates that are not yet known until the tests are written.
|
| 108 |
+
|
| 109 |
+
- The spec is still in an RFC phase and may still have minor updates, which
|
| 110 |
+
will need to be reflected here.
|
| 111 |
+
|
| 112 |
+
- Complex number support in array API spec is planned but not yet finalized,
|
| 113 |
+
as are the fft extension and certain linear algebra functions such as eig
|
| 114 |
+
that require complex dtypes.
|
| 115 |
+
|
| 116 |
+
"""
|
| 117 |
+
|
| 118 |
+
import warnings
|
| 119 |
+
|
| 120 |
+
warnings.warn(
|
| 121 |
+
"The numpy.array_api submodule is still experimental. See NEP 47.", stacklevel=2
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
__array_api_version__ = "2022.12"
|
| 125 |
+
|
| 126 |
+
__all__ = ["__array_api_version__"]
|
| 127 |
+
|
| 128 |
+
from ._constants import e, inf, nan, pi, newaxis
|
| 129 |
+
|
| 130 |
+
__all__ += ["e", "inf", "nan", "pi", "newaxis"]
|
| 131 |
+
|
| 132 |
+
from ._creation_functions import (
|
| 133 |
+
asarray,
|
| 134 |
+
arange,
|
| 135 |
+
empty,
|
| 136 |
+
empty_like,
|
| 137 |
+
eye,
|
| 138 |
+
from_dlpack,
|
| 139 |
+
full,
|
| 140 |
+
full_like,
|
| 141 |
+
linspace,
|
| 142 |
+
meshgrid,
|
| 143 |
+
ones,
|
| 144 |
+
ones_like,
|
| 145 |
+
tril,
|
| 146 |
+
triu,
|
| 147 |
+
zeros,
|
| 148 |
+
zeros_like,
|
| 149 |
+
)
|
| 150 |
+
|
| 151 |
+
__all__ += [
|
| 152 |
+
"asarray",
|
| 153 |
+
"arange",
|
| 154 |
+
"empty",
|
| 155 |
+
"empty_like",
|
| 156 |
+
"eye",
|
| 157 |
+
"from_dlpack",
|
| 158 |
+
"full",
|
| 159 |
+
"full_like",
|
| 160 |
+
"linspace",
|
| 161 |
+
"meshgrid",
|
| 162 |
+
"ones",
|
| 163 |
+
"ones_like",
|
| 164 |
+
"tril",
|
| 165 |
+
"triu",
|
| 166 |
+
"zeros",
|
| 167 |
+
"zeros_like",
|
| 168 |
+
]
|
| 169 |
+
|
| 170 |
+
from ._data_type_functions import (
|
| 171 |
+
astype,
|
| 172 |
+
broadcast_arrays,
|
| 173 |
+
broadcast_to,
|
| 174 |
+
can_cast,
|
| 175 |
+
finfo,
|
| 176 |
+
isdtype,
|
| 177 |
+
iinfo,
|
| 178 |
+
result_type,
|
| 179 |
+
)
|
| 180 |
+
|
| 181 |
+
__all__ += [
|
| 182 |
+
"astype",
|
| 183 |
+
"broadcast_arrays",
|
| 184 |
+
"broadcast_to",
|
| 185 |
+
"can_cast",
|
| 186 |
+
"finfo",
|
| 187 |
+
"iinfo",
|
| 188 |
+
"result_type",
|
| 189 |
+
]
|
| 190 |
+
|
| 191 |
+
from ._dtypes import (
|
| 192 |
+
int8,
|
| 193 |
+
int16,
|
| 194 |
+
int32,
|
| 195 |
+
int64,
|
| 196 |
+
uint8,
|
| 197 |
+
uint16,
|
| 198 |
+
uint32,
|
| 199 |
+
uint64,
|
| 200 |
+
float32,
|
| 201 |
+
float64,
|
| 202 |
+
complex64,
|
| 203 |
+
complex128,
|
| 204 |
+
bool,
|
| 205 |
+
)
|
| 206 |
+
|
| 207 |
+
__all__ += [
|
| 208 |
+
"int8",
|
| 209 |
+
"int16",
|
| 210 |
+
"int32",
|
| 211 |
+
"int64",
|
| 212 |
+
"uint8",
|
| 213 |
+
"uint16",
|
| 214 |
+
"uint32",
|
| 215 |
+
"uint64",
|
| 216 |
+
"float32",
|
| 217 |
+
"float64",
|
| 218 |
+
"bool",
|
| 219 |
+
]
|
| 220 |
+
|
| 221 |
+
from ._elementwise_functions import (
|
| 222 |
+
abs,
|
| 223 |
+
acos,
|
| 224 |
+
acosh,
|
| 225 |
+
add,
|
| 226 |
+
asin,
|
| 227 |
+
asinh,
|
| 228 |
+
atan,
|
| 229 |
+
atan2,
|
| 230 |
+
atanh,
|
| 231 |
+
bitwise_and,
|
| 232 |
+
bitwise_left_shift,
|
| 233 |
+
bitwise_invert,
|
| 234 |
+
bitwise_or,
|
| 235 |
+
bitwise_right_shift,
|
| 236 |
+
bitwise_xor,
|
| 237 |
+
ceil,
|
| 238 |
+
conj,
|
| 239 |
+
cos,
|
| 240 |
+
cosh,
|
| 241 |
+
divide,
|
| 242 |
+
equal,
|
| 243 |
+
exp,
|
| 244 |
+
expm1,
|
| 245 |
+
floor,
|
| 246 |
+
floor_divide,
|
| 247 |
+
greater,
|
| 248 |
+
greater_equal,
|
| 249 |
+
imag,
|
| 250 |
+
isfinite,
|
| 251 |
+
isinf,
|
| 252 |
+
isnan,
|
| 253 |
+
less,
|
| 254 |
+
less_equal,
|
| 255 |
+
log,
|
| 256 |
+
log1p,
|
| 257 |
+
log2,
|
| 258 |
+
log10,
|
| 259 |
+
logaddexp,
|
| 260 |
+
logical_and,
|
| 261 |
+
logical_not,
|
| 262 |
+
logical_or,
|
| 263 |
+
logical_xor,
|
| 264 |
+
multiply,
|
| 265 |
+
negative,
|
| 266 |
+
not_equal,
|
| 267 |
+
positive,
|
| 268 |
+
pow,
|
| 269 |
+
real,
|
| 270 |
+
remainder,
|
| 271 |
+
round,
|
| 272 |
+
sign,
|
| 273 |
+
sin,
|
| 274 |
+
sinh,
|
| 275 |
+
square,
|
| 276 |
+
sqrt,
|
| 277 |
+
subtract,
|
| 278 |
+
tan,
|
| 279 |
+
tanh,
|
| 280 |
+
trunc,
|
| 281 |
+
)
|
| 282 |
+
|
| 283 |
+
__all__ += [
|
| 284 |
+
"abs",
|
| 285 |
+
"acos",
|
| 286 |
+
"acosh",
|
| 287 |
+
"add",
|
| 288 |
+
"asin",
|
| 289 |
+
"asinh",
|
| 290 |
+
"atan",
|
| 291 |
+
"atan2",
|
| 292 |
+
"atanh",
|
| 293 |
+
"bitwise_and",
|
| 294 |
+
"bitwise_left_shift",
|
| 295 |
+
"bitwise_invert",
|
| 296 |
+
"bitwise_or",
|
| 297 |
+
"bitwise_right_shift",
|
| 298 |
+
"bitwise_xor",
|
| 299 |
+
"ceil",
|
| 300 |
+
"cos",
|
| 301 |
+
"cosh",
|
| 302 |
+
"divide",
|
| 303 |
+
"equal",
|
| 304 |
+
"exp",
|
| 305 |
+
"expm1",
|
| 306 |
+
"floor",
|
| 307 |
+
"floor_divide",
|
| 308 |
+
"greater",
|
| 309 |
+
"greater_equal",
|
| 310 |
+
"isfinite",
|
| 311 |
+
"isinf",
|
| 312 |
+
"isnan",
|
| 313 |
+
"less",
|
| 314 |
+
"less_equal",
|
| 315 |
+
"log",
|
| 316 |
+
"log1p",
|
| 317 |
+
"log2",
|
| 318 |
+
"log10",
|
| 319 |
+
"logaddexp",
|
| 320 |
+
"logical_and",
|
| 321 |
+
"logical_not",
|
| 322 |
+
"logical_or",
|
| 323 |
+
"logical_xor",
|
| 324 |
+
"multiply",
|
| 325 |
+
"negative",
|
| 326 |
+
"not_equal",
|
| 327 |
+
"positive",
|
| 328 |
+
"pow",
|
| 329 |
+
"remainder",
|
| 330 |
+
"round",
|
| 331 |
+
"sign",
|
| 332 |
+
"sin",
|
| 333 |
+
"sinh",
|
| 334 |
+
"square",
|
| 335 |
+
"sqrt",
|
| 336 |
+
"subtract",
|
| 337 |
+
"tan",
|
| 338 |
+
"tanh",
|
| 339 |
+
"trunc",
|
| 340 |
+
]
|
| 341 |
+
|
| 342 |
+
from ._indexing_functions import take
|
| 343 |
+
|
| 344 |
+
__all__ += ["take"]
|
| 345 |
+
|
| 346 |
+
# linalg is an extension in the array API spec, which is a sub-namespace. Only
|
| 347 |
+
# a subset of functions in it are imported into the top-level namespace.
|
| 348 |
+
from . import linalg
|
| 349 |
+
|
| 350 |
+
__all__ += ["linalg"]
|
| 351 |
+
|
| 352 |
+
from .linalg import matmul, tensordot, matrix_transpose, vecdot
|
| 353 |
+
|
| 354 |
+
__all__ += ["matmul", "tensordot", "matrix_transpose", "vecdot"]
|
| 355 |
+
|
| 356 |
+
from ._manipulation_functions import (
|
| 357 |
+
concat,
|
| 358 |
+
expand_dims,
|
| 359 |
+
flip,
|
| 360 |
+
permute_dims,
|
| 361 |
+
reshape,
|
| 362 |
+
roll,
|
| 363 |
+
squeeze,
|
| 364 |
+
stack,
|
| 365 |
+
)
|
| 366 |
+
|
| 367 |
+
__all__ += ["concat", "expand_dims", "flip", "permute_dims", "reshape", "roll", "squeeze", "stack"]
|
| 368 |
+
|
| 369 |
+
from ._searching_functions import argmax, argmin, nonzero, where
|
| 370 |
+
|
| 371 |
+
__all__ += ["argmax", "argmin", "nonzero", "where"]
|
| 372 |
+
|
| 373 |
+
from ._set_functions import unique_all, unique_counts, unique_inverse, unique_values
|
| 374 |
+
|
| 375 |
+
__all__ += ["unique_all", "unique_counts", "unique_inverse", "unique_values"]
|
| 376 |
+
|
| 377 |
+
from ._sorting_functions import argsort, sort
|
| 378 |
+
|
| 379 |
+
__all__ += ["argsort", "sort"]
|
| 380 |
+
|
| 381 |
+
from ._statistical_functions import max, mean, min, prod, std, sum, var
|
| 382 |
+
|
| 383 |
+
__all__ += ["max", "mean", "min", "prod", "std", "sum", "var"]
|
| 384 |
+
|
| 385 |
+
from ._utility_functions import all, any
|
| 386 |
+
|
| 387 |
+
__all__ += ["all", "any"]
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/array_api/_indexing_functions.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from ._array_object import Array
|
| 4 |
+
from ._dtypes import _integer_dtypes
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
|
| 8 |
+
def take(x: Array, indices: Array, /, *, axis: Optional[int] = None) -> Array:
|
| 9 |
+
"""
|
| 10 |
+
Array API compatible wrapper for :py:func:`np.take <numpy.take>`.
|
| 11 |
+
|
| 12 |
+
See its docstring for more information.
|
| 13 |
+
"""
|
| 14 |
+
if axis is None and x.ndim != 1:
|
| 15 |
+
raise ValueError("axis must be specified when ndim > 1")
|
| 16 |
+
if indices.dtype not in _integer_dtypes:
|
| 17 |
+
raise TypeError("Only integer dtypes are allowed in indexing")
|
| 18 |
+
if indices.ndim != 1:
|
| 19 |
+
raise ValueError("Only 1-dim indices array is supported")
|
| 20 |
+
return Array._new(np.take(x._array, indices._array, axis=axis))
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/array_api/linalg.py
ADDED
|
@@ -0,0 +1,466 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from ._dtypes import (
|
| 4 |
+
_floating_dtypes,
|
| 5 |
+
_numeric_dtypes,
|
| 6 |
+
float32,
|
| 7 |
+
float64,
|
| 8 |
+
complex64,
|
| 9 |
+
complex128
|
| 10 |
+
)
|
| 11 |
+
from ._manipulation_functions import reshape
|
| 12 |
+
from ._elementwise_functions import conj
|
| 13 |
+
from ._array_object import Array
|
| 14 |
+
|
| 15 |
+
from ..core.numeric import normalize_axis_tuple
|
| 16 |
+
|
| 17 |
+
from typing import TYPE_CHECKING
|
| 18 |
+
if TYPE_CHECKING:
|
| 19 |
+
from ._typing import Literal, Optional, Sequence, Tuple, Union, Dtype
|
| 20 |
+
|
| 21 |
+
from typing import NamedTuple
|
| 22 |
+
|
| 23 |
+
import numpy.linalg
|
| 24 |
+
import numpy as np
|
| 25 |
+
|
| 26 |
+
class EighResult(NamedTuple):
|
| 27 |
+
eigenvalues: Array
|
| 28 |
+
eigenvectors: Array
|
| 29 |
+
|
| 30 |
+
class QRResult(NamedTuple):
|
| 31 |
+
Q: Array
|
| 32 |
+
R: Array
|
| 33 |
+
|
| 34 |
+
class SlogdetResult(NamedTuple):
|
| 35 |
+
sign: Array
|
| 36 |
+
logabsdet: Array
|
| 37 |
+
|
| 38 |
+
class SVDResult(NamedTuple):
|
| 39 |
+
U: Array
|
| 40 |
+
S: Array
|
| 41 |
+
Vh: Array
|
| 42 |
+
|
| 43 |
+
# Note: the inclusion of the upper keyword is different from
|
| 44 |
+
# np.linalg.cholesky, which does not have it.
|
| 45 |
+
def cholesky(x: Array, /, *, upper: bool = False) -> Array:
|
| 46 |
+
"""
|
| 47 |
+
Array API compatible wrapper for :py:func:`np.linalg.cholesky <numpy.linalg.cholesky>`.
|
| 48 |
+
|
| 49 |
+
See its docstring for more information.
|
| 50 |
+
"""
|
| 51 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 52 |
+
# np.linalg.cholesky.
|
| 53 |
+
if x.dtype not in _floating_dtypes:
|
| 54 |
+
raise TypeError('Only floating-point dtypes are allowed in cholesky')
|
| 55 |
+
L = np.linalg.cholesky(x._array)
|
| 56 |
+
if upper:
|
| 57 |
+
U = Array._new(L).mT
|
| 58 |
+
if U.dtype in [complex64, complex128]:
|
| 59 |
+
U = conj(U)
|
| 60 |
+
return U
|
| 61 |
+
return Array._new(L)
|
| 62 |
+
|
| 63 |
+
# Note: cross is the numpy top-level namespace, not np.linalg
|
| 64 |
+
def cross(x1: Array, x2: Array, /, *, axis: int = -1) -> Array:
|
| 65 |
+
"""
|
| 66 |
+
Array API compatible wrapper for :py:func:`np.cross <numpy.cross>`.
|
| 67 |
+
|
| 68 |
+
See its docstring for more information.
|
| 69 |
+
"""
|
| 70 |
+
if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
|
| 71 |
+
raise TypeError('Only numeric dtypes are allowed in cross')
|
| 72 |
+
# Note: this is different from np.cross(), which broadcasts
|
| 73 |
+
if x1.shape != x2.shape:
|
| 74 |
+
raise ValueError('x1 and x2 must have the same shape')
|
| 75 |
+
if x1.ndim == 0:
|
| 76 |
+
raise ValueError('cross() requires arrays of dimension at least 1')
|
| 77 |
+
# Note: this is different from np.cross(), which allows dimension 2
|
| 78 |
+
if x1.shape[axis] != 3:
|
| 79 |
+
raise ValueError('cross() dimension must equal 3')
|
| 80 |
+
return Array._new(np.cross(x1._array, x2._array, axis=axis))
|
| 81 |
+
|
| 82 |
+
def det(x: Array, /) -> Array:
|
| 83 |
+
"""
|
| 84 |
+
Array API compatible wrapper for :py:func:`np.linalg.det <numpy.linalg.det>`.
|
| 85 |
+
|
| 86 |
+
See its docstring for more information.
|
| 87 |
+
"""
|
| 88 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 89 |
+
# np.linalg.det.
|
| 90 |
+
if x.dtype not in _floating_dtypes:
|
| 91 |
+
raise TypeError('Only floating-point dtypes are allowed in det')
|
| 92 |
+
return Array._new(np.linalg.det(x._array))
|
| 93 |
+
|
| 94 |
+
# Note: diagonal is the numpy top-level namespace, not np.linalg
|
| 95 |
+
def diagonal(x: Array, /, *, offset: int = 0) -> Array:
|
| 96 |
+
"""
|
| 97 |
+
Array API compatible wrapper for :py:func:`np.diagonal <numpy.diagonal>`.
|
| 98 |
+
|
| 99 |
+
See its docstring for more information.
|
| 100 |
+
"""
|
| 101 |
+
# Note: diagonal always operates on the last two axes, whereas np.diagonal
|
| 102 |
+
# operates on the first two axes by default
|
| 103 |
+
return Array._new(np.diagonal(x._array, offset=offset, axis1=-2, axis2=-1))
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def eigh(x: Array, /) -> EighResult:
|
| 107 |
+
"""
|
| 108 |
+
Array API compatible wrapper for :py:func:`np.linalg.eigh <numpy.linalg.eigh>`.
|
| 109 |
+
|
| 110 |
+
See its docstring for more information.
|
| 111 |
+
"""
|
| 112 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 113 |
+
# np.linalg.eigh.
|
| 114 |
+
if x.dtype not in _floating_dtypes:
|
| 115 |
+
raise TypeError('Only floating-point dtypes are allowed in eigh')
|
| 116 |
+
|
| 117 |
+
# Note: the return type here is a namedtuple, which is different from
|
| 118 |
+
# np.eigh, which only returns a tuple.
|
| 119 |
+
return EighResult(*map(Array._new, np.linalg.eigh(x._array)))
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def eigvalsh(x: Array, /) -> Array:
|
| 123 |
+
"""
|
| 124 |
+
Array API compatible wrapper for :py:func:`np.linalg.eigvalsh <numpy.linalg.eigvalsh>`.
|
| 125 |
+
|
| 126 |
+
See its docstring for more information.
|
| 127 |
+
"""
|
| 128 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 129 |
+
# np.linalg.eigvalsh.
|
| 130 |
+
if x.dtype not in _floating_dtypes:
|
| 131 |
+
raise TypeError('Only floating-point dtypes are allowed in eigvalsh')
|
| 132 |
+
|
| 133 |
+
return Array._new(np.linalg.eigvalsh(x._array))
|
| 134 |
+
|
| 135 |
+
def inv(x: Array, /) -> Array:
|
| 136 |
+
"""
|
| 137 |
+
Array API compatible wrapper for :py:func:`np.linalg.inv <numpy.linalg.inv>`.
|
| 138 |
+
|
| 139 |
+
See its docstring for more information.
|
| 140 |
+
"""
|
| 141 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 142 |
+
# np.linalg.inv.
|
| 143 |
+
if x.dtype not in _floating_dtypes:
|
| 144 |
+
raise TypeError('Only floating-point dtypes are allowed in inv')
|
| 145 |
+
|
| 146 |
+
return Array._new(np.linalg.inv(x._array))
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
# Note: matmul is the numpy top-level namespace but not in np.linalg
|
| 150 |
+
def matmul(x1: Array, x2: Array, /) -> Array:
|
| 151 |
+
"""
|
| 152 |
+
Array API compatible wrapper for :py:func:`np.matmul <numpy.matmul>`.
|
| 153 |
+
|
| 154 |
+
See its docstring for more information.
|
| 155 |
+
"""
|
| 156 |
+
# Note: the restriction to numeric dtypes only is different from
|
| 157 |
+
# np.matmul.
|
| 158 |
+
if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
|
| 159 |
+
raise TypeError('Only numeric dtypes are allowed in matmul')
|
| 160 |
+
|
| 161 |
+
return Array._new(np.matmul(x1._array, x2._array))
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
# Note: the name here is different from norm(). The array API norm is split
|
| 165 |
+
# into matrix_norm and vector_norm().
|
| 166 |
+
|
| 167 |
+
# The type for ord should be Optional[Union[int, float, Literal[np.inf,
|
| 168 |
+
# -np.inf, 'fro', 'nuc']]], but Literal does not support floating-point
|
| 169 |
+
# literals.
|
| 170 |
+
def matrix_norm(x: Array, /, *, keepdims: bool = False, ord: Optional[Union[int, float, Literal['fro', 'nuc']]] = 'fro') -> Array:
|
| 171 |
+
"""
|
| 172 |
+
Array API compatible wrapper for :py:func:`np.linalg.norm <numpy.linalg.norm>`.
|
| 173 |
+
|
| 174 |
+
See its docstring for more information.
|
| 175 |
+
"""
|
| 176 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 177 |
+
# np.linalg.norm.
|
| 178 |
+
if x.dtype not in _floating_dtypes:
|
| 179 |
+
raise TypeError('Only floating-point dtypes are allowed in matrix_norm')
|
| 180 |
+
|
| 181 |
+
return Array._new(np.linalg.norm(x._array, axis=(-2, -1), keepdims=keepdims, ord=ord))
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
def matrix_power(x: Array, n: int, /) -> Array:
|
| 185 |
+
"""
|
| 186 |
+
Array API compatible wrapper for :py:func:`np.matrix_power <numpy.matrix_power>`.
|
| 187 |
+
|
| 188 |
+
See its docstring for more information.
|
| 189 |
+
"""
|
| 190 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 191 |
+
# np.linalg.matrix_power.
|
| 192 |
+
if x.dtype not in _floating_dtypes:
|
| 193 |
+
raise TypeError('Only floating-point dtypes are allowed for the first argument of matrix_power')
|
| 194 |
+
|
| 195 |
+
# np.matrix_power already checks if n is an integer
|
| 196 |
+
return Array._new(np.linalg.matrix_power(x._array, n))
|
| 197 |
+
|
| 198 |
+
# Note: the keyword argument name rtol is different from np.linalg.matrix_rank
|
| 199 |
+
def matrix_rank(x: Array, /, *, rtol: Optional[Union[float, Array]] = None) -> Array:
|
| 200 |
+
"""
|
| 201 |
+
Array API compatible wrapper for :py:func:`np.matrix_rank <numpy.matrix_rank>`.
|
| 202 |
+
|
| 203 |
+
See its docstring for more information.
|
| 204 |
+
"""
|
| 205 |
+
# Note: this is different from np.linalg.matrix_rank, which supports 1
|
| 206 |
+
# dimensional arrays.
|
| 207 |
+
if x.ndim < 2:
|
| 208 |
+
raise np.linalg.LinAlgError("1-dimensional array given. Array must be at least two-dimensional")
|
| 209 |
+
S = np.linalg.svd(x._array, compute_uv=False)
|
| 210 |
+
if rtol is None:
|
| 211 |
+
tol = S.max(axis=-1, keepdims=True) * max(x.shape[-2:]) * np.finfo(S.dtype).eps
|
| 212 |
+
else:
|
| 213 |
+
if isinstance(rtol, Array):
|
| 214 |
+
rtol = rtol._array
|
| 215 |
+
# Note: this is different from np.linalg.matrix_rank, which does not multiply
|
| 216 |
+
# the tolerance by the largest singular value.
|
| 217 |
+
tol = S.max(axis=-1, keepdims=True)*np.asarray(rtol)[..., np.newaxis]
|
| 218 |
+
return Array._new(np.count_nonzero(S > tol, axis=-1))
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
# Note: this function is new in the array API spec. Unlike transpose, it only
|
| 222 |
+
# transposes the last two axes.
|
| 223 |
+
def matrix_transpose(x: Array, /) -> Array:
|
| 224 |
+
if x.ndim < 2:
|
| 225 |
+
raise ValueError("x must be at least 2-dimensional for matrix_transpose")
|
| 226 |
+
return Array._new(np.swapaxes(x._array, -1, -2))
|
| 227 |
+
|
| 228 |
+
# Note: outer is the numpy top-level namespace, not np.linalg
|
| 229 |
+
def outer(x1: Array, x2: Array, /) -> Array:
|
| 230 |
+
"""
|
| 231 |
+
Array API compatible wrapper for :py:func:`np.outer <numpy.outer>`.
|
| 232 |
+
|
| 233 |
+
See its docstring for more information.
|
| 234 |
+
"""
|
| 235 |
+
# Note: the restriction to numeric dtypes only is different from
|
| 236 |
+
# np.outer.
|
| 237 |
+
if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
|
| 238 |
+
raise TypeError('Only numeric dtypes are allowed in outer')
|
| 239 |
+
|
| 240 |
+
# Note: the restriction to only 1-dim arrays is different from np.outer
|
| 241 |
+
if x1.ndim != 1 or x2.ndim != 1:
|
| 242 |
+
raise ValueError('The input arrays to outer must be 1-dimensional')
|
| 243 |
+
|
| 244 |
+
return Array._new(np.outer(x1._array, x2._array))
|
| 245 |
+
|
| 246 |
+
# Note: the keyword argument name rtol is different from np.linalg.pinv
|
| 247 |
+
def pinv(x: Array, /, *, rtol: Optional[Union[float, Array]] = None) -> Array:
|
| 248 |
+
"""
|
| 249 |
+
Array API compatible wrapper for :py:func:`np.linalg.pinv <numpy.linalg.pinv>`.
|
| 250 |
+
|
| 251 |
+
See its docstring for more information.
|
| 252 |
+
"""
|
| 253 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 254 |
+
# np.linalg.pinv.
|
| 255 |
+
if x.dtype not in _floating_dtypes:
|
| 256 |
+
raise TypeError('Only floating-point dtypes are allowed in pinv')
|
| 257 |
+
|
| 258 |
+
# Note: this is different from np.linalg.pinv, which does not multiply the
|
| 259 |
+
# default tolerance by max(M, N).
|
| 260 |
+
if rtol is None:
|
| 261 |
+
rtol = max(x.shape[-2:]) * np.finfo(x.dtype).eps
|
| 262 |
+
return Array._new(np.linalg.pinv(x._array, rcond=rtol))
|
| 263 |
+
|
| 264 |
+
def qr(x: Array, /, *, mode: Literal['reduced', 'complete'] = 'reduced') -> QRResult:
|
| 265 |
+
"""
|
| 266 |
+
Array API compatible wrapper for :py:func:`np.linalg.qr <numpy.linalg.qr>`.
|
| 267 |
+
|
| 268 |
+
See its docstring for more information.
|
| 269 |
+
"""
|
| 270 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 271 |
+
# np.linalg.qr.
|
| 272 |
+
if x.dtype not in _floating_dtypes:
|
| 273 |
+
raise TypeError('Only floating-point dtypes are allowed in qr')
|
| 274 |
+
|
| 275 |
+
# Note: the return type here is a namedtuple, which is different from
|
| 276 |
+
# np.linalg.qr, which only returns a tuple.
|
| 277 |
+
return QRResult(*map(Array._new, np.linalg.qr(x._array, mode=mode)))
|
| 278 |
+
|
| 279 |
+
def slogdet(x: Array, /) -> SlogdetResult:
|
| 280 |
+
"""
|
| 281 |
+
Array API compatible wrapper for :py:func:`np.linalg.slogdet <numpy.linalg.slogdet>`.
|
| 282 |
+
|
| 283 |
+
See its docstring for more information.
|
| 284 |
+
"""
|
| 285 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 286 |
+
# np.linalg.slogdet.
|
| 287 |
+
if x.dtype not in _floating_dtypes:
|
| 288 |
+
raise TypeError('Only floating-point dtypes are allowed in slogdet')
|
| 289 |
+
|
| 290 |
+
# Note: the return type here is a namedtuple, which is different from
|
| 291 |
+
# np.linalg.slogdet, which only returns a tuple.
|
| 292 |
+
return SlogdetResult(*map(Array._new, np.linalg.slogdet(x._array)))
|
| 293 |
+
|
| 294 |
+
# Note: unlike np.linalg.solve, the array API solve() only accepts x2 as a
|
| 295 |
+
# vector when it is exactly 1-dimensional. All other cases treat x2 as a stack
|
| 296 |
+
# of matrices. The np.linalg.solve behavior of allowing stacks of both
|
| 297 |
+
# matrices and vectors is ambiguous c.f.
|
| 298 |
+
# https://github.com/numpy/numpy/issues/15349 and
|
| 299 |
+
# https://github.com/data-apis/array-api/issues/285.
|
| 300 |
+
|
| 301 |
+
# To workaround this, the below is the code from np.linalg.solve except
|
| 302 |
+
# only calling solve1 in the exactly 1D case.
|
| 303 |
+
def _solve(a, b):
|
| 304 |
+
from ..linalg.linalg import (_makearray, _assert_stacked_2d,
|
| 305 |
+
_assert_stacked_square, _commonType,
|
| 306 |
+
isComplexType, get_linalg_error_extobj,
|
| 307 |
+
_raise_linalgerror_singular)
|
| 308 |
+
from ..linalg import _umath_linalg
|
| 309 |
+
|
| 310 |
+
a, _ = _makearray(a)
|
| 311 |
+
_assert_stacked_2d(a)
|
| 312 |
+
_assert_stacked_square(a)
|
| 313 |
+
b, wrap = _makearray(b)
|
| 314 |
+
t, result_t = _commonType(a, b)
|
| 315 |
+
|
| 316 |
+
# This part is different from np.linalg.solve
|
| 317 |
+
if b.ndim == 1:
|
| 318 |
+
gufunc = _umath_linalg.solve1
|
| 319 |
+
else:
|
| 320 |
+
gufunc = _umath_linalg.solve
|
| 321 |
+
|
| 322 |
+
# This does nothing currently but is left in because it will be relevant
|
| 323 |
+
# when complex dtype support is added to the spec in 2022.
|
| 324 |
+
signature = 'DD->D' if isComplexType(t) else 'dd->d'
|
| 325 |
+
with np.errstate(call=_raise_linalgerror_singular, invalid='call',
|
| 326 |
+
over='ignore', divide='ignore', under='ignore'):
|
| 327 |
+
r = gufunc(a, b, signature=signature)
|
| 328 |
+
|
| 329 |
+
return wrap(r.astype(result_t, copy=False))
|
| 330 |
+
|
| 331 |
+
def solve(x1: Array, x2: Array, /) -> Array:
|
| 332 |
+
"""
|
| 333 |
+
Array API compatible wrapper for :py:func:`np.linalg.solve <numpy.linalg.solve>`.
|
| 334 |
+
|
| 335 |
+
See its docstring for more information.
|
| 336 |
+
"""
|
| 337 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 338 |
+
# np.linalg.solve.
|
| 339 |
+
if x1.dtype not in _floating_dtypes or x2.dtype not in _floating_dtypes:
|
| 340 |
+
raise TypeError('Only floating-point dtypes are allowed in solve')
|
| 341 |
+
|
| 342 |
+
return Array._new(_solve(x1._array, x2._array))
|
| 343 |
+
|
| 344 |
+
def svd(x: Array, /, *, full_matrices: bool = True) -> SVDResult:
|
| 345 |
+
"""
|
| 346 |
+
Array API compatible wrapper for :py:func:`np.linalg.svd <numpy.linalg.svd>`.
|
| 347 |
+
|
| 348 |
+
See its docstring for more information.
|
| 349 |
+
"""
|
| 350 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 351 |
+
# np.linalg.svd.
|
| 352 |
+
if x.dtype not in _floating_dtypes:
|
| 353 |
+
raise TypeError('Only floating-point dtypes are allowed in svd')
|
| 354 |
+
|
| 355 |
+
# Note: the return type here is a namedtuple, which is different from
|
| 356 |
+
# np.svd, which only returns a tuple.
|
| 357 |
+
return SVDResult(*map(Array._new, np.linalg.svd(x._array, full_matrices=full_matrices)))
|
| 358 |
+
|
| 359 |
+
# Note: svdvals is not in NumPy (but it is in SciPy). It is equivalent to
|
| 360 |
+
# np.linalg.svd(compute_uv=False).
|
| 361 |
+
def svdvals(x: Array, /) -> Union[Array, Tuple[Array, ...]]:
|
| 362 |
+
if x.dtype not in _floating_dtypes:
|
| 363 |
+
raise TypeError('Only floating-point dtypes are allowed in svdvals')
|
| 364 |
+
return Array._new(np.linalg.svd(x._array, compute_uv=False))
|
| 365 |
+
|
| 366 |
+
# Note: tensordot is the numpy top-level namespace but not in np.linalg
|
| 367 |
+
|
| 368 |
+
# Note: axes must be a tuple, unlike np.tensordot where it can be an array or array-like.
|
| 369 |
+
def tensordot(x1: Array, x2: Array, /, *, axes: Union[int, Tuple[Sequence[int], Sequence[int]]] = 2) -> Array:
|
| 370 |
+
# Note: the restriction to numeric dtypes only is different from
|
| 371 |
+
# np.tensordot.
|
| 372 |
+
if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
|
| 373 |
+
raise TypeError('Only numeric dtypes are allowed in tensordot')
|
| 374 |
+
|
| 375 |
+
return Array._new(np.tensordot(x1._array, x2._array, axes=axes))
|
| 376 |
+
|
| 377 |
+
# Note: trace is the numpy top-level namespace, not np.linalg
|
| 378 |
+
def trace(x: Array, /, *, offset: int = 0, dtype: Optional[Dtype] = None) -> Array:
|
| 379 |
+
"""
|
| 380 |
+
Array API compatible wrapper for :py:func:`np.trace <numpy.trace>`.
|
| 381 |
+
|
| 382 |
+
See its docstring for more information.
|
| 383 |
+
"""
|
| 384 |
+
if x.dtype not in _numeric_dtypes:
|
| 385 |
+
raise TypeError('Only numeric dtypes are allowed in trace')
|
| 386 |
+
|
| 387 |
+
# Note: trace() works the same as sum() and prod() (see
|
| 388 |
+
# _statistical_functions.py)
|
| 389 |
+
if dtype is None:
|
| 390 |
+
if x.dtype == float32:
|
| 391 |
+
dtype = float64
|
| 392 |
+
elif x.dtype == complex64:
|
| 393 |
+
dtype = complex128
|
| 394 |
+
# Note: trace always operates on the last two axes, whereas np.trace
|
| 395 |
+
# operates on the first two axes by default
|
| 396 |
+
return Array._new(np.asarray(np.trace(x._array, offset=offset, axis1=-2, axis2=-1, dtype=dtype)))
|
| 397 |
+
|
| 398 |
+
# Note: vecdot is not in NumPy
|
| 399 |
+
def vecdot(x1: Array, x2: Array, /, *, axis: int = -1) -> Array:
|
| 400 |
+
if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
|
| 401 |
+
raise TypeError('Only numeric dtypes are allowed in vecdot')
|
| 402 |
+
ndim = max(x1.ndim, x2.ndim)
|
| 403 |
+
x1_shape = (1,)*(ndim - x1.ndim) + tuple(x1.shape)
|
| 404 |
+
x2_shape = (1,)*(ndim - x2.ndim) + tuple(x2.shape)
|
| 405 |
+
if x1_shape[axis] != x2_shape[axis]:
|
| 406 |
+
raise ValueError("x1 and x2 must have the same size along the given axis")
|
| 407 |
+
|
| 408 |
+
x1_, x2_ = np.broadcast_arrays(x1._array, x2._array)
|
| 409 |
+
x1_ = np.moveaxis(x1_, axis, -1)
|
| 410 |
+
x2_ = np.moveaxis(x2_, axis, -1)
|
| 411 |
+
|
| 412 |
+
res = x1_[..., None, :] @ x2_[..., None]
|
| 413 |
+
return Array._new(res[..., 0, 0])
|
| 414 |
+
|
| 415 |
+
|
| 416 |
+
# Note: the name here is different from norm(). The array API norm is split
|
| 417 |
+
# into matrix_norm and vector_norm().
|
| 418 |
+
|
| 419 |
+
# The type for ord should be Optional[Union[int, float, Literal[np.inf,
|
| 420 |
+
# -np.inf]]] but Literal does not support floating-point literals.
|
| 421 |
+
def vector_norm(x: Array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, keepdims: bool = False, ord: Optional[Union[int, float]] = 2) -> Array:
|
| 422 |
+
"""
|
| 423 |
+
Array API compatible wrapper for :py:func:`np.linalg.norm <numpy.linalg.norm>`.
|
| 424 |
+
|
| 425 |
+
See its docstring for more information.
|
| 426 |
+
"""
|
| 427 |
+
# Note: the restriction to floating-point dtypes only is different from
|
| 428 |
+
# np.linalg.norm.
|
| 429 |
+
if x.dtype not in _floating_dtypes:
|
| 430 |
+
raise TypeError('Only floating-point dtypes are allowed in norm')
|
| 431 |
+
|
| 432 |
+
# np.linalg.norm tries to do a matrix norm whenever axis is a 2-tuple or
|
| 433 |
+
# when axis=None and the input is 2-D, so to force a vector norm, we make
|
| 434 |
+
# it so the input is 1-D (for axis=None), or reshape so that norm is done
|
| 435 |
+
# on a single dimension.
|
| 436 |
+
a = x._array
|
| 437 |
+
if axis is None:
|
| 438 |
+
# Note: np.linalg.norm() doesn't handle 0-D arrays
|
| 439 |
+
a = a.ravel()
|
| 440 |
+
_axis = 0
|
| 441 |
+
elif isinstance(axis, tuple):
|
| 442 |
+
# Note: The axis argument supports any number of axes, whereas
|
| 443 |
+
# np.linalg.norm() only supports a single axis for vector norm.
|
| 444 |
+
normalized_axis = normalize_axis_tuple(axis, x.ndim)
|
| 445 |
+
rest = tuple(i for i in range(a.ndim) if i not in normalized_axis)
|
| 446 |
+
newshape = axis + rest
|
| 447 |
+
a = np.transpose(a, newshape).reshape(
|
| 448 |
+
(np.prod([a.shape[i] for i in axis], dtype=int), *[a.shape[i] for i in rest]))
|
| 449 |
+
_axis = 0
|
| 450 |
+
else:
|
| 451 |
+
_axis = axis
|
| 452 |
+
|
| 453 |
+
res = Array._new(np.linalg.norm(a, axis=_axis, ord=ord))
|
| 454 |
+
|
| 455 |
+
if keepdims:
|
| 456 |
+
# We can't reuse np.linalg.norm(keepdims) because of the reshape hacks
|
| 457 |
+
# above to avoid matrix norm logic.
|
| 458 |
+
shape = list(x.shape)
|
| 459 |
+
_axis = normalize_axis_tuple(range(x.ndim) if axis is None else axis, x.ndim)
|
| 460 |
+
for i in _axis:
|
| 461 |
+
shape[i] = 1
|
| 462 |
+
res = reshape(res, tuple(shape))
|
| 463 |
+
|
| 464 |
+
return res
|
| 465 |
+
|
| 466 |
+
__all__ = ['cholesky', 'cross', 'det', 'diagonal', 'eigh', 'eigvalsh', 'inv', 'matmul', 'matrix_norm', 'matrix_power', 'matrix_rank', 'matrix_transpose', 'outer', 'pinv', 'qr', 'slogdet', 'solve', 'svd', 'svdvals', 'tensordot', 'trace', 'vecdot', 'vector_norm']
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/numpy/array_api/tests/test_set_functions.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
from hypothesis import given
|
| 3 |
+
from hypothesis.extra.array_api import make_strategies_namespace
|
| 4 |
+
|
| 5 |
+
from numpy import array_api as xp
|
| 6 |
+
|
| 7 |
+
xps = make_strategies_namespace(xp)
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
@pytest.mark.parametrize("func", [xp.unique_all, xp.unique_inverse])
|
| 11 |
+
@given(xps.arrays(dtype=xps.scalar_dtypes(), shape=xps.array_shapes()))
|
| 12 |
+
def test_inverse_indices_shape(func, x):
|
| 13 |
+
"""
|
| 14 |
+
Inverse indices share shape of input array
|
| 15 |
+
|
| 16 |
+
See https://github.com/numpy/numpy/issues/20638
|
| 17 |
+
"""
|
| 18 |
+
out = func(x)
|
| 19 |
+
assert out.inverse_indices.shape == x.shape
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/transformers/models/gemma/configuration_gemma.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 2 |
+
# This file was automatically generated from src/transformers/models/gemma/modular_gemma.py.
|
| 3 |
+
# Do NOT edit this file manually as any edits will be overwritten by the generation of
|
| 4 |
+
# the file from the modular. If any change should be done, please apply the change to the
|
| 5 |
+
# modular_gemma.py file directly. One of our CI enforces this.
|
| 6 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 7 |
+
# Copyright 2024 Google Inc. HuggingFace Inc. team. All rights reserved.
|
| 8 |
+
#
|
| 9 |
+
#
|
| 10 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 11 |
+
# you may not use this file except in compliance with the License.
|
| 12 |
+
# You may obtain a copy of the License at
|
| 13 |
+
#
|
| 14 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 15 |
+
#
|
| 16 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 17 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 18 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 19 |
+
# See the License for the specific language governing permissions and
|
| 20 |
+
# limitations under the License.
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
from huggingface_hub.dataclasses import strict
|
| 24 |
+
|
| 25 |
+
from ...configuration_utils import PreTrainedConfig
|
| 26 |
+
from ...modeling_rope_utils import RopeParameters
|
| 27 |
+
from ...utils import auto_docstring
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
@auto_docstring(checkpoint="google/gemma-7b")
|
| 31 |
+
@strict
|
| 32 |
+
class GemmaConfig(PreTrainedConfig):
|
| 33 |
+
r"""
|
| 34 |
+
use_bidirectional_attention (`bool`, *optional*):
|
| 35 |
+
If True, the model will attend to all text tokens instead of using a causal mask.
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
>>> from transformers import GemmaModel, GemmaConfig
|
| 39 |
+
>>> # Initializing a Gemma gemma-7b style configuration
|
| 40 |
+
>>> configuration = GemmaConfig()
|
| 41 |
+
>>> # Initializing a model from the gemma-7b style configuration
|
| 42 |
+
>>> model = GemmaModel(configuration)
|
| 43 |
+
>>> # Accessing the model configuration
|
| 44 |
+
>>> configuration = model.config
|
| 45 |
+
```"""
|
| 46 |
+
|
| 47 |
+
model_type = "gemma"
|
| 48 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 49 |
+
base_model_tp_plan = {
|
| 50 |
+
"layers.*.self_attn.q_proj": "colwise",
|
| 51 |
+
"layers.*.self_attn.k_proj": "colwise",
|
| 52 |
+
"layers.*.self_attn.v_proj": "colwise",
|
| 53 |
+
"layers.*.self_attn.o_proj": "rowwise",
|
| 54 |
+
"layers.*.mlp.gate_proj": "colwise",
|
| 55 |
+
"layers.*.mlp.up_proj": "colwise",
|
| 56 |
+
"layers.*.mlp.down_proj": "rowwise",
|
| 57 |
+
}
|
| 58 |
+
base_model_pp_plan = {
|
| 59 |
+
"embed_tokens": (["input_ids"], ["inputs_embeds"]),
|
| 60 |
+
"layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
|
| 61 |
+
"norm": (["hidden_states"], ["hidden_states"]),
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
vocab_size: int = 256000
|
| 65 |
+
hidden_size: int = 3072
|
| 66 |
+
intermediate_size: int = 24576
|
| 67 |
+
num_hidden_layers: int = 28
|
| 68 |
+
num_attention_heads: int = 16
|
| 69 |
+
num_key_value_heads: int = 16
|
| 70 |
+
head_dim: int = 256
|
| 71 |
+
hidden_act: str = "gelu_pytorch_tanh"
|
| 72 |
+
max_position_embeddings: int = 8192
|
| 73 |
+
initializer_range: float = 0.02
|
| 74 |
+
rms_norm_eps: float = 1e-6
|
| 75 |
+
use_cache: bool = True
|
| 76 |
+
pad_token_id: int | None = 0
|
| 77 |
+
eos_token_id: int | list[int] | None = 1
|
| 78 |
+
bos_token_id: int | None = 2
|
| 79 |
+
tie_word_embeddings: bool = True
|
| 80 |
+
rope_parameters: RopeParameters | dict | None = None
|
| 81 |
+
attention_bias: bool = False
|
| 82 |
+
attention_dropout: float | int = 0.0
|
| 83 |
+
use_bidirectional_attention: bool | None = None
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
__all__ = ["GemmaConfig"]
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/transformers/models/mistral3/configuration_mistral3.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2025 HuggingFace Inc. team. All rights reserved.
|
| 2 |
+
#
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
from huggingface_hub.dataclasses import strict
|
| 18 |
+
|
| 19 |
+
from ...configuration_utils import PreTrainedConfig
|
| 20 |
+
from ...utils import auto_docstring
|
| 21 |
+
from ..auto import CONFIG_MAPPING, AutoConfig
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
@auto_docstring(checkpoint="mistralai/Mistral-Small-3.1-24B-Instruct-2503")
|
| 25 |
+
@strict
|
| 26 |
+
class Mistral3Config(PreTrainedConfig):
|
| 27 |
+
r"""
|
| 28 |
+
Example:
|
| 29 |
+
|
| 30 |
+
```python
|
| 31 |
+
>>> from transformers import Mistral3ForConditionalGeneration, Mistral3Config, PixtralVisionConfig, MistralConfig
|
| 32 |
+
|
| 33 |
+
>>> # Initializing a Pixtral-vision config
|
| 34 |
+
>>> vision_config = PixtralVisionConfig()
|
| 35 |
+
|
| 36 |
+
>>> # Initializing a Mistral config
|
| 37 |
+
>>> text_config = MistralConfig()
|
| 38 |
+
|
| 39 |
+
>>> # Initializing a Mistral3 configuration
|
| 40 |
+
>>> configuration = Mistral3Config(vision_config, text_config)
|
| 41 |
+
|
| 42 |
+
>>> # Initializing a model from the mistral3.1 configuration
|
| 43 |
+
>>> model = Mistral3ForConditionalGeneration(configuration)
|
| 44 |
+
|
| 45 |
+
>>> # Accessing the model configuration
|
| 46 |
+
>>> configuration = model.config
|
| 47 |
+
```"""
|
| 48 |
+
|
| 49 |
+
model_type = "mistral3"
|
| 50 |
+
attribute_map = {
|
| 51 |
+
"image_token_id": "image_token_index",
|
| 52 |
+
}
|
| 53 |
+
sub_configs = {"text_config": AutoConfig, "vision_config": AutoConfig}
|
| 54 |
+
is_composition = True
|
| 55 |
+
|
| 56 |
+
vision_config: dict | PreTrainedConfig | None = None
|
| 57 |
+
text_config: dict | PreTrainedConfig | None = None
|
| 58 |
+
image_token_index: int = 10
|
| 59 |
+
projector_hidden_act: str = "gelu"
|
| 60 |
+
vision_feature_layer: int | list[int] = -1
|
| 61 |
+
multimodal_projector_bias: bool = False
|
| 62 |
+
spatial_merge_size: int = 2
|
| 63 |
+
tie_word_embeddings: bool = True
|
| 64 |
+
|
| 65 |
+
def __post_init__(self, **kwargs):
|
| 66 |
+
if isinstance(self.vision_config, dict):
|
| 67 |
+
self.vision_config["model_type"] = self.vision_config.get("model_type", "pixtral")
|
| 68 |
+
self.vision_config = CONFIG_MAPPING[self.vision_config["model_type"]](**self.vision_config)
|
| 69 |
+
elif self.vision_config is None:
|
| 70 |
+
self.vision_config = CONFIG_MAPPING["pixtral"](
|
| 71 |
+
intermediate_size=4096,
|
| 72 |
+
hidden_size=1024,
|
| 73 |
+
patch_size=14,
|
| 74 |
+
image_size=1540,
|
| 75 |
+
num_hidden_layers=24,
|
| 76 |
+
num_attention_heads=16,
|
| 77 |
+
vocab_size=32000,
|
| 78 |
+
head_dim=64,
|
| 79 |
+
hidden_act="gelu",
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
if isinstance(self.text_config, dict):
|
| 83 |
+
self.text_config["model_type"] = self.text_config.get("model_type", "mistral")
|
| 84 |
+
self.text_config = CONFIG_MAPPING[self.text_config["model_type"]](**self.text_config)
|
| 85 |
+
elif self.text_config is None:
|
| 86 |
+
self.text_config = CONFIG_MAPPING["mistral"](
|
| 87 |
+
attention_dropout=0.0,
|
| 88 |
+
head_dim=128,
|
| 89 |
+
hidden_act="silu",
|
| 90 |
+
hidden_size=5120,
|
| 91 |
+
initializer_range=0.02,
|
| 92 |
+
intermediate_size=32768,
|
| 93 |
+
max_position_embeddings=131072,
|
| 94 |
+
model_type="mistral",
|
| 95 |
+
num_attention_heads=32,
|
| 96 |
+
num_hidden_layers=40,
|
| 97 |
+
num_key_value_heads=8,
|
| 98 |
+
rms_norm_eps=1e-05,
|
| 99 |
+
rope_theta=1000000000.0,
|
| 100 |
+
sliding_window=None,
|
| 101 |
+
use_cache=True,
|
| 102 |
+
vocab_size=131072,
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
super().__post_init__(**kwargs)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
__all__ = ["Mistral3Config"]
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/transformers/models/mistral3/modeling_mistral3.py
ADDED
|
@@ -0,0 +1,464 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 2 |
+
# This file was automatically generated from src/transformers/models/mistral3/modular_mistral3.py.
|
| 3 |
+
# Do NOT edit this file manually as any edits will be overwritten by the generation of
|
| 4 |
+
# the file from the modular. If any change should be done, please apply the change to the
|
| 5 |
+
# modular_mistral3.py file directly. One of our CI enforces this.
|
| 6 |
+
# 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
|
| 7 |
+
# Copyright 2025 HuggingFace Inc. team. All rights reserved.
|
| 8 |
+
#
|
| 9 |
+
#
|
| 10 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 11 |
+
# you may not use this file except in compliance with the License.
|
| 12 |
+
# You may obtain a copy of the License at
|
| 13 |
+
#
|
| 14 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 15 |
+
#
|
| 16 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 17 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 18 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 19 |
+
# See the License for the specific language governing permissions and
|
| 20 |
+
# limitations under the License.
|
| 21 |
+
|
| 22 |
+
from dataclasses import dataclass
|
| 23 |
+
|
| 24 |
+
import torch
|
| 25 |
+
from torch import nn
|
| 26 |
+
|
| 27 |
+
from ...activations import ACT2FN
|
| 28 |
+
from ...cache_utils import Cache
|
| 29 |
+
from ...generation import GenerationMixin
|
| 30 |
+
from ...integrations import use_kernel_forward_from_hub
|
| 31 |
+
from ...modeling_outputs import BaseModelOutputWithPast, BaseModelOutputWithPooling, ModelOutput
|
| 32 |
+
from ...modeling_utils import PreTrainedModel
|
| 33 |
+
from ...processing_utils import Unpack
|
| 34 |
+
from ...utils import TransformersKwargs, auto_docstring, torch_compilable_check
|
| 35 |
+
from ...utils.generic import can_return_tuple, merge_with_config_defaults
|
| 36 |
+
from ..auto import AutoModel
|
| 37 |
+
from .configuration_mistral3 import Mistral3Config
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
@use_kernel_forward_from_hub("RMSNorm")
|
| 41 |
+
class Mistral3RMSNorm(nn.Module):
|
| 42 |
+
def __init__(self, hidden_size, eps: float = 1e-6) -> None:
|
| 43 |
+
"""
|
| 44 |
+
Mistral3RMSNorm is equivalent to T5LayerNorm
|
| 45 |
+
"""
|
| 46 |
+
super().__init__()
|
| 47 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 48 |
+
self.variance_epsilon = eps
|
| 49 |
+
|
| 50 |
+
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
| 51 |
+
input_dtype = hidden_states.dtype
|
| 52 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 53 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 54 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
| 55 |
+
return self.weight * hidden_states.to(input_dtype)
|
| 56 |
+
|
| 57 |
+
def extra_repr(self):
|
| 58 |
+
return f"{tuple(self.weight.shape)}, eps={self.variance_epsilon}"
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
class Mistral3PatchMerger(nn.Module):
|
| 62 |
+
"""
|
| 63 |
+
Learned merging of spatial_merge_size ** 2 patches
|
| 64 |
+
"""
|
| 65 |
+
|
| 66 |
+
def __init__(self, config: Mistral3Config):
|
| 67 |
+
super().__init__()
|
| 68 |
+
self.config = config
|
| 69 |
+
|
| 70 |
+
hidden_size = config.vision_config.hidden_size
|
| 71 |
+
self.spatial_merge_size = config.spatial_merge_size
|
| 72 |
+
self.patch_size = self.config.vision_config.patch_size
|
| 73 |
+
self.merging_layer = nn.Linear(hidden_size * self.spatial_merge_size**2, hidden_size, bias=False)
|
| 74 |
+
|
| 75 |
+
def forward(self, image_features: torch.Tensor, image_sizes: torch.Tensor) -> torch.Tensor:
|
| 76 |
+
image_sizes = [
|
| 77 |
+
(image_size[0] // self.patch_size, image_size[1] // self.patch_size) for image_size in image_sizes
|
| 78 |
+
]
|
| 79 |
+
|
| 80 |
+
tokens_per_image = [h * w for h, w in image_sizes]
|
| 81 |
+
d = image_features.shape[-1]
|
| 82 |
+
|
| 83 |
+
permuted_tensor = []
|
| 84 |
+
for image_index, image_tokens in enumerate(image_features.split(tokens_per_image)):
|
| 85 |
+
# Reshape image_tokens into a 2D grid
|
| 86 |
+
h, w = image_sizes[image_index]
|
| 87 |
+
image_grid = image_tokens.view(h, w, d).permute(2, 0, 1).unsqueeze(0)
|
| 88 |
+
grid = torch.nn.functional.unfold(
|
| 89 |
+
image_grid, kernel_size=self.spatial_merge_size, stride=self.spatial_merge_size
|
| 90 |
+
)
|
| 91 |
+
grid = grid.view(d * self.spatial_merge_size**2, -1).t()
|
| 92 |
+
permuted_tensor.append(grid)
|
| 93 |
+
|
| 94 |
+
image_features = torch.cat(permuted_tensor, dim=0)
|
| 95 |
+
image_features = self.merging_layer(image_features)
|
| 96 |
+
return image_features
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
class Mistral3MultiModalProjector(nn.Module):
|
| 100 |
+
def __init__(self, config: Mistral3Config):
|
| 101 |
+
super().__init__()
|
| 102 |
+
self.norm = Mistral3RMSNorm(config.vision_config.hidden_size, eps=config.text_config.rms_norm_eps)
|
| 103 |
+
self.patch_merger = Mistral3PatchMerger(config)
|
| 104 |
+
# We have hidden_size * the number of vision feature layers
|
| 105 |
+
self.num_feature_layers = (
|
| 106 |
+
1 if isinstance(config.vision_feature_layer, int) else len(config.vision_feature_layer)
|
| 107 |
+
)
|
| 108 |
+
self.linear_1 = nn.Linear(
|
| 109 |
+
config.vision_config.hidden_size * self.num_feature_layers,
|
| 110 |
+
config.text_config.hidden_size,
|
| 111 |
+
bias=config.multimodal_projector_bias,
|
| 112 |
+
)
|
| 113 |
+
self.act = ACT2FN[config.projector_hidden_act]
|
| 114 |
+
self.linear_2 = nn.Linear(
|
| 115 |
+
config.text_config.hidden_size, config.text_config.hidden_size, bias=config.multimodal_projector_bias
|
| 116 |
+
)
|
| 117 |
+
|
| 118 |
+
def forward(self, image_features: torch.Tensor, image_sizes: torch.Tensor):
|
| 119 |
+
image_features = self.norm(image_features)
|
| 120 |
+
image_features = self.patch_merger(image_features, image_sizes)
|
| 121 |
+
hidden_states = self.linear_1(image_features)
|
| 122 |
+
hidden_states = self.act(hidden_states)
|
| 123 |
+
hidden_states = self.linear_2(hidden_states)
|
| 124 |
+
return hidden_states
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
@auto_docstring(
|
| 128 |
+
custom_intro="""
|
| 129 |
+
Base class for Mistral3 causal language model (or autoregressive) outputs.
|
| 130 |
+
"""
|
| 131 |
+
)
|
| 132 |
+
@dataclass
|
| 133 |
+
class Mistral3CausalLMOutputWithPast(ModelOutput):
|
| 134 |
+
r"""
|
| 135 |
+
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
|
| 136 |
+
Language modeling loss (for next-token prediction).
|
| 137 |
+
logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):
|
| 138 |
+
Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
|
| 139 |
+
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
|
| 140 |
+
It is a [`~cache_utils.Cache`] instance. For more details, see our [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache).
|
| 141 |
+
|
| 142 |
+
Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
|
| 143 |
+
`past_key_values` input) to speed up sequential decoding.
|
| 144 |
+
image_hidden_states (`torch.FloatTensor`, *optional*):
|
| 145 |
+
A `torch.FloatTensor` of size `(batch_size, num_images, sequence_length, hidden_size)`.
|
| 146 |
+
image_hidden_states of the model produced by the vision encoder and after projecting the last hidden state.
|
| 147 |
+
"""
|
| 148 |
+
|
| 149 |
+
loss: torch.FloatTensor | None = None
|
| 150 |
+
logits: torch.FloatTensor | None = None
|
| 151 |
+
past_key_values: Cache | None = None
|
| 152 |
+
hidden_states: tuple[torch.FloatTensor] | None = None
|
| 153 |
+
attentions: tuple[torch.FloatTensor] | None = None
|
| 154 |
+
image_hidden_states: torch.FloatTensor | None = None
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
@auto_docstring(
|
| 158 |
+
custom_intro="""
|
| 159 |
+
Base class for Mistral3 outputs, with hidden states and attentions.
|
| 160 |
+
"""
|
| 161 |
+
)
|
| 162 |
+
@dataclass
|
| 163 |
+
class Mistral3ModelOutputWithPast(BaseModelOutputWithPast):
|
| 164 |
+
r"""
|
| 165 |
+
past_key_values (`Cache`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
|
| 166 |
+
It is a [`~cache_utils.Cache`] instance. For more details, see our [kv cache guide](https://huggingface.co/docs/transformers/en/kv_cache).
|
| 167 |
+
|
| 168 |
+
Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
|
| 169 |
+
`past_key_values` input) to speed up sequential decoding.
|
| 170 |
+
image_hidden_states (`torch.FloatTensor`, *optional*):
|
| 171 |
+
A `torch.FloatTensor` of size `(batch_size, num_images, sequence_length, hidden_size)`.
|
| 172 |
+
image_hidden_states of the model produced by the vision encoder and after projecting the last hidden state.
|
| 173 |
+
"""
|
| 174 |
+
|
| 175 |
+
image_hidden_states: torch.FloatTensor | None = None
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
@auto_docstring
|
| 179 |
+
class Mistral3PreTrainedModel(PreTrainedModel):
|
| 180 |
+
config: Mistral3Config
|
| 181 |
+
base_model_prefix = "model"
|
| 182 |
+
input_modalities = ("image", "text")
|
| 183 |
+
supports_gradient_checkpointing = True
|
| 184 |
+
_skip_keys_device_placement = ["past_key_values"]
|
| 185 |
+
|
| 186 |
+
_supports_flash_attn = True
|
| 187 |
+
_supports_sdpa = True
|
| 188 |
+
|
| 189 |
+
_can_compile_fullgraph = True
|
| 190 |
+
_supports_flex_attn = True
|
| 191 |
+
_supports_attention_backend = True
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
@auto_docstring(
|
| 195 |
+
custom_intro="""
|
| 196 |
+
The Mistral3 model which consists of a vision backbone and a language model, without a language modeling head.
|
| 197 |
+
"""
|
| 198 |
+
)
|
| 199 |
+
class Mistral3Model(Mistral3PreTrainedModel):
|
| 200 |
+
def __init__(self, config: Mistral3Config):
|
| 201 |
+
super().__init__(config)
|
| 202 |
+
self.vision_tower = AutoModel.from_config(config.vision_config)
|
| 203 |
+
|
| 204 |
+
self.multi_modal_projector = Mistral3MultiModalProjector(config)
|
| 205 |
+
self.language_model = AutoModel.from_config(config.text_config)
|
| 206 |
+
self.post_init()
|
| 207 |
+
|
| 208 |
+
@merge_with_config_defaults
|
| 209 |
+
@can_return_tuple
|
| 210 |
+
@auto_docstring(
|
| 211 |
+
custom_intro="Obtains image last hidden states from the vision tower and apply multimodal projection."
|
| 212 |
+
)
|
| 213 |
+
def get_image_features(
|
| 214 |
+
self,
|
| 215 |
+
pixel_values: torch.FloatTensor,
|
| 216 |
+
image_sizes: torch.Tensor,
|
| 217 |
+
vision_feature_layer: int | list[int] | list[int] | None = None,
|
| 218 |
+
output_hidden_states: bool | None = None,
|
| 219 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 220 |
+
) -> tuple | BaseModelOutputWithPooling:
|
| 221 |
+
kwargs = {k: v for k, v in kwargs.items() if v is not None}
|
| 222 |
+
# this is not memory efficient at all (output_hidden_states=True) will save all the hidden states.
|
| 223 |
+
image_outputs = self.vision_tower(
|
| 224 |
+
pixel_values,
|
| 225 |
+
image_sizes=image_sizes,
|
| 226 |
+
output_hidden_states=True, # Ignore arg on purpose
|
| 227 |
+
return_dict=True,
|
| 228 |
+
**kwargs,
|
| 229 |
+
)
|
| 230 |
+
# If we have one vision feature layer, return the corresponding hidden states,
|
| 231 |
+
# otherwise, select the hidden states of each feature layer and concatenate them
|
| 232 |
+
if isinstance(vision_feature_layer, int):
|
| 233 |
+
selected_image_feature = image_outputs.hidden_states[vision_feature_layer]
|
| 234 |
+
else:
|
| 235 |
+
hs_pool = [image_outputs.hidden_states[layer_idx] for layer_idx in vision_feature_layer]
|
| 236 |
+
selected_image_feature = torch.cat(hs_pool, dim=-1)
|
| 237 |
+
|
| 238 |
+
image_features = self.multi_modal_projector(selected_image_feature.squeeze(0), image_sizes)
|
| 239 |
+
downsample_ratio = self.vision_tower.patch_size * self.config.spatial_merge_size
|
| 240 |
+
split_sizes = (
|
| 241 |
+
(torch.as_tensor(image_sizes, device=image_features.device) // downsample_ratio).prod(dim=-1).tolist()
|
| 242 |
+
)
|
| 243 |
+
image_features = torch.split(image_features.squeeze(0), split_sizes)
|
| 244 |
+
image_outputs.pooler_output = image_features
|
| 245 |
+
|
| 246 |
+
return image_outputs
|
| 247 |
+
|
| 248 |
+
def get_placeholder_mask(
|
| 249 |
+
self, input_ids: torch.LongTensor, inputs_embeds: torch.FloatTensor, image_features: torch.FloatTensor
|
| 250 |
+
):
|
| 251 |
+
"""
|
| 252 |
+
Obtains multimodal placeholder mask from `input_ids` or `inputs_embeds`, and checks that the placeholder token count is
|
| 253 |
+
equal to the length of multimodal features. If the lengths are different, an error is raised.
|
| 254 |
+
"""
|
| 255 |
+
if input_ids is None:
|
| 256 |
+
special_image_mask = inputs_embeds == self.get_input_embeddings()(
|
| 257 |
+
torch.tensor(self.config.image_token_id, dtype=torch.long, device=inputs_embeds.device)
|
| 258 |
+
)
|
| 259 |
+
special_image_mask = special_image_mask.all(-1)
|
| 260 |
+
else:
|
| 261 |
+
special_image_mask = input_ids == self.config.image_token_id
|
| 262 |
+
|
| 263 |
+
n_image_tokens = special_image_mask.sum()
|
| 264 |
+
n_image_features = image_features.shape[0] * image_features.shape[1]
|
| 265 |
+
special_image_mask = special_image_mask.unsqueeze(-1).expand_as(inputs_embeds).to(inputs_embeds.device)
|
| 266 |
+
torch_compilable_check(
|
| 267 |
+
inputs_embeds[special_image_mask].numel() == image_features.numel(),
|
| 268 |
+
f"Image features and image tokens do not match, tokens: {n_image_tokens}, features: {n_image_features}",
|
| 269 |
+
)
|
| 270 |
+
return special_image_mask
|
| 271 |
+
|
| 272 |
+
@merge_with_config_defaults
|
| 273 |
+
@can_return_tuple
|
| 274 |
+
@auto_docstring
|
| 275 |
+
def forward(
|
| 276 |
+
self,
|
| 277 |
+
input_ids: torch.LongTensor | None = None,
|
| 278 |
+
pixel_values: torch.FloatTensor | None = None,
|
| 279 |
+
attention_mask: torch.Tensor | None = None,
|
| 280 |
+
position_ids: torch.LongTensor | None = None,
|
| 281 |
+
past_key_values: Cache | None = None,
|
| 282 |
+
inputs_embeds: torch.FloatTensor | None = None,
|
| 283 |
+
vision_feature_layer: int | list[int] | list[int] | None = None,
|
| 284 |
+
use_cache: bool | None = None,
|
| 285 |
+
image_sizes: torch.Tensor | None = None,
|
| 286 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 287 |
+
) -> tuple | Mistral3ModelOutputWithPast:
|
| 288 |
+
if (input_ids is None) ^ (inputs_embeds is not None):
|
| 289 |
+
raise ValueError("You must specify exactly one of input_ids or inputs_embeds")
|
| 290 |
+
|
| 291 |
+
if inputs_embeds is None:
|
| 292 |
+
inputs_embeds = self.get_input_embeddings()(input_ids)
|
| 293 |
+
|
| 294 |
+
if pixel_values is not None:
|
| 295 |
+
image_features = self.get_image_features(
|
| 296 |
+
pixel_values=pixel_values,
|
| 297 |
+
vision_feature_layer=vision_feature_layer,
|
| 298 |
+
image_sizes=image_sizes,
|
| 299 |
+
return_dict=True,
|
| 300 |
+
).pooler_output
|
| 301 |
+
image_features = torch.cat(image_features, dim=0).to(inputs_embeds.device, inputs_embeds.dtype)
|
| 302 |
+
special_image_mask = self.get_placeholder_mask(
|
| 303 |
+
input_ids, inputs_embeds=inputs_embeds, image_features=image_features
|
| 304 |
+
)
|
| 305 |
+
inputs_embeds = inputs_embeds.masked_scatter(special_image_mask, image_features)
|
| 306 |
+
|
| 307 |
+
outputs = self.language_model(
|
| 308 |
+
attention_mask=attention_mask,
|
| 309 |
+
position_ids=position_ids,
|
| 310 |
+
past_key_values=past_key_values,
|
| 311 |
+
inputs_embeds=inputs_embeds,
|
| 312 |
+
use_cache=use_cache,
|
| 313 |
+
**kwargs,
|
| 314 |
+
)
|
| 315 |
+
|
| 316 |
+
return Mistral3ModelOutputWithPast(
|
| 317 |
+
last_hidden_state=outputs.last_hidden_state,
|
| 318 |
+
past_key_values=outputs.past_key_values,
|
| 319 |
+
hidden_states=outputs.hidden_states,
|
| 320 |
+
attentions=outputs.attentions,
|
| 321 |
+
image_hidden_states=image_features if pixel_values is not None else None,
|
| 322 |
+
)
|
| 323 |
+
|
| 324 |
+
|
| 325 |
+
@auto_docstring(
|
| 326 |
+
custom_intro="""
|
| 327 |
+
The MISTRAL3 model which consists of a vision backbone and a language model.
|
| 328 |
+
"""
|
| 329 |
+
)
|
| 330 |
+
class Mistral3ForConditionalGeneration(Mistral3PreTrainedModel, GenerationMixin):
|
| 331 |
+
_tied_weights_keys = {"lm_head.weight": "model.language_model.embed_tokens.weight"}
|
| 332 |
+
|
| 333 |
+
def __init__(self, config: Mistral3Config):
|
| 334 |
+
super().__init__(config)
|
| 335 |
+
self.model = Mistral3Model(config)
|
| 336 |
+
self.lm_head = nn.Linear(config.text_config.hidden_size, config.text_config.vocab_size, bias=False)
|
| 337 |
+
self.post_init()
|
| 338 |
+
|
| 339 |
+
def get_output_embeddings(self) -> nn.Module:
|
| 340 |
+
return self.lm_head
|
| 341 |
+
|
| 342 |
+
@merge_with_config_defaults
|
| 343 |
+
@can_return_tuple
|
| 344 |
+
@auto_docstring
|
| 345 |
+
def get_image_features(
|
| 346 |
+
self,
|
| 347 |
+
pixel_values: torch.FloatTensor,
|
| 348 |
+
image_sizes: torch.Tensor,
|
| 349 |
+
vision_feature_layer: int | list[int] | list[int] | None = None,
|
| 350 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 351 |
+
) -> tuple | BaseModelOutputWithPooling:
|
| 352 |
+
return self.model.get_image_features(
|
| 353 |
+
pixel_values=pixel_values,
|
| 354 |
+
image_sizes=image_sizes,
|
| 355 |
+
vision_feature_layer=vision_feature_layer,
|
| 356 |
+
**kwargs,
|
| 357 |
+
)
|
| 358 |
+
|
| 359 |
+
@merge_with_config_defaults
|
| 360 |
+
@can_return_tuple
|
| 361 |
+
@auto_docstring
|
| 362 |
+
def forward(
|
| 363 |
+
self,
|
| 364 |
+
input_ids: torch.LongTensor | None = None,
|
| 365 |
+
pixel_values: torch.FloatTensor | None = None,
|
| 366 |
+
attention_mask: torch.Tensor | None = None,
|
| 367 |
+
position_ids: torch.LongTensor | None = None,
|
| 368 |
+
past_key_values: Cache | None = None,
|
| 369 |
+
inputs_embeds: torch.FloatTensor | None = None,
|
| 370 |
+
labels: torch.LongTensor | None = None,
|
| 371 |
+
use_cache: bool | None = None,
|
| 372 |
+
logits_to_keep: int | torch.Tensor = 0,
|
| 373 |
+
image_sizes: torch.Tensor | None = None,
|
| 374 |
+
**kwargs: Unpack[TransformersKwargs],
|
| 375 |
+
) -> tuple | Mistral3CausalLMOutputWithPast:
|
| 376 |
+
r"""
|
| 377 |
+
Example:
|
| 378 |
+
|
| 379 |
+
```python
|
| 380 |
+
>>> from PIL import Image
|
| 381 |
+
>>> import httpx
|
| 382 |
+
>>> from io import BytesIO
|
| 383 |
+
>>> from transformers import AutoProcessor, Mistral3ForConditionalGeneration
|
| 384 |
+
|
| 385 |
+
>>> model = Mistral3ForConditionalGeneration.from_pretrained("mistralai/Mistral-Small-3.1-24B-Instruct-2503")
|
| 386 |
+
>>> processor = AutoProcessor.from_pretrained("mistralai/Mistral-Small-3.1-24B-Instruct-2503")
|
| 387 |
+
|
| 388 |
+
>>> prompt = "<s>[INST][IMG]What is the image?[/INST]"
|
| 389 |
+
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
|
| 390 |
+
>>> with httpx.stream("GET", url) as response:
|
| 391 |
+
... image = Image.open(BytesIO(response.read()))
|
| 392 |
+
|
| 393 |
+
>>> inputs = processor(images=image, text=prompt, return_tensors="pt")
|
| 394 |
+
|
| 395 |
+
>>> # Generate
|
| 396 |
+
>>> generate_ids = model.generate(**inputs, max_new_tokens=15)
|
| 397 |
+
>>> processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
| 398 |
+
"What is the image?The image depicts two cats lying on a pink blanket."
|
| 399 |
+
```"""
|
| 400 |
+
outputs = self.model(
|
| 401 |
+
input_ids=input_ids,
|
| 402 |
+
pixel_values=pixel_values,
|
| 403 |
+
attention_mask=attention_mask,
|
| 404 |
+
position_ids=position_ids,
|
| 405 |
+
past_key_values=past_key_values,
|
| 406 |
+
inputs_embeds=inputs_embeds,
|
| 407 |
+
use_cache=use_cache,
|
| 408 |
+
image_sizes=image_sizes,
|
| 409 |
+
**kwargs,
|
| 410 |
+
)
|
| 411 |
+
|
| 412 |
+
hidden_states = outputs[0]
|
| 413 |
+
slice_indices = slice(-logits_to_keep, None) if isinstance(logits_to_keep, int) else logits_to_keep
|
| 414 |
+
logits = self.lm_head(hidden_states[:, slice_indices, :])
|
| 415 |
+
|
| 416 |
+
loss = None
|
| 417 |
+
if labels is not None:
|
| 418 |
+
loss = self.loss_function(
|
| 419 |
+
logits=logits, labels=labels, vocab_size=self.config.text_config.vocab_size, **kwargs
|
| 420 |
+
)
|
| 421 |
+
|
| 422 |
+
return Mistral3CausalLMOutputWithPast(
|
| 423 |
+
loss=loss,
|
| 424 |
+
logits=logits,
|
| 425 |
+
past_key_values=outputs.past_key_values,
|
| 426 |
+
hidden_states=outputs.hidden_states,
|
| 427 |
+
attentions=outputs.attentions,
|
| 428 |
+
image_hidden_states=outputs.image_hidden_states,
|
| 429 |
+
)
|
| 430 |
+
|
| 431 |
+
def prepare_inputs_for_generation(
|
| 432 |
+
self,
|
| 433 |
+
input_ids,
|
| 434 |
+
past_key_values=None,
|
| 435 |
+
inputs_embeds=None,
|
| 436 |
+
pixel_values=None,
|
| 437 |
+
attention_mask=None,
|
| 438 |
+
logits_to_keep=None,
|
| 439 |
+
is_first_iteration=False,
|
| 440 |
+
**kwargs,
|
| 441 |
+
):
|
| 442 |
+
# Overwritten -- in specific circumstances we don't want to forward image inputs to the model
|
| 443 |
+
|
| 444 |
+
model_inputs = super().prepare_inputs_for_generation(
|
| 445 |
+
input_ids,
|
| 446 |
+
past_key_values=past_key_values,
|
| 447 |
+
inputs_embeds=inputs_embeds,
|
| 448 |
+
attention_mask=attention_mask,
|
| 449 |
+
logits_to_keep=logits_to_keep,
|
| 450 |
+
is_first_iteration=is_first_iteration,
|
| 451 |
+
**kwargs,
|
| 452 |
+
)
|
| 453 |
+
|
| 454 |
+
if is_first_iteration or not kwargs.get("use_cache", True):
|
| 455 |
+
# Pixel values are used only in the first iteration if available
|
| 456 |
+
# In subsequent iterations, they are already merged with text and cached
|
| 457 |
+
# NOTE: first iteration doesn't have to be prefill, it can be the first
|
| 458 |
+
# iteration with a question and cached system prompt (continue generate from cache)
|
| 459 |
+
model_inputs["pixel_values"] = pixel_values
|
| 460 |
+
|
| 461 |
+
return model_inputs
|
| 462 |
+
|
| 463 |
+
|
| 464 |
+
__all__ = ["Mistral3Model", "Mistral3PreTrainedModel", "Mistral3ForConditionalGeneration"]
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/transformers/models/vits/__init__.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2024 The HuggingFace Team. All rights reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
from typing import TYPE_CHECKING
|
| 15 |
+
|
| 16 |
+
from ...utils import _LazyModule
|
| 17 |
+
from ...utils.import_utils import define_import_structure
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
if TYPE_CHECKING:
|
| 21 |
+
from .configuration_vits import *
|
| 22 |
+
from .modeling_vits import *
|
| 23 |
+
from .tokenization_vits import *
|
| 24 |
+
else:
|
| 25 |
+
import sys
|
| 26 |
+
|
| 27 |
+
_file = globals()["__file__"]
|
| 28 |
+
sys.modules[__name__] = _LazyModule(__name__, _file, define_import_structure(_file), module_spec=__spec__)
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/.venv_qwen35_uv/lib/python3.12/site-packages/transformers/models/vits/configuration_vits.py
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2023 The Kakao Enterprise Authors and the HuggingFace Inc. team. All rights reserved.
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
"""VITS model configuration"""
|
| 15 |
+
|
| 16 |
+
from huggingface_hub.dataclasses import strict
|
| 17 |
+
|
| 18 |
+
from ...configuration_utils import PreTrainedConfig
|
| 19 |
+
from ...utils import auto_docstring
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
@auto_docstring(checkpoint="facebook/mms-tts-eng")
|
| 23 |
+
@strict
|
| 24 |
+
class VitsConfig(PreTrainedConfig):
|
| 25 |
+
r"""
|
| 26 |
+
window_size (`int`, *optional*, defaults to 4):
|
| 27 |
+
Window size for the relative positional embeddings in the attention layers of the Transformer encoder.
|
| 28 |
+
use_bias (`bool`, *optional*, defaults to `True`):
|
| 29 |
+
Whether to use bias in the key, query, value projection layers in the Transformer encoder.
|
| 30 |
+
ffn_kernel_size (`int`, *optional*, defaults to 3):
|
| 31 |
+
Kernel size of the 1D convolution layers used by the feed-forward network in the Transformer encoder.
|
| 32 |
+
flow_size (`int`, *optional*, defaults to 192):
|
| 33 |
+
Dimensionality of the flow layers.
|
| 34 |
+
spectrogram_bins (`int`, *optional*, defaults to 513):
|
| 35 |
+
Number of frequency bins in the target spectrogram.
|
| 36 |
+
use_stochastic_duration_prediction (`bool`, *optional*, defaults to `True`):
|
| 37 |
+
Whether to use the stochastic duration prediction module or the regular duration predictor.
|
| 38 |
+
num_speakers (`int`, *optional*, defaults to 1):
|
| 39 |
+
Number of speakers if this is a multi-speaker model.
|
| 40 |
+
speaker_embedding_size (`int`, *optional*, defaults to 0):
|
| 41 |
+
Number of channels used by the speaker embeddings. Is zero for single-speaker models.
|
| 42 |
+
upsample_initial_channel (`int`, *optional*, defaults to 512):
|
| 43 |
+
The number of input channels into the HiFi-GAN upsampling network.
|
| 44 |
+
upsample_rates (`tuple[int]` or `list[int]`, *optional*, defaults to `[8, 8, 2, 2]`):
|
| 45 |
+
A tuple of integers defining the stride of each 1D convolutional layer in the HiFi-GAN upsampling network.
|
| 46 |
+
The length of `upsample_rates` defines the number of convolutional layers and has to match the length of
|
| 47 |
+
`upsample_kernel_sizes`.
|
| 48 |
+
upsample_kernel_sizes (`tuple[int]` or `list[int]`, *optional*, defaults to `[16, 16, 4, 4]`):
|
| 49 |
+
A tuple of integers defining the kernel size of each 1D convolutional layer in the HiFi-GAN upsampling
|
| 50 |
+
network. The length of `upsample_kernel_sizes` defines the number of convolutional layers and has to match
|
| 51 |
+
the length of `upsample_rates`.
|
| 52 |
+
resblock_kernel_sizes (`tuple[int]` or `list[int]`, *optional*, defaults to `[3, 7, 11]`):
|
| 53 |
+
A tuple of integers defining the kernel sizes of the 1D convolutional layers in the HiFi-GAN
|
| 54 |
+
multi-receptive field fusion (MRF) module.
|
| 55 |
+
resblock_dilation_sizes (`tuple[tuple[int]]` or `list[list[int]]`, *optional*, defaults to `[[1, 3, 5], [1, 3, 5], [1, 3, 5]]`):
|
| 56 |
+
A nested tuple of integers defining the dilation rates of the dilated 1D convolutional layers in the
|
| 57 |
+
HiFi-GAN multi-receptive field fusion (MRF) module.
|
| 58 |
+
leaky_relu_slope (`float`, *optional*, defaults to 0.1):
|
| 59 |
+
The angle of the negative slope used by the leaky ReLU activation.
|
| 60 |
+
depth_separable_channels (`int`, *optional*, defaults to 2):
|
| 61 |
+
Number of channels to use in each depth-separable block.
|
| 62 |
+
depth_separable_num_layers (`int`, *optional*, defaults to 3):
|
| 63 |
+
Number of convolutional layers to use in each depth-separable block.
|
| 64 |
+
duration_predictor_flow_bins (`int`, *optional*, defaults to 10):
|
| 65 |
+
Number of channels to map using the unonstrained rational spline in the duration predictor model.
|
| 66 |
+
duration_predictor_tail_bound (`float`, *optional*, defaults to 5.0):
|
| 67 |
+
Value of the tail bin boundary when computing the unconstrained rational spline in the duration predictor
|
| 68 |
+
model.
|
| 69 |
+
duration_predictor_kernel_size (`int`, *optional*, defaults to 3):
|
| 70 |
+
Kernel size of the 1D convolution layers used in the duration predictor model.
|
| 71 |
+
duration_predictor_dropout (`float`, *optional*, defaults to 0.5):
|
| 72 |
+
The dropout ratio for the duration predictor model.
|
| 73 |
+
duration_predictor_num_flows (`int`, *optional*, defaults to 4):
|
| 74 |
+
Number of flow stages used by the duration predictor model.
|
| 75 |
+
duration_predictor_filter_channels (`int`, *optional*, defaults to 256):
|
| 76 |
+
Number of channels for the convolution layers used in the duration predictor model.
|
| 77 |
+
prior_encoder_num_flows (`int`, *optional*, defaults to 4):
|
| 78 |
+
Number of flow stages used by the prior encoder flow model.
|
| 79 |
+
prior_encoder_num_wavenet_layers (`int`, *optional*, defaults to 4):
|
| 80 |
+
Number of WaveNet layers used by the prior encoder flow model.
|
| 81 |
+
posterior_encoder_num_wavenet_layers (`int`, *optional*, defaults to 16):
|
| 82 |
+
Number of WaveNet layers used by the posterior encoder model.
|
| 83 |
+
wavenet_kernel_size (`int`, *optional*, defaults to 5):
|
| 84 |
+
Kernel size of the 1D convolution layers used in the WaveNet model.
|
| 85 |
+
wavenet_dilation_rate (`int`, *optional*, defaults to 1):
|
| 86 |
+
Dilation rates of the dilated 1D convolutional layers used in the WaveNet model.
|
| 87 |
+
wavenet_dropout (`float`, *optional*, defaults to 0.0):
|
| 88 |
+
The dropout ratio for the WaveNet layers.
|
| 89 |
+
speaking_rate (`float`, *optional*, defaults to 1.0):
|
| 90 |
+
Speaking rate. Larger values give faster synthesised speech.
|
| 91 |
+
noise_scale (`float`, *optional*, defaults to 0.667):
|
| 92 |
+
How random the speech prediction is. Larger values create more variation in the predicted speech.
|
| 93 |
+
noise_scale_duration (`float`, *optional*, defaults to 0.8):
|
| 94 |
+
How random the duration prediction is. Larger values create more variation in the predicted durations.
|
| 95 |
+
|
| 96 |
+
Example:
|
| 97 |
+
|
| 98 |
+
```python
|
| 99 |
+
>>> from transformers import VitsModel, VitsConfig
|
| 100 |
+
|
| 101 |
+
>>> # Initializing a "facebook/mms-tts-eng" style configuration
|
| 102 |
+
>>> configuration = VitsConfig()
|
| 103 |
+
|
| 104 |
+
>>> # Initializing a model (with random weights) from the "facebook/mms-tts-eng" style configuration
|
| 105 |
+
>>> model = VitsModel(configuration)
|
| 106 |
+
|
| 107 |
+
>>> # Accessing the model configuration
|
| 108 |
+
>>> configuration = model.config
|
| 109 |
+
```"""
|
| 110 |
+
|
| 111 |
+
model_type = "vits"
|
| 112 |
+
|
| 113 |
+
vocab_size: int = 38
|
| 114 |
+
hidden_size: int = 192
|
| 115 |
+
num_hidden_layers: int = 6
|
| 116 |
+
num_attention_heads: int = 2
|
| 117 |
+
window_size: int = 4
|
| 118 |
+
use_bias: bool = True
|
| 119 |
+
ffn_dim: int = 768
|
| 120 |
+
layerdrop: float | int = 0.1
|
| 121 |
+
ffn_kernel_size: int = 3
|
| 122 |
+
flow_size: int = 192
|
| 123 |
+
spectrogram_bins: int = 513
|
| 124 |
+
hidden_act: str = "relu"
|
| 125 |
+
hidden_dropout: float | int = 0.1
|
| 126 |
+
attention_dropout: float | int = 0.1
|
| 127 |
+
activation_dropout: float | int = 0.1
|
| 128 |
+
initializer_range: float = 0.02
|
| 129 |
+
layer_norm_eps: float = 1e-5
|
| 130 |
+
use_stochastic_duration_prediction: bool = True
|
| 131 |
+
num_speakers: int = 1
|
| 132 |
+
speaker_embedding_size: int = 0
|
| 133 |
+
upsample_initial_channel: int = 512
|
| 134 |
+
upsample_rates: list[int] | tuple[int, ...] = (8, 8, 2, 2)
|
| 135 |
+
upsample_kernel_sizes: list[int] | tuple[int, ...] = (16, 16, 4, 4)
|
| 136 |
+
resblock_kernel_sizes: list[int] | tuple[int, ...] = (3, 7, 11)
|
| 137 |
+
resblock_dilation_sizes: list | tuple = ((1, 3, 5), (1, 3, 5), (1, 3, 5))
|
| 138 |
+
leaky_relu_slope: float = 0.1
|
| 139 |
+
depth_separable_channels: int = 2
|
| 140 |
+
depth_separable_num_layers: int = 3
|
| 141 |
+
duration_predictor_flow_bins: int = 10
|
| 142 |
+
duration_predictor_tail_bound: float = 5.0
|
| 143 |
+
duration_predictor_kernel_size: int = 3
|
| 144 |
+
duration_predictor_dropout: float | int = 0.5
|
| 145 |
+
duration_predictor_num_flows: int = 4
|
| 146 |
+
duration_predictor_filter_channels: int = 256
|
| 147 |
+
prior_encoder_num_flows: int = 4
|
| 148 |
+
prior_encoder_num_wavenet_layers: int = 4
|
| 149 |
+
posterior_encoder_num_wavenet_layers: int = 16
|
| 150 |
+
wavenet_kernel_size: int = 5
|
| 151 |
+
wavenet_dilation_rate: int = 1
|
| 152 |
+
wavenet_dropout: float | int = 0.0
|
| 153 |
+
speaking_rate: float | int = 1.0
|
| 154 |
+
noise_scale: float = 0.667
|
| 155 |
+
noise_scale_duration: float = 0.8
|
| 156 |
+
sampling_rate: int = 16_000
|
| 157 |
+
pad_token_id: int | None = None
|
| 158 |
+
|
| 159 |
+
def validate_architecture(self):
|
| 160 |
+
"""Part of `@strict`-powered validation. Validates the architecture of the config."""
|
| 161 |
+
if len(self.upsample_kernel_sizes) != len(self.upsample_rates):
|
| 162 |
+
raise ValueError(
|
| 163 |
+
f"The length of `upsample_kernel_sizes` ({len(self.upsample_kernel_sizes)}) must match the length of "
|
| 164 |
+
f"`upsample_rates` ({len(self.upsample_rates)})"
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
__all__ = ["VitsConfig"]
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/runs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_2x8gpu_50ep_lr3e3_ema0p9999_elfopt_not5_bottleneck16_unfixed_norm_stateprobadd_selfcond_ce_fast_20260612_030202/step_052000.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:44e2ec069f680d89a853d9c0cf3cccb413c6be8160d1fda6530f751e52a5f822
|
| 3 |
+
size 897562466
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/runs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_2x8gpu_50ep_lr3e3_ema0p9999_elfopt_not5_bottleneck16_unfixed_norm_stateprobadd_selfcond_ce_fast_20260612_030202/step_077000.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ffcb7c2372c93a992b0d49b00b7e0982a5077a7ab4836824a223e0f3e32a7cd4
|
| 3 |
+
size 897562466
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/runs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_2x8gpu_50ep_lr3e3_ema0p9999_elfopt_not5_bottleneck16_unfixed_norm_stateprobadd_selfcond_ce_fast_20260612_030202/step_235000.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6116067dace5b1907365933a8918605d925dbc107ee1adb18e674c79cdb87515
|
| 3 |
+
size 897562466
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/runs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_2x8gpu_50ep_lr3e3_ema0p9999_elfopt_not5_bottleneck16_unfixed_norm_stateprobadd_selfcond_ce_fast_20260612_030202/step_336000.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:787ed5d853bf14b4e516a700be25ea48f6530582d80888258bd0e4d0ac437681
|
| 3 |
+
size 897562466
|
LTA_openwebtext_dualt/mini_owt_logdirichlet/runs/owt_t5_elftokenized_full_len1024_C1_to_1024_pow1_d768_l12_h12_gbs512_2x8gpu_50ep_lr3e3_ema0p9999_elfopt_not5_bottleneck16_unfixed_norm_stateprobadd_selfcond_ce_fast_20260612_030202/step_456000.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:05e3a27ef20d69e7811fa546b2c28f75295af782805e1741d0c08b76e830ecf6
|
| 3 |
+
size 897562466
|