Skip to content

Commit bea3516

Browse files
committed
Add dependencies check for ptq
Signed-off-by: Kai Xu <kaix@nvidia.com>
1 parent 202c3d3 commit bea3516

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

.claude/skills/ptq/SKILL.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ Check the support table in `examples/llm_ptq/README.md` for verified HF models.
2424
- **Listed** → supported, use `hf_ptq.py` (step 4A/4B)
2525
- **Not listed** → read `references/unsupported-models.md` to determine if `hf_ptq.py` can still work or if a custom script is needed (step 4C)
2626

27+
## Step 2.5 — Check for model-specific dependencies
28+
29+
If the model uses `trust_remote_code` (check `config.json` for `auto_map`), inspect its custom Python files for imports not present in the container:
30+
31+
```bash
32+
grep -h "^from \|^import " <model_path>/modeling_*.py | sort -u
33+
```
34+
35+
**Known dependency patterns:**
36+
37+
| Import found | Packages to install |
38+
| --- | --- |
39+
| `from mamba_ssm` / `from causal_conv1d` | `mamba-ssm causal-conv1d` (Mamba/hybrid models: NemotronH, Jamba) |
40+
41+
If extra deps are needed:
42+
- **Launcher (4B)**: set `EXTRA_PIP_DEPS` in the task's `environment` section — `ptq.sh` installs them automatically
43+
- **Manual (4A)**: `unset PIP_CONSTRAINT && pip install <deps>` before running `hf_ptq.py`
44+
2745
## Step 3 — Choose quantization format
2846

2947
**First**, check for a model-specific recipe:
@@ -124,6 +142,7 @@ Report the path and size to the user.
124142

125143
## Common Pitfalls
126144

145+
- **Model-specific dependencies**: Models with `trust_remote_code` may import packages not in the container (e.g., `mamba-ssm` for hybrid Mamba models). See Step 2.5. Use `EXTRA_PIP_DEPS` env var with the launcher, or install manually before running `hf_ptq.py`
127146
- **Transformers version**: New models may need a newer version of transformers than what's installed. Check `config.json` for `transformers_version`. In containers, beware of `PIP_CONSTRAINT` blocking upgrades — see `references/slurm-setup-ptq.md` for workarounds
128147
- **Gated datasets**: Some calibration datasets require HF authentication. Ensure `HF_TOKEN` is set in the job environment, or use `--dataset cnn_dailymail` as a non-gated alternative
129148
- **NFS root_squash + Docker**: See `skills/common/slurm-setup.md` section 5

tools/launcher/common/hf/ptq.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525

2626
set -e
2727

28+
# Install extra pip dependencies if specified (e.g., mamba-ssm for hybrid Mamba models).
29+
if [ -n "$EXTRA_PIP_DEPS" ]; then
30+
echo "Installing extra dependencies: $EXTRA_PIP_DEPS"
31+
unset PIP_CONSTRAINT
32+
pip install $EXTRA_PIP_DEPS
33+
fi
34+
2835
REPO=""
2936
LOCAL_DIR=""
3037
PTQ_ARGS=()

0 commit comments

Comments
 (0)