Skip to content

Feature/half select - #788

Open
Minsikc wants to merge 4 commits into
IBM:masterfrom
Minsikc:feature/half-select
Open

Minsikc wants to merge 4 commits into
IBM:masterfrom
Minsikc:feature/half-select

Conversation

@Minsikc

@Minsikc Minsikc commented Aug 25, 2026

Copy link
Copy Markdown

Related issues

Description

Details

Minsikc and others added 4 commits March 3, 2026 17:44
- Add uint8_t *dev_hs_states_ member for GPU HS state storage
- Add bool hs_gpu_enabled_ flag for allocation tracking
- Add dev_global_params_ and gp_count_ for kernel parameter passing
- Implement allocateHSGPU(): lazy allocation with cudaMalloc, init to HS1
- Implement freeHSGPU(): proper cleanup with cudaFree
- Implement resetHSGPU(): restore all states to HS1 via cudaMemset
- Implement getDevHSStates(): accessor for kernel use
- Update destructor to call freeHSGPU() preventing memory leaks
- Update copy constructor for deep-copy of HS states
- Update move assignment for ownership transfer
- Update swap function to handle HS members
- Override getGlobalParamsData() to return global params when available

Memory layout: d_size * x_size uint8_t values, initialized to HS1 (value=1)
Global params infrastructure: ready for [write_noise_std, hs_decay] encoding
Pattern: follows dev_persistent_weights_ allocation strategy

Ref: Task 4 from aihwkit-hs-cuda plan
- Add PulseType::HalfselectedStochastic and PulseType::HalfselectedStochasticStream
  as case labels in makeCounts() switch statement
- Both variants alias to existing StochasticCompressed logic
- Pulse generation is identical; difference is only in kernel dispatch after BLM
- Follows CPU SparseBLM pattern for HS variant handling
- Prevents RPU_FATAL crash when creating tile with HS PulseType on CUDA
Add half-select-aware pulsed update to the RPU simulator:
- New PulseType variants HALFSELECTED_STOCHASTIC / HALFSELECTED_STOCHASTIC_STREAM
  (Python enum + C++ meta parameter), plus STOCHASTIC_STREAM support.
- HS state tracking on PulsedRPUDevice (CPU) and PulsedRPUDeviceCuda (GPU),
  with hs_decay parameter on ConstantStepDevice and transition-count readout
  exposed via enable_hs_tracking() / get_hs_transition_counts().
- CPU: SparseBitLineMaker and weight updater apply HS decay on half-selected
  cells; CUDA: pwu_kernel_hs.h kernels wired into constant-step and
  linear-step device updates.
- Tests: tests/test_hs_state_tracking.cpp, tests/test_hs_training_cpu.py,
  tests/test_hs_verify.py. Examples 01-03 updated to exercise HS pulse types.
- CUDA_HS_BUILD.md documents building/verifying HS on GPU (WSL2, sm_75).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@PabloCarmona

Copy link
Copy Markdown
Collaborator

Hello @Minsikc can you give us some context and explanation on the PR description about your changes? Thanks!

@PabloCarmona

PabloCarmona commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

@Minsikc could you update the PR with info about what is does, how and some details? This PR changes a lot of files specially the core of the sdk: CUDA and C++ source code.

If we don't get any update on this we will close the PR.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants