trnrt 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. trnrt-0.1.0/LICENSE +202 -0
  2. trnrt-0.1.0/NOTICE +4 -0
  3. trnrt-0.1.0/PKG-INFO +275 -0
  4. trnrt-0.1.0/README.md +230 -0
  5. trnrt-0.1.0/pyproject.toml +156 -0
  6. trnrt-0.1.0/setup.cfg +4 -0
  7. trnrt-0.1.0/tests/test_api.py +153 -0
  8. trnrt-0.1.0/tests/test_api_cached_tokens.py +113 -0
  9. trnrt-0.1.0/tests/test_api_engine_health.py +205 -0
  10. trnrt-0.1.0/tests/test_api_prompt_thread.py +136 -0
  11. trnrt-0.1.0/tests/test_api_request_checks.py +106 -0
  12. trnrt-0.1.0/tests/test_batch_configs.py +235 -0
  13. trnrt-0.1.0/tests/test_cache_overlap_pages.py +255 -0
  14. trnrt-0.1.0/tests/test_check_docs.py +59 -0
  15. trnrt-0.1.0/tests/test_check_image.py +53 -0
  16. trnrt-0.1.0/tests/test_check_mixed.py +76 -0
  17. trnrt-0.1.0/tests/test_ckpt_dominated.py +98 -0
  18. trnrt-0.1.0/tests/test_ckpt_mid.py +155 -0
  19. trnrt-0.1.0/tests/test_ckpt_offload_running.py +164 -0
  20. trnrt-0.1.0/tests/test_ckpt_prompt_finish.py +156 -0
  21. trnrt-0.1.0/tests/test_compile_farm.py +976 -0
  22. trnrt-0.1.0/tests/test_decode_composition.py +82 -0
  23. trnrt-0.1.0/tests/test_detok_incremental.py +148 -0
  24. trnrt-0.1.0/tests/test_detok_selfcheck.py +93 -0
  25. trnrt-0.1.0/tests/test_dma_hw.py +75 -0
  26. trnrt-0.1.0/tests/test_dsa_cp.py +436 -0
  27. trnrt-0.1.0/tests/test_dsa_cp_glue.py +159 -0
  28. trnrt-0.1.0/tests/test_dsa_cp_index_rows.py +76 -0
  29. trnrt-0.1.0/tests/test_dsa_fused_layer.py +404 -0
  30. trnrt-0.1.0/tests/test_dsa_index.py +82 -0
  31. trnrt-0.1.0/tests/test_dsa_long.py +585 -0
  32. trnrt-0.1.0/tests/test_dsa_long_select_t_trips.py +166 -0
  33. trnrt-0.1.0/tests/test_dsa_sel2g_generated.py +79 -0
  34. trnrt-0.1.0/tests/test_dsa_shell.py +594 -0
  35. trnrt-0.1.0/tests/test_dsa_slots.py +688 -0
  36. trnrt-0.1.0/tests/test_dsa_topk.py +317 -0
  37. trnrt-0.1.0/tests/test_e2e.py +214 -0
  38. trnrt-0.1.0/tests/test_ffn_half.py +837 -0
  39. trnrt-0.1.0/tests/test_gated_norm.py +80 -0
  40. trnrt-0.1.0/tests/test_glm53_chat.py +287 -0
  41. trnrt-0.1.0/tests/test_glm53_template.py +131 -0
  42. trnrt-0.1.0/tests/test_glm5_next.py +308 -0
  43. trnrt-0.1.0/tests/test_graph_equiv.py +181 -0
  44. trnrt-0.1.0/tests/test_graph_equiv_command.py +31 -0
  45. trnrt-0.1.0/tests/test_graph_equiv_meta.py +19 -0
  46. trnrt-0.1.0/tests/test_host_cache.py +114 -0
  47. trnrt-0.1.0/tests/test_host_cache_checkpoints.py +170 -0
  48. trnrt-0.1.0/tests/test_host_sim_seam.py +286 -0
  49. trnrt-0.1.0/tests/test_iopool.py +348 -0
  50. trnrt-0.1.0/tests/test_kda.py +341 -0
  51. trnrt-0.1.0/tests/test_kda_decode.py +146 -0
  52. trnrt-0.1.0/tests/test_kda_shell.py +1113 -0
  53. trnrt-0.1.0/tests/test_kda_zero_row.py +130 -0
  54. trnrt-0.1.0/tests/test_labeler.py +36 -0
  55. trnrt-0.1.0/tests/test_lnc_split.py +134 -0
  56. trnrt-0.1.0/tests/test_local_k.py +215 -0
  57. trnrt-0.1.0/tests/test_log.py +95 -0
  58. trnrt-0.1.0/tests/test_max_running.py +101 -0
  59. trnrt-0.1.0/tests/test_mhc.py +672 -0
  60. trnrt-0.1.0/tests/test_mk_b5c.py +127 -0
  61. trnrt-0.1.0/tests/test_mk_kda_layer.py +133 -0
  62. trnrt-0.1.0/tests/test_model_path.py +92 -0
  63. trnrt-0.1.0/tests/test_moe_dedupe.py +427 -0
  64. trnrt-0.1.0/tests/test_moe_prefill.py +313 -0
  65. trnrt-0.1.0/tests/test_moe_prefill_mdr.py +166 -0
  66. trnrt-0.1.0/tests/test_moe_prefill_tsb.py +102 -0
  67. trnrt-0.1.0/tests/test_neff_strip.py +163 -0
  68. trnrt-0.1.0/tests/test_no_abbrev.py +55 -0
  69. trnrt-0.1.0/tests/test_no_trace.py +271 -0
  70. trnrt-0.1.0/tests/test_parsers.py +83 -0
  71. trnrt-0.1.0/tests/test_parsers_glm.py +154 -0
  72. trnrt-0.1.0/tests/test_preset_env.py +130 -0
  73. trnrt-0.1.0/tests/test_radix_cache.py +215 -0
  74. trnrt-0.1.0/tests/test_rank_threads.py +112 -0
  75. trnrt-0.1.0/tests/test_release_plan.py +109 -0
  76. trnrt-0.1.0/tests/test_router.py +495 -0
  77. trnrt-0.1.0/tests/test_router_affinity.py +539 -0
  78. trnrt-0.1.0/tests/test_row_isolation.py +371 -0
  79. trnrt-0.1.0/tests/test_sampler.py +270 -0
  80. trnrt-0.1.0/tests/test_sched_pchain.py +130 -0
  81. trnrt-0.1.0/tests/test_scheduler.py +419 -0
  82. trnrt-0.1.0/tests/test_scheduler_spec.py +209 -0
  83. trnrt-0.1.0/tests/test_serve_api.py +630 -0
  84. trnrt-0.1.0/tests/test_serve_cli.py +365 -0
  85. trnrt-0.1.0/tests/test_serve_e2e.py +307 -0
  86. trnrt-0.1.0/tests/test_shape_dir_hub.py +71 -0
  87. trnrt-0.1.0/tests/test_shell.py +139 -0
  88. trnrt-0.1.0/tests/test_spec_async.py +206 -0
  89. trnrt-0.1.0/tests/test_spec_config.py +293 -0
  90. trnrt-0.1.0/tests/test_spec_engine_fake.py +631 -0
  91. trnrt-0.1.0/tests/test_spec_metrics.py +70 -0
  92. trnrt-0.1.0/tests/test_spec_model.py +182 -0
  93. trnrt-0.1.0/tests/test_spec_runner_stub.py +482 -0
  94. trnrt-0.1.0/tests/test_spec_synth.py +147 -0
  95. trnrt-0.1.0/tests/test_start_checks.py +190 -0
  96. trnrt-0.1.0/tests/test_state_pool.py +78 -0
  97. trnrt-0.1.0/tests/test_state_pool_spec.py +153 -0
  98. trnrt-0.1.0/tests/test_third_party_notices.py +114 -0
  99. trnrt-0.1.0/tests/test_tp_init.py +34 -0
  100. trnrt-0.1.0/tests/test_tp_shm.py +424 -0
  101. trnrt-0.1.0/tests/test_zero_blobs.py +118 -0
  102. trnrt-0.1.0/trnrt/__init__.py +3 -0
  103. trnrt-0.1.0/trnrt/__main__.py +700 -0
  104. trnrt-0.1.0/trnrt/compile/__init__.py +3 -0
  105. trnrt-0.1.0/trnrt/compile/cache.py +161 -0
  106. trnrt-0.1.0/trnrt/compile/capture.py +802 -0
  107. trnrt-0.1.0/trnrt/compile/farm.py +634 -0
  108. trnrt-0.1.0/trnrt/compile/strip.py +162 -0
  109. trnrt-0.1.0/trnrt/config.py +252 -0
  110. trnrt-0.1.0/trnrt/engine/__init__.py +0 -0
  111. trnrt-0.1.0/trnrt/engine/engine.py +773 -0
  112. trnrt-0.1.0/trnrt/engine/host_cache.py +155 -0
  113. trnrt-0.1.0/trnrt/engine/iopool.py +230 -0
  114. trnrt-0.1.0/trnrt/engine/kv_pool.py +50 -0
  115. trnrt-0.1.0/trnrt/engine/model_runner.py +1385 -0
  116. trnrt-0.1.0/trnrt/engine/radix_cache.py +479 -0
  117. trnrt-0.1.0/trnrt/engine/request.py +142 -0
  118. trnrt-0.1.0/trnrt/engine/sampler.py +285 -0
  119. trnrt-0.1.0/trnrt/engine/scheduler.py +768 -0
  120. trnrt-0.1.0/trnrt/engine/spec_async.py +302 -0
  121. trnrt-0.1.0/trnrt/engine/spec_synth.py +94 -0
  122. trnrt-0.1.0/trnrt/engine/start_checks.py +190 -0
  123. trnrt-0.1.0/trnrt/engine/start_lock.py +88 -0
  124. trnrt-0.1.0/trnrt/engine/state_pool.py +194 -0
  125. trnrt-0.1.0/trnrt/engine/tp.py +488 -0
  126. trnrt-0.1.0/trnrt/engine/watchdog.py +142 -0
  127. trnrt-0.1.0/trnrt/kernels/__init__.py +2 -0
  128. trnrt-0.1.0/trnrt/kernels/cc_tail.py +348 -0
  129. trnrt-0.1.0/trnrt/kernels/cc_world.py +110 -0
  130. trnrt-0.1.0/trnrt/kernels/delta_rule.py +566 -0
  131. trnrt-0.1.0/trnrt/kernels/dense_half.py +361 -0
  132. trnrt-0.1.0/trnrt/kernels/dsa_cp_glue.py +299 -0
  133. trnrt-0.1.0/trnrt/kernels/dsa_decode.py +43 -0
  134. trnrt-0.1.0/trnrt/kernels/dsa_index.py +268 -0
  135. trnrt-0.1.0/trnrt/kernels/dsa_long_pipe.py +390 -0
  136. trnrt-0.1.0/trnrt/kernels/dsa_long_pipe_s.py +200 -0
  137. trnrt-0.1.0/trnrt/kernels/dsa_long_select.py +528 -0
  138. trnrt-0.1.0/trnrt/kernels/dsa_long_select_t.py +169 -0
  139. trnrt-0.1.0/trnrt/kernels/dsa_sa.py +428 -0
  140. trnrt-0.1.0/trnrt/kernels/dsa_sat.py +306 -0
  141. trnrt-0.1.0/trnrt/kernels/dsa_satwf.py +285 -0
  142. trnrt-0.1.0/trnrt/kernels/dsa_satwfc.py +280 -0
  143. trnrt-0.1.0/trnrt/kernels/dsa_satwfcg.py +286 -0
  144. trnrt-0.1.0/trnrt/kernels/dsa_satwfg.py +274 -0
  145. trnrt-0.1.0/trnrt/kernels/dsa_sel2g.py +884 -0
  146. trnrt-0.1.0/trnrt/kernels/dsa_sel_s2.py +87 -0
  147. trnrt-0.1.0/trnrt/kernels/dsa_shell.py +2321 -0
  148. trnrt-0.1.0/trnrt/kernels/dsa_slots.py +228 -0
  149. trnrt-0.1.0/trnrt/kernels/dsa_slots_c.py +447 -0
  150. trnrt-0.1.0/trnrt/kernels/dsa_slots_n.py +249 -0
  151. trnrt-0.1.0/trnrt/kernels/dsa_slots_n_s.py +125 -0
  152. trnrt-0.1.0/trnrt/kernels/dsa_slots_n_s2.py +237 -0
  153. trnrt-0.1.0/trnrt/kernels/dsa_topk.py +514 -0
  154. trnrt-0.1.0/trnrt/kernels/ffn_half.py +209 -0
  155. trnrt-0.1.0/trnrt/kernels/ffn_half_pb.py +634 -0
  156. trnrt-0.1.0/trnrt/kernels/ffn_half_shared.py +88 -0
  157. trnrt-0.1.0/trnrt/kernels/gated_norm.py +154 -0
  158. trnrt-0.1.0/trnrt/kernels/kda_decode.py +243 -0
  159. trnrt-0.1.0/trnrt/kernels/kda_half.py +327 -0
  160. trnrt-0.1.0/trnrt/kernels/kda_oob.py +86 -0
  161. trnrt-0.1.0/trnrt/kernels/kda_shell.py +824 -0
  162. trnrt-0.1.0/trnrt/kernels/mhc_fnj.py +190 -0
  163. trnrt-0.1.0/trnrt/kernels/mhc_front.py +108 -0
  164. trnrt-0.1.0/trnrt/kernels/mhc_mix.py +127 -0
  165. trnrt-0.1.0/trnrt/kernels/mhc_pre.py +319 -0
  166. trnrt-0.1.0/trnrt/kernels/mhc_pre_split.py +182 -0
  167. trnrt-0.1.0/trnrt/kernels/mhc_split.py +322 -0
  168. trnrt-0.1.0/trnrt/kernels/mix_wide.py +127 -0
  169. trnrt-0.1.0/trnrt/kernels/mk_kda_layer.py +234 -0
  170. trnrt-0.1.0/trnrt/kernels/moe_dedupe.py +1762 -0
  171. trnrt-0.1.0/trnrt/kernels/moe_half.py +537 -0
  172. trnrt-0.1.0/trnrt/kernels/moe_prefill.py +1118 -0
  173. trnrt-0.1.0/trnrt/kernels/moe_prefill_mdr.py +866 -0
  174. trnrt-0.1.0/trnrt/kernels/moe_prefill_tsb.py +860 -0
  175. trnrt-0.1.0/trnrt/kernels/rowiso.py +102 -0
  176. trnrt-0.1.0/trnrt/kernels/shell.py +463 -0
  177. trnrt-0.1.0/trnrt/kernels/short_conv.py +121 -0
  178. trnrt-0.1.0/trnrt/kernels/sp_gather.py +117 -0
  179. trnrt-0.1.0/trnrt/log.py +75 -0
  180. trnrt-0.1.0/trnrt/metrics.py +243 -0
  181. trnrt-0.1.0/trnrt/models/__init__.py +0 -0
  182. trnrt-0.1.0/trnrt/models/config.py +158 -0
  183. trnrt-0.1.0/trnrt/models/decoder.py +1131 -0
  184. trnrt-0.1.0/trnrt/models/dsa_long.py +433 -0
  185. trnrt-0.1.0/trnrt/models/dsa_select.py +38 -0
  186. trnrt-0.1.0/trnrt/models/glm5_next.py +208 -0
  187. trnrt-0.1.0/trnrt/models/hybrid.py +571 -0
  188. trnrt-0.1.0/trnrt/models/linear_attn.py +522 -0
  189. trnrt-0.1.0/trnrt/models/loader.py +353 -0
  190. trnrt-0.1.0/trnrt/models/mla.py +1448 -0
  191. trnrt-0.1.0/trnrt/models/quant.py +76 -0
  192. trnrt-0.1.0/trnrt/platform.py +210 -0
  193. trnrt-0.1.0/trnrt/serve/__init__.py +0 -0
  194. trnrt-0.1.0/trnrt/serve/api.py +1022 -0
  195. trnrt-0.1.0/trnrt/serve/parsers.py +571 -0
  196. trnrt-0.1.0/trnrt/serve/router.py +723 -0
  197. trnrt-0.1.0/trnrt.egg-info/PKG-INFO +275 -0
  198. trnrt-0.1.0/trnrt.egg-info/SOURCES.txt +200 -0
  199. trnrt-0.1.0/trnrt.egg-info/dependency_links.txt +1 -0
  200. trnrt-0.1.0/trnrt.egg-info/entry_points.txt +2 -0
  201. trnrt-0.1.0/trnrt.egg-info/requires.txt +23 -0
  202. trnrt-0.1.0/trnrt.egg-info/top_level.txt +1 -0
