Defense Secretary Ash Carter, during an unannounced visit to Iraq on Thursday, heard some badly needed encouragement regarding the fight against the Islamic State -- with advisers telling him 3,000 newly installed, coalition-trained Iraqi forces have joined the fight to retake Ramadi and are seeing some success.

This would be a welcome development given earlier reports that Iraqi soldiers fled the fight when ISIS forces launched their assault on Ramadi.

A senior defense official attributed the success to better training, better equipment and improved moral. One newly trained Iraqi unit is said to have advanced about three miles toward Ramadi in a 24-hour period – a difficult task considering the city is ringed with ISIS-planted explosives.

The official described the assault on Ramadi as in an "isolation" phase, in which the city is encircled to deprive ISIS of resupply. Next will come the actual assault, a process that defense officials say will be deliberate and selective to avoid civilian casualties and limit damage, so that residents have homes and businesses to return to.

The 3,000 new trainees are among thousands of Iraqi Security Forces soldiers preparing for an assault to retake the city.

But the development is tempered by some sobering realities in Iraq.

Baghdad was hit this week with two car bombs that took more than 20 lives. A massive truck bomb was detonated east of Baghdad last Saturday killing more than a hundred, one of the largest blasts in the last decade in Iraq.

Further, ISIS’ rampage through Iraq in roughly the last year has led to one of the largest humanitarian crises in the world. The United Nations estimates that 8.2 million Iraqis need humanitarian assistance; 3.1 million have left their homes, many moving into hotels or with relatives away from the fighting; and 4.4 million are considered "food insecure," according to the United Nations.

Carter arrived in Baghdad as part of a tour through Middle East countries. It is Carter's first visit to Iraq since he took office in February.

Carter is not expected to announce any major change in U.S. strategy or increase in U.S. troop levels. The approximately 3,360 troops now in Iraq are largely involved in training Iraqi troops, advising Iraqi commanders on battle plans, and providing security for U.S. personnel and facilities. The U.S., joined by several coalition partners, also is conducting airstrikes daily to chip away at the Islamic State's grip on large parts of Iraq.

The visit, however, comes at an important moment for the Iraqi government, which has announced the counteroffensive to retake Ramadi, the capital of Anbar province.

The Ramadi campaign will be a crucial test not only for the Iraqi government led by Prime Minister Haider al-Abadi, but also for the U.S. strategy of relying on Iraqi security forces, operating in coordination with U.S.-led coalition airstrikes, to overcome the smaller Islamic State forces.

The Associated Press contributed to this report.