Feat/precomputed noise pool - #518
Conversation
|
👋 Hi! Thank you for contributing. We also recommend installing prek and configuring it to check your code before every local commit. |
|
📖 This PR includes doc changes. Download the preview (built from uv pip install -r docs/requirements-docs.txt
mkdocs serve |
ce1e679 to
b07b686
Compare
|
|
||
| _USE_NOISE_POOL = os.environ.get("SPYRE_USE_NOISE_POOL", "0") == "1" | ||
| _NOISE_POOL_MULTIPLIER = int(os.environ.get("SPYRE_NOISE_POOL_MULTIPLIER", "32")) | ||
| _SAMPLER_TIMING = int(os.environ.get("SPYRE_SAMPLER_TIMING", "0")) |
There was a problem hiding this comment.
a few thoughts:
SPYRE_SAMPLER_TIMINGsmells like something that we should be using the profiler for instead of injecting into a production code path- We need to do config properly here- at the minimum the
envs.pyapproach that puts all the config levers in one place with documentation, caching, and override semantics is required. - This feels like running before we crawl, it's an optimization for noise generation for sampling on a specific cpu platform but we haven't even done the work yet to put the rest of the sampling into a torch.compiled path on the spyre devices. The model / sampler split on sendnn-inference was a limitation that we couldn't work around that no longer exists here
There was a problem hiding this comment.
Agree on sequencing. this is only an opt-in host stopgap for slow Exp(1) on s390x while sampling is still on CPU — it doesn’t move sampling onto Spyre.
for that few pain point i have analyzed:
- argmax— CPU fallback
- topk— native but unusable (k≤4, fp16 indices wrong past 2048)
- cumsum— CPU fallback (top-p)
- sort— unsupported (top-p / joint top-k+top-p)
- scatter / scatter_add / gather / index_put_— incomplete/broken (top-p, penalties, logprobs)
- exponential/ RNG— CPU fallback (temp / random sample)
CC: @dilipgb @rishikakedia
tdoublep
left a comment
There was a problem hiding this comment.
I am concerned that this approach will change the sampling statistics in strange and ways that are hard to interpret. I would prefer to hold off on merging.
Port sendnn-inference#1046 sampling stages to spyre-inference: 1) async Exp(1) log-noise ring buffer on a background thread 2) TP rank-0 sample + broadcast when logits are on CPU 3) log-space Gumbel argmax(logits - log_noise) to skip softmax Wire SpyreSampler into TorchSpyreModelRunner and add unit tests. Signed-off-by: Avishek Goswami <avishek.goswami@ibm.com>
Port the vLLM-style envs module from the precomputed-noise-pool work and wire SPYRE_ASYNC_NOISE_SCALE into Holtz's async ring buffer. The static Exp(1) pool is superseded by the background refill path. Signed-off-by: Avishek Goswami <avishek.goswami@ibm.com>
Async ring buffer is the host noise path; remove leftover mentions of the superseded static pool. Signed-off-by: Avishek Goswami <avishek.goswami@ibm.com>
0303451 to
f51eb4c
Compare
Drop the envs/noise-scale extras that are not in Holtz's PR. Match his SpyreSampler vocab lookup, and wire with is_vllm_config_compatible fallback to the default Sampler (same as SpyreCausalLM). Signed-off-by: Avishek Goswami <avishek.goswami@ibm.com>
Address review: keep all sampler knobs in a vLLM-style envs module (docs, defaults, cache, is_set overrides). Wire SPYRE_USE_SPYRE_SAMPLER and SPYRE_ASYNC_NOISE_SCALE; do not inject production-path timing — use the Kineto profiler instead. Signed-off-by: Avishek Goswami <avishek.goswami@ibm.com>
Under the Spyre plugin, default-device Spyre tensors hang on background refill and deadlock borrow_rows after the first wrap. Signed-off-by: Avishek Goswami <avishek.goswami@ibm.com>
Under the Spyre plugin the producer thread was dying on Torch fill_/ exponential_ (absent from the pytest-timeout dump), so borrow_rows deadlocked after the first wrap. Keep a NumPy backing store shared with a Torch CPU view; surface producer failures instead of waiting forever. Signed-off-by: Avishek Goswami <avishek.goswami@ibm.com>
|
As the scope of this PR changed towards the direction of torch-spyre/sendnn-inference#1046: I agreed with @tdoublep to provide an analogous solution to sendnn-inference here; however I think PR 1046 should not be mirrored 1:1 here. For example, the softmax function could be properly computed on device with this stack. There is currently no rush to address the sampler before batching support lands, so I will provide a draft of that idea in about two weeks. |
Description
argmax(logits - log_noise)) so the hot path avoids softmax.build_spyre_samplerin the Spyre model runner; document host-sampler config; add unit tests for the ring buffer, sampler, and top-k/top-p path.docs in
docs/user_guide/configuration.md.Related Issues
Relates to host sampling performance / sendnn-style Exp(1) pool reuse.
Test Plan
pytest tests/test_spyre_noise_pool.py -q(pool fill, slice, seeded path, opt-in wiring)SPYRE_USE_NOISE_POOL=1 SPYRE_SAMPLER_TIMING=50 \ python examples/offline_inference/torch_spyre_inference.py # use temperature > 0; greedy does not exercise the poolChecklist
bash format.sh)Signed-off-by:line (DCO compliance)