trnrt-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
trnrt-0.1.0/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ TrnRT
2
+ Copyright 2026 RunanywhereAI
3
+
4
+ This product includes software derived from Kiln (https://github.com/foxl-ai/kiln), licensed under the Apache License, Version 2.0, and modified by RunanywhereAI.
trnrt-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,275 @@
1
+ Metadata-Version: 2.4
2
+ Name: trnrt
3
+ Version: 0.1.0
4
+ Summary: LLM inference on AWS Trainium2, with NKI megakernels: an OpenAI-compatible server, 1M-token context and prefix caching
5
+ Author-email: RunAnywhere <security@runanywhere.ai>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/RunanywhereAI/trnrt
8
+ Project-URL: Repository, https://github.com/RunanywhereAI/trnrt
9
+ Project-URL: Documentation, https://github.com/RunanywhereAI/trnrt/tree/main/docs
10
+ Project-URL: Issues, https://github.com/RunanywhereAI/trnrt/issues
11
+ Project-URL: Changelog, https://github.com/RunanywhereAI/trnrt/blob/main/CHANGELOG.md
12
+ Keywords: llm,inference,trainium,aws,neuron,nki,serving,openai
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Requires-Python: >=3.13
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ License-File: NOTICE
24
+ Requires-Dist: numpy
25
+ Requires-Dist: safetensors
26
+ Requires-Dist: tokenizers
27
+ Requires-Dist: torch>=2.11
28
+ Requires-Dist: transformers>=5.17
29
+ Requires-Dist: jinja2
30
+ Requires-Dist: huggingface_hub
31
+ Requires-Dist: fastapi
32
+ Requires-Dist: uvicorn
33
+ Requires-Dist: httpx
34
+ Provides-Extra: test
35
+ Requires-Dist: pytest>=8; extra == "test"
36
+ Requires-Dist: openai>=1.40; extra == "test"
37
+ Requires-Dist: ml_dtypes; extra == "test"
38
+ Provides-Extra: lint
39
+ Requires-Dist: ruff==0.17.3; extra == "lint"
40
+ Requires-Dist: pre-commit>=4; extra == "lint"
41
+ Requires-Dist: mypy==2.4.1; extra == "lint"
42
+ Provides-Extra: dev
43
+ Requires-Dist: trnrt[lint,test]; extra == "dev"
44
+ Dynamic: license-file
45
+
46
+ <p align="center">
47
+ <picture>
48
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/banner-dark.svg">
49
+ <source media="(prefers-color-scheme: light)" srcset="docs/assets/banner-light.svg">
50
+ <img alt="TrnRT: the open LLM inference engine for AWS Trainium, by RunAnywhere" src="docs/assets/banner-dark.svg" width="100%">
51
+ </picture>
52
+ </p>
53
+
54
+ <p align="center">
55
+ <a href="https://github.com/RunanywhereAI/trnrt/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/RunanywhereAI/trnrt/ci.yml?branch=development&style=flat-square&labelColor=161515&label=CI"></a>
56
+ <a href="https://scorecard.dev/viewer/?uri=github.com/RunanywhereAI/trnrt"><img alt="OpenSSF Scorecard" src="https://img.shields.io/ossf-scorecard/github.com/RunanywhereAI/trnrt?style=flat-square&labelColor=161515&label=OpenSSF%20Scorecard"></a>
57
+ <a href="LICENSE"><img alt="License: Apache 2.0" src="https://img.shields.io/badge/license-Apache%202.0-fd7014?style=flat-square&labelColor=161515"></a>
58
+ <img alt="Python 3.13" src="https://img.shields.io/badge/python-3.13-fd7014?style=flat-square&labelColor=161515">
59
+ <img alt="AWS Trainium2" src="https://img.shields.io/badge/AWS-Trainium2-fd7014?style=flat-square&labelColor=161515">
60
+ <img alt="Neuron SDK 2.32" src="https://img.shields.io/badge/Neuron%20SDK-2.32-fd7014?style=flat-square&labelColor=161515">
61
+ </p>
62
+
63
+ <p align="center">
64
+ <a href="#quickstart"><b>Quickstart</b></a> ·
65
+ <a href="docs/RESULTS.md"><b>Benchmarks</b></a> ·
66
+ <a href="docs/README.md"><b>Docs</b></a> ·
67
+ <a href="docs/MEGAKERNELS.md"><b>Kernels</b></a> ·
68
+ <a href="https://runanywhere.ai/blog/glm-5-3-flash-trainium2-nki-megakernels"><b>Blog post</b></a> ·
69
+ <a href="https://runanywhere.ai"><b>runanywhere.ai</b></a>
70
+ </p>
71
+
72
+ **TrnRT** is an open inference engine for large language models on AWS Trainium. It serves an OpenAI-compatible API
73
+ from one `trn2.48xlarge`, runs decode as NKI megakernels (about one kernel per layer half), and keeps a prefix cache
74
+ across device and host memory. **GLM-5.3-Flash is the first supported model; more open models are on the way.**
75
+
76
+ How we built it, with the AgentX results: [Serving GLM-5.3-Flash on one Trainium2 box with NKI layer megakernels](https://runanywhere.ai/blog/glm-5-3-flash-trainium2-nki-megakernels).
77
+
78
+ <p align="center">
79
+ <picture>
80
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/cards-dark.svg">
81
+ <source media="(prefers-color-scheme: light)" srcset="docs/assets/cards-light.svg">
82
+ <img alt="3.57M tokens per minute on one trn2.48xlarge (AgentX, batch 12). 24 ms batch-8 decode step, down from 32.2 ms with NKI megakernels. $0.040 per million tokens at the spot price, $0.167 on a capacity block." src="docs/assets/cards-dark.svg" width="100%">
83
+ </picture>
84
+ </p>
85
+
86
+ ## Highlights
87
+
88
+ | Feature | What it does |
89
+ |---|---|
90
+ | **NKI megakernels** | One fused kernel per layer half for decode: KDA attention, the fused DSA layer, mHC and the MoE FFN. |
91
+ | **1M-token context** | Sparse attention (top 2,048) and linear attention, with fixed-size state. |
92
+ | **Prefix cache** | A radix tree over FP8 KV pages, plus a host-memory tier for evicted pages and state checkpoints. |
93
+ | **Two engines per box** | Each engine is tensor-parallel over 32 logical NeuronCores, behind a session-affine router. |
94
+ | **OpenAI API** | Chat and completions, streaming, tool calls and reasoning output. |
95
+ | **Offline compile** | Every graph is built on a CPU host; the serving box loads them and compiles nothing by default. |
96
+
97
+ ## Quickstart
98
+
99
+ You need Docker, a `trn2.48xlarge` to serve on, and any x86_64 host to compile on. New to Trainium? Start with
100
+ [docs/AWS.md](docs/AWS.md).
101
+
102
+ **1. Build the image** (Neuron SDK 2.32 (neuronx-cc 2.27), Python 3.13)
103
+
104
+ ```bash
105
+ git clone https://github.com/RunanywhereAI/trnrt.git && cd trnrt
106
+ docker build -f docker/Dockerfile \
107
+ --build-arg TRNRT_VERSION=$(python3 -c 'import trnrt; print(trnrt.__version__)') \
108
+ --build-arg TRNRT_REVISION=$(git rev-parse HEAD) -t trnrt .
109
+ ```
110
+
111
+ **2. Build the compile cache** (any x86_64 host, no NeuronCore needed; takes hours)
112
+
113
+ ```bash
114
+ OUT=/data/trnrt REV=eb9eb208eb0d988989d07a6a12d0fdeb5f52574a
115
+ mkdir -p $OUT/nki $OUT/work
116
+ trnrt() { docker run --rm -e HF_TOKEN -v $OUT:$OUT \
117
+ -v $OUT/nki:/var/tmp/nki-intermediate-cache trnrt "$@"; }
118
+ trnrt compile shapes zai-org/GLM-5.3-Flash --revision $REV --out $OUT
119
+ trnrt compile decisions --model zai-org/GLM-5.3-Flash --revision $REV --out $OUT
120
+ trnrt compile capture --out $OUT -- --model $OUT/shapes
121
+ trnrt compile compile --out $OUT --work-root $OUT/work
122
+ trnrt compile strip --out $OUT
123
+ ```
124
+
125
+ **3. Serve** (on the `trn2.48xlarge`, with `$OUT/cache` and `$OUT/nki` copied over)
126
+
127
+ ```bash
128
+ hf download zai-org/GLM-5.3-Flash --revision eb9eb208eb0d988989d07a6a12d0fdeb5f52574a \
129
+ --local-dir /models/GLM-5.3-Flash
130
+ docker run --rm --privileged --network host --ipc=host \
131
+ -v /data/trnrt/cache:/cache \
132
+ -v /data/trnrt/nki:/var/tmp/nki-intermediate-cache \
133
+ -v /models/GLM-5.3-Flash:/model \
134
+ -e NEURON_LIBTORCH_CACHE_ROOT=/cache \
135
+ trnrt serve --model /model --port 8000
136
+ ```
137
+
138
+ **4. Call it** with any OpenAI client
139
+
140
+ ```python
141
+ from openai import OpenAI
142
+
143
+ client = OpenAI(base_url="http://localhost:8000/v1", api_key="unused")
144
+ reply = client.chat.completions.create(
145
+ model="glm",
146
+ messages=[{"role": "user", "content": "Write a haiku about Trainium."}],
147
+ extra_body={"session_id": "my-session"}, # keeps a conversation on one engine's prefix cache
148
+ )
149
+ print(reply.choices[0].message.content)
150
+ ```
151
+
152
+ The full guide covers what each step needs, start-up checks, the batch 4, 8 and 12 configurations and every flag:
153
+ [deploy](docs/DEPLOY.md) · [API](docs/API.md) · [configuration](docs/CONFIGURATION.md).
154
+
155
+ ## Supported hardware and models
156
+
157
+ <p align="center">
158
+ <picture>
159
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/support-dark.svg">
160
+ <source media="(prefers-color-scheme: light)" srcset="docs/assets/support-light.svg">
161
+ <img alt="Hardware: AWS Trainium2 (trn2.48xlarge, 16 chips, 96 GiB HBM each, Neuron SDK 2.32), supported. Models: GLM-5.3-Flash (320B MoE, 18B active, FP8, 1M-token context), supported. More open models: coming soon." src="docs/assets/support-dark.svg" width="100%">
162
+ </picture>
163
+ </p>
164
+
165
+ | Target | Status |
166
+ |---|---|
167
+ | **AWS Trainium2**, `trn2.48xlarge` (16 chips, 2 engines × TP 32, LNC 2) | ✅ Supported |
168
+ | **[GLM-5.3-Flash](https://huggingface.co/zai-org/GLM-5.3-Flash)** (320B MoE, 18B active, FP8, 1M-token context) | ✅ Supported |
169
+ | More open models | 🔜 Coming soon. [Request a model](https://github.com/RunanywhereAI/trnrt/issues/new?template=30-model-request.yml) |
170
+
171
+ GLM-5.3-Flash is where TrnRT starts. The engine, router, caches and compile pipeline are built to carry more model
172
+ families, and [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md#adding-a-model-family) describes what a new one needs.
173
+
174
+ ## Benchmarks
175
+
176
+ [SemiAnalysis AgentX](https://github.com/SemiAnalysisAI/agentx-harness) replays real coding-agent sessions. One
177
+ `trn2.48xlarge` ran it at a 1M-token context with 32 concurrent agents, for one hour per point:
178
+
179
+ | Decode batch | Requests / min | Tokens / min | Decode tok/s per user (p50) | First token, cached (p50) | $ / M tokens (spot) |
180
+ |---|---|---|---|---|---|
181
+ | 4 | 19.3 | 2.36M | 46.6 | 76.73 s | $0.061 |
182
+ | 8 | 25.2 | 3.02M | 29.4 | 28.82 s | $0.047 |
183
+ | **12** (default) | **28.9** | **3.57M** | 22.3 | 6.53 s | **$0.040** |
184
+
185
+ Tokens count input (cached input included) and output. Spot price: $8.60/h, us-east-2, 3 Nov 2026. On a capacity block
186
+ at $35.76/h, the batch 12 cost is $0.167 per million tokens. Full tables, cold-prompt latencies, long prompts and
187
+ methodology are in [docs/RESULTS.md](docs/RESULTS.md).
188
+
189
+ These numbers were measured with an earlier build of TrnRT. This repository passes these checks against that build
190
+ ([docs/KNOWN_ISSUES.md](docs/KNOWN_ISSUES.md#verification-status)):
191
+
192
+ - Graph equivalence: EQUAL on all 32 ranks, for all 157 graphs that build compiles in the default batch-12
193
+ configuration.
194
+ - Outputs: byte-identical to that build's on 384 of 384 requests.
195
+ - Serving: the two-engine serve in the [Quickstart](#quickstart) passes end to end.
196
+
197
+ ## How it works
198
+
199
+ <p align="center">
200
+ <picture>
201
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/architecture-dark.svg">
202
+ <source media="(prefers-color-scheme: light)" srcset="docs/assets/architecture-light.svg">
203
+ <img alt="Clients reach a session-affine router on port 8000, which sends each session to one of two engines. Each engine is tensor-parallel over 32 logical NeuronCores on 8 chips. Offline, five steps build the compile cache the engines load." src="docs/assets/architecture-dark.svg" width="100%">
204
+ </picture>
205
+ </p>
206
+
207
+ Decode is not limited by memory bandwidth here; small instructions, kernel boundaries and exposed collectives dominate it. So
208
+ each decode megakernel follows three rules: keep the working set in SBUF, use both physical cores symmetrically, and move
209
+ the collectives into the kernel. [docs/MEGAKERNELS.md](docs/MEGAKERNELS.md) walks through every kernel.
210
+
211
+ ## Repository layout
212
+
213
+ ```text
214
+ trnrt/
215
+ ├── __main__.py CLI: serve, engine, compile
216
+ ├── serve/ OpenAI API, session-affine router, output parsers
217
+ ├── engine/ scheduler, prefix caches, tensor parallelism
218
+ ├── models/ GLM-5.3-Flash: KDA, DSA, mHC, MoE, FP8 loading
219
+ ├── kernels/ NKI decode megakernels and prefill kernels
220
+ └── compile/ offline compile: shapes, capture, neuronx-cc, strip
221
+ docker/ the serving and compile image
222
+ tools/ graph-equivalence gate, device checks, doc checks
223
+ tests/ CPU test suite (no NeuronCore needed)
224
+ docs/ guides, results, kernel notes
225
+ ```
226
+
227
+ More in [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
228
+
229
+ ## Development
230
+
231
+ ```bash
232
+ make dev # editable install with test and lint tools (Python 3.13)
233
+ make check # lint, type-check, then the CPU test suite
234
+ ```
235
+
236
+ See [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) for the test tiers and CI, [CONTRIBUTING.md](CONTRIBUTING.md) to send a
237
+ change (pull requests target `development`), [SUPPORT.md](SUPPORT.md) to get help, and [SECURITY.md](SECURITY.md) to
238
+ report a vulnerability.
239
+
240
+ ## AWS resources
241
+
242
+ | Resource | Link |
243
+ |---|---|
244
+ | Trainium2 and `trn2` instances | [aws.amazon.com/ec2/instance-types/trn2](https://aws.amazon.com/ec2/instance-types/trn2/) |
245
+ | AWS Neuron SDK documentation | [awsdocs-neuron.readthedocs-hosted.com](https://awsdocs-neuron.readthedocs-hosted.com/) |
246
+ | NKI (Neuron Kernel Interface) | [NKI documentation](https://awsdocs-neuron.readthedocs-hosted.com/en/latest/general/nki/index.html) |
247
+ | Neuron deep learning containers | [github.com/aws-neuron/deep-learning-containers](https://github.com/aws-neuron/deep-learning-containers) |
248
+ | EC2 Capacity Blocks for ML | [aws.amazon.com/ec2/capacityblocks](https://aws.amazon.com/ec2/capacityblocks/) |
249
+
250
+ ## Acknowledgments
251
+
252
+ Thanks to the AWS Neuron team for NKI and its documentation, to Z.ai for releasing GLM-5.3-Flash, and to SemiAnalysis
253
+ for AgentX and its public traces. TrnRT includes code derived from other Apache-2.0 projects: see [NOTICE](NOTICE)
254
+ and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
255
+
256
+ ## License
257
+
258
+ [Apache License 2.0](LICENSE).
259
+
260
+ <p align="center">
261
+ <br>
262
+ <a href="https://runanywhere.ai">
263
+ <picture>
264
+ <source media="(prefers-color-scheme: dark)" srcset="docs/assets/runanywhere-lockup-dark.svg">
265
+ <source media="(prefers-color-scheme: light)" srcset="docs/assets/runanywhere-lockup-light.svg">
266
+ <img alt="RunAnywhere" src="docs/assets/runanywhere-lockup-dark.svg" height="32">
267
+ </picture>
268
+ </a>
269
+ <br>
270
+ <sub>Built by <a href="https://runanywhere.ai">RunAnywhere</a>.</sub>
271
+ </p>
272
+
273
+ <sub>AWS, Amazon Web Services, Trainium, Inferentia and Neuron are trademarks of Amazon.com, Inc. or its affiliates. The
274
+ AWS logo appears here as published in AWS's Architecture Icons. TrnRT is an independent open-source project, not
275
+ affiliated with or endorsed by Amazon Web Services.</sub>