MakotoUwu opened a new pull request, #19766:
URL: https://github.com/apache/tvm/pull/19766
### Summary
This PR adds a small set of TVM runtime, Relax frontend, TIRx, DLight,
WebGPU target, and WebAssembly runtime prerequisites that are exercised by
Gemma 4 E2B text-only WebGPU execution through downstream MLC/WebLLM.
The intent is not to add Gemma 4 model support to Apache TVM directly. The
downstream model implementation remains in MLC-LLM. This PR only contains
lower-layer behavior needed by that downstream path.
### Changes
- Make `DictAttrs::HasNonzeroAttr` accept `IntImm` and bool attributes, in
addition to native integer attributes. This fixes TIRx attrs such as
`tirx.noalias` when represented as `IntImm`.
- Let DLight GPU matmul schedule rules return non-applicable for helper
PrimFuncs without a root block, instead of raising during default schedule
application.
- Add `max_shared_memory_per_block = 32768` as the default WebGPU target
option in `src/backend/webgpu/codegen/target_kind.cc`.
- Add `freq_dim_base` support for GPT-J-style RoPE frequency generation, so
callers can decouple rotated dimensions from the frequency-base dimension.
- Mark generated RoPE PrimFuncs as private to avoid duplicate module-scope
symbols when downstream code creates multiple RoPE factories.
- Group TIRx device functions by target kind name instead of full target
string to avoid splitting a single backend into multiple device modules when
attributes differ.
- Fix PagedKVCache metadata reservation ordering and route sliding MHA
attention through the MHA path.
- Make the wasm runtime tolerate native-f32 payloads tagged as
`f32-to-bf16`, and add chunked tensor loading support for large records.
- Add focused tests for the `IntImm` attr case and the non-root helper
PrimFunc DLight matmul case.
### Validation
Local validation on macOS after rebasing on current `apache/main`:
```text
cmake --build build --parallel 8
```
Result: passed. The build produced nonfatal warnings, mostly
`-Woverloaded-virtual` warnings around TIRx visitor overloads, plus LLVM
deprecation warnings.
Focused tests:
```text
TVM_LIBRARY_PATH=build/lib python -m pytest \
tests/python/ir/test_ir_attrs.py::test_dict_attrs_has_nonzero_attr_accepts_int_imm
-q
TVM_LIBRARY_PATH=build/lib python -m pytest \
tests/python/s_tir/dlight/test_gpu_matmul.py::test_matmul_rule_skips_non_root_block_helper_func
-q
```
Result:
```text
1 passed in 0.02s
1 passed in 0.03s
```
Branch shape and hygiene:
```text
git rev-list --left-right --count apache/main...HEAD
0 1
git diff --check apache/main...HEAD
# no output
```
Downstream WebLLM smoke evidence from the Apache-prep wasm:
- Wasm SHA256:
`70d7295dc91b622b79ceeada2c64b4c20787832631c04e3714de95db04515dfc`
- Browser result title: `apache-pr-validate:ok`
- Prompt checks:
- `Hi`: load `11.0s`, generation `0.7s`
- France capital: load `4.3s`, generation `0.2s`, output `Paris`
- Haiku: load `4.0s`, generation `2.4s`
### Non-goals
- This PR does not add Gemma 4 model registration to TVM.
- This PR does not add MLC-LLM model code.
- This PR does not add WebLLM model-list entries.
- This PR does not claim multimodal Gemma 4 support.
- Full MLC vs Transformers.js benchmarking is intentionally deferred to
downstream artifact/model-card work.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]