Skip to content

feat(weight-free): weight-free ONNX export for causalLM - #1248

Open
quic-amitraj wants to merge 1 commit into
mainfrom
quic-enable-weightfree-for-causallm
Open

feat(weight-free): weight-free ONNX export for causalLM#1248
quic-amitraj wants to merge 1 commit into
mainfrom
quic-enable-weightfree-for-causallm

Conversation

@quic-amitraj

Copy link
Copy Markdown
Contributor

Summary

Adds weight-free ONNX export for causal LM models on top of the dynamo export infrastructure.

Weight-free export builds the model on meta device (no weights in RAM), exports ONNX graph structure only, and lets the QAIC compiler load weights directly from the original safetensors checkpoint at compile time via weight_spec.json.

New files

  • QEfficient/exporter/weight_free/ — core weight-free export, weight spec format, checkpoint prep pipeline (MoE expert stacking, dtype
    conversion, .bin→safetensors auto-convert)

  • examples/text_generation/weight_free/ — single-model smoke test, CB weight-free smoke test

    Key changes

  • modeling_qeff.pyuse_weight_free_export flag; reorder example_inputs/dynamic_shapes by forward() signature so torch.export
    binds them correctly; skip SplitTensorsTransform; embed weight_spec.json as ONNX metadata; symlink prepared checkpoint next to ONNX

  • modeling_auto.pyuse_weight_free_export wired through export() and compile(); auto-enable dynamo=True

  • onnx_transforms.py — disable unsupported transforms for dynamo path

  • export_utils.py — separate dynamo/TorchScript subfunction setup paths

  • torch_patches.pytemporarily_enable/disable_nested_compile_regions()

  • core.py — dtype suffix in prepared checkpoint dir; prune fake initializers after meta-device export

    Model fixes

  • codegen — fix embed_positions device/dtype for weight-free subfunction tracing

  • glm4_moelogits.float() to fix runtime buffer mismatch; rotary cos/sin device sync; _rotary_dim attribute; MoE expert placeholder
    dtype

  • granitemoe, mixtral, phi3, qwen3_moe — rotary cos/sin device/dtype sync for meta-device tracing; MoE expert placeholder dtype

    • continuous_batching.py — fix use_dynamo=Truedynamo=True

    Tests

    pip install -e .[test]
    pytest tests/weight_free/ -m "not on_qaic" -n auto -v
    

Signed-off-by: Amar <amarshar@qti.qualcomm.com>
Signed-off-by: Amit Raj <amitraj@qti.qualcomm.com>
Co-authored-by: Amit Raj <amitraj@qti.qualcomm.com>
@quic-amitraj
quic-amitraj force-pushed the quic-enable-weightfree-for-causallm branch from 366a956 to ffa2688 Compare August 7, 2026 08:16
@quic-amitraj
quic-amitraj marked this pull request as ready for review August 7, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